Logo video2dn
  • Сохранить видео с ютуба
  • Категории
    • Музыка
    • Кино и Анимация
    • Автомобили
    • Животные
    • Спорт
    • Путешествия
    • Игры
    • Люди и Блоги
    • Юмор
    • Развлечения
    • Новости и Политика
    • Howto и Стиль
    • Diy своими руками
    • Образование
    • Наука и Технологии
    • Некоммерческие Организации
  • О сайте

Скачать или смотреть Ubuntu: How to create script with auto-complete? (5 solutions!)

  • Роэль Ван де Паар (Техническая помощь Роэля)
  • 2019-06-21
  • 249
Ubuntu: How to create script with auto-complete? (5 solutions!)
bashauto-completionquestionsolutionsolutions
  • ok logo

Скачать Ubuntu: How to create script with auto-complete? (5 solutions!) бесплатно в качестве 4к (2к / 1080p)

У нас вы можете скачать бесплатно Ubuntu: How to create script with auto-complete? (5 solutions!) или посмотреть видео с ютуба в максимальном доступном качестве.

Для скачивания выберите вариант из формы ниже:

  • Информация по загрузке:

Cкачать музыку Ubuntu: How to create script with auto-complete? (5 solutions!) бесплатно в формате MP3:

Если иконки загрузки не отобразились, ПОЖАЛУЙСТА, НАЖМИТЕ ЗДЕСЬ или обновите страницу
Если у вас возникли трудности с загрузкой, пожалуйста, свяжитесь с нами по контактам, указанным в нижней части страницы.
Спасибо за использование сервиса video2dn.com

Описание к видео Ubuntu: How to create script with auto-complete? (5 solutions!)

Ubuntu: How to create script with auto-complete?


The Question: When I use program like svn and I type in Gnome Terminal:
svn upd
and hit Tab it's autocompleted to:
svn update
Is it possible to do something like that in my custom bash script?

Solutions Sample (Please watch the whole video to see all solutions, in order of how many people found them helpful):

== This solution helped 39 people ==
You can use the http://www.gnu.org/s/bash/manual/bash...
Completion. Have look at /etc/bash_completion and /etc/bash_completion.d/* for
some examples.

== This solution helped 34 people ==
All of the bash completions are stored in /etc/bash_completion.d/. So if you're
building software with bash_completion it would be worthwhile to have the deb/
make install drop a file with the name of the software in that directory.
Here's an example bash completion script for Rsync:
bash completion for rsync

have rsync &&
_rsync()
{
TODO: _split_longopt

local cur prev shell i userhost path

COMPREPLY=()
cur=`_get_cword`
prev=${COMP_WORDS[COMP_CWORD-1]}

_expand || return 0

case "$prev" in
--@(config|password-file|include-from|exclude-from))
_filedir
return 0
;;
-@(T|-temp-dir|-compare-dest))
_filedir -d
return 0
;;
-@(e|-rsh))
COMPREPLY=( $( compgen -W 'rsh ssh' -- "$cur" ) )
return 0
;;
esac

case "$cur" in
-*)
COMPREPLY=( $( compgen -W '-v -q -c -a -r -R -b -u -l -L -H -p -
o -g -D -t -S -n -W -x -B -e -C -I -T -P -z -h -4 -6 --verbose --
quiet --checksum --archive --recursive --relative --backup
-backup-dir --suffix= --update --links --copy-links --copy-unsafe
links --safe-links --hard-links --perms --owner --group --devices
-times --sparse --dry-run --whole-file --no-whole-file --one-file
system --block-size= --rsh= --rsync-path= --cvs-exclude
-existing --ignore-existing --delete --delete-excluded --delete
after --ignore-errors --max-delete= --partial --force -
-numeric-ids --timeout= --ignore-times --size-only --modify-window=
--temp-dir= --compare-dest= --compress --exclude= --exclude-from= -
-include= --include-from= --version --daemon --no-detach
--address= --config= --port= --blocking-io --no-blocking-io --stats
--progress --log-format= --password-file= --bwlimit= --
write-batch= --read-batch= --help' -- "$cur" ))
;;
*:*)
find which remote shell is used
shell=ssh
for (( i=1; i < COMP_CWORD; i++ )); do
if [[ "${COMP_WORDS[i]}" == -@(e|-rsh) ]]; then
shell=${COMP_WORDS[i+1]}
break
fi
done
if [[ "$shell" == ssh ]]; then
remove backslash escape from :
cur=${cur/\:/:}
userhost=${cur%%?(\):*}
path=${cur#*:}
unescape spaces
path=${path//\\\\ / }
if [ -z "$path" ]; then
default to home dir of specified
user on remote host
path=$(ssh -o 'Batchmode yes' $userhost pwd 2>/dev/null)
fi
escape spaces; remove executables, aliases, pipes
and sockets; add space at end of file names
COMPREPLY=( $( ssh -o 'Batchmode yes' $userhost command ls -
aF1d "$path*" 2>/dev/null | sed -e 's/ /\\\ /g' -e 's/[*@|=]$//
g' -e 's/[^/]$/& /g' ) )
fi
;;
*)
_known_hosts_real -c -a "$cur"
_filedir
;;
esac

return 0
} &&
complete -F _rsync $nospace $filenames rsync

Local variables:
mode: shell-script
sh-basic-offset: 4
sh-indent-comment: t
indent-tabs-mode: nil
End:
ex: ts=4 sw=4 et filetype=sh
It would likely be worthwhile to review one of the bash completion files in
there that most closely matches your program. One of the simplest examples is
the rrdtool file.

== This solution helped 185 people ==
I'm six months late but I was looking for the same thing and found this:
You'll have to create a new file:
/etc/bash_completion.d/foo
For a static autocompletion (--help / --verbose for instance) add this:
_foo()
{
local cur prev opts
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
opts="--help --verbose --version"

With thanks & praise to God! With thanks to the many people who have made this project possible! | Content (except music & images) licensed under cc by-sa 3.0 | Music: https://www.bensound.com/royalty-free... | Images: https://stocksnap.io/license & others | With thanks to user UAdapter (https://askubuntu.com/users/8436), user Marco Ceppi (https://askubuntu.com/users/41), user Louis Soulez (https://askubuntu.com/users/192621), user kokosing (https://askubuntu.com/users/17489), user Florian Diesch (https://askubuntu.com/users/2369), user codeforester (https://askubuntu.com/users/615697), user Ben (https://askubuntu.com/users/483521), user 7ochem (https://askubuntu.com/users/378108), and the Stack Exchange Network (http://askubuntu.com/questions/68175). Trademarks are property of their respective owners. Disclaimer: All information is provided "AS IS" without warranty of any kind. You are responsible for your own actions. Please contact me if anything looks amiss at Roel D.OT VandePaar A.T gmail.com.

Комментарии

Информация по комментариям в разработке

Похожие видео

  • О нас
  • Контакты
  • Отказ от ответственности - Disclaimer
  • Условия использования сайта - TOS
  • Политика конфиденциальности

video2dn Copyright © 2023 - 2025

Контакты для правообладателей [email protected]