69 lines
1.4 KiB
Plaintext
Raw Normal View History

# bash completion for screen
have screen &&
2009-03-30 21:56:09 +02:00
_screen_sessions()
{
2009-10-04 19:42:50 +02:00
local pattern
2009-03-30 21:56:09 +02:00
2009-10-04 19:42:50 +02:00
if [ -n "$1" ]; then
pattern=".*$1.*"
else
2009-11-03 20:14:46 +02:00
pattern=".*"
2009-10-04 19:42:50 +02:00
fi
2009-03-30 21:56:09 +02:00
2009-10-04 19:42:50 +02:00
COMPREPLY=( $( command screen -ls | sed -ne \
2009-11-03 22:04:46 +02:00
's|^['$'\t'']\{1,\}\('"$cur"'[0-9]\{1,\}\.[^'$'\t'']\{1,\}\)'"$pattern"'$|\1|p' ) )
2009-03-30 21:56:09 +02:00
} &&
_screen()
{
local cur prev words cword
2009-10-04 19:42:50 +02:00
COMPREPLY=()
_get_comp_words_by_ref cur prev words cword
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
;;
-[dDx])
# list attached
_screen_sessions 'Attached'
return 0
;;
-s)
2009-12-09 01:01:49 +02:00
_shells
return 0
2009-10-04 19:42:50 +02:00
;;
-c)
_filedir
return 0
;;
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 \
-list -L -m -O -p -q -r -R -s -S -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