70 lines
1.4 KiB
Plaintext
Raw Normal View History

# bash completion for screen
have screen || return
2009-03-30 21:56:09 +02:00
_screen_sessions()
{
COMPREPLY=( $( compgen -W "$( command screen -ls | sed -ne \
's|^\t\{1,\}\([0-9]\{1,\}\.[^\t]\{1,\}\).*'"$1"'.*$|\1|p' )" \
-- "$cur" ) )
2009-03-30 21:56:09 +02:00
} &&
_screen()
{
local cur prev words cword
_init_completion || return
if ((cword > 2)); then
case ${words[cword-2]} in
-[dD])
_screen_sessions
return 0
;;
esac
fi
2009-03-30 21:56:09 +02:00
case $prev in
2009-10-04 19:42:50 +02:00
-[rR])
# list detached
_screen_sessions 'Detached'
return 0
;;
-[dD])
2009-10-04 19:42:50 +02:00
# list attached
_screen_sessions 'Attached'
return 0
;;
-x)
# list both
_screen_sessions
return 0
;;
2009-10-04 19:42:50 +02:00
-s)
2009-12-09 01:01:49 +02:00
_shells
return 0
2009-10-04 19:42:50 +02:00
;;
-c)
_filedir
return 0
;;
2011-04-25 15:19:48 +03:00
-T)
_terms
return 0
;;
2009-10-04 19:42:50 +02:00
esac
2009-03-30 21:59:58 +02:00
2009-10-04 19:42:50 +02:00
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-a -A -c -d -D -e -f -fn -fa -h -i -ln \
2011-04-25 15:19:48 +03:00
-list -L -m -O -p -q -r -R -s -S -t -T -U -v -wipe -x -X --help \
--version' -- "$cur" ) )
2009-10-04 19:42:50 +02:00
fi
} &&
complete -F _screen -o default screen
# Local variables:
# mode: shell-script
2009-10-04 19:42:50 +02:00
# sh-basic-offset: 4
# sh-indent-comment: t
2009-10-04 19:42:50 +02:00
# indent-tabs-mode: nil
# End:
2009-10-04 19:42:50 +02:00
# ex: ts=4 sw=4 et filetype=sh