screen: Drop pid prefixes from session name completions where possible.
Thanks-to: Alexey Zaytsev <alexey.zaytsev@gmail.com>
This commit is contained in:
parent
eefc69d83b
commit
6e4912d9cc
@ -4,9 +4,23 @@ have screen || return
|
|||||||
|
|
||||||
_screen_sessions()
|
_screen_sessions()
|
||||||
{
|
{
|
||||||
COMPREPLY=( $( compgen -W "$( command screen -ls | sed -ne \
|
local sessions=( $( command screen -ls | sed -ne \
|
||||||
's|^\t\{1,\}\([0-9]\{1,\}\.[^\t]\{1,\}\).*'"$1"'.*$|\1|p' )" \
|
's|^\t\{1,\}\([0-9]\{1,\}\.[^\t]\{1,\}\).*'"$1"'.*$|\1|p' ) )
|
||||||
-- "$cur" ) )
|
if [[ $cur == +([0-9])?(.*) ]]; then
|
||||||
|
# Complete sessions including pid prefixes
|
||||||
|
COMPREPLY=( $( compgen -W '${sessions[@]}' -- "$cur" ) )
|
||||||
|
else
|
||||||
|
# Create unique completions, dropping pids where possible
|
||||||
|
local -A res
|
||||||
|
local i tmp
|
||||||
|
for i in ${sessions[@]}; do
|
||||||
|
res[${i/#+([0-9])./}]+=" $i"
|
||||||
|
done
|
||||||
|
for i in ${!res[@]}; do
|
||||||
|
[[ ${res[$i]} == \ *\ * ]] && tmp+=" ${res[$i]}" || tmp+=" $i"
|
||||||
|
done
|
||||||
|
COMPREPLY=( $( compgen -W '$tmp' -- "$cur" ) )
|
||||||
|
fi
|
||||||
} &&
|
} &&
|
||||||
_screen()
|
_screen()
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user