mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-23 03:03:57 +08:00
fix broken completion of screen on osx, test on ubuntu and mac (#3271)
* fixes broken completion of screen on osx, test on ubuntu and mac with fish 2.3.1 * replaces sed, __fish_sgrep with fish builtin string * add completion for `screen -x` * adjust format (e.g. 12345.socket\t01/01/16 09:55:00 Detached)
This commit is contained in:
parent
8f0ea07eab
commit
044efef577
|
@ -1,14 +1,61 @@
|
|||
function __fish_complete_screen --description "Print a list of running screen sessions"
|
||||
screen -list | __fish_sgrep \^\t.\*\(.\*\)|sed -e 's/\t\(.*\)\t(\(.*\))/\1'\t'Screen: \2/'
|
||||
function __fish_detect_screen_socket_dir --description "Detect which folder screen uses"
|
||||
set screen_bin screen
|
||||
if not set -q __fish_screen_socket_dir
|
||||
set -g __fish_screen_socket_dir (eval $screen_bin -ls __fish_i_don_t_think_this_will_be_matched | string match -r "(?<=No Sockets found in ).*(?=\.)")
|
||||
end
|
||||
end
|
||||
|
||||
function __fish_complete_screen_general_list_mac --description "Get the socket list on mac"
|
||||
pushd $__fish_screen_socket_dir > /dev/null
|
||||
set -l sockets (ls)
|
||||
if test (count $sockets) -ne 0
|
||||
switch $argv
|
||||
case "Detached"
|
||||
stat -f "%Lp %SB %N" -t "%D %T" $sockets | string match -r '^6\d{2} .*$' | string replace -r '^6\d{2} (\S+ \S+) (\S+)' '$2\t$1 Detached'
|
||||
case "Attached"
|
||||
stat -f "%Lp %SB %N" -t "%D %T" $sockets | string match -r '^7\d{2} .*$' | string replace -r '^7\d{2} (\S+ \S+) (\S+)' '$2\t$1 Attached'
|
||||
end
|
||||
end
|
||||
popd > /dev/null
|
||||
end
|
||||
|
||||
function __fish_complete_screen_general_list --description "Get the socket list"
|
||||
screen -list | string match -r '^\t.*\(.*\)\s*\('$argv'\)\s*$'| string replace -r '\t(.*)\s+\((.*)\)\s*\((.*)\)' '$1\t$2 $3'
|
||||
end
|
||||
|
||||
function __fish_complete_screen_detached --description "Print a list of detached screen sessions"
|
||||
switch (uname)
|
||||
case Darwin
|
||||
__fish_complete_screen_general_list_mac Detached
|
||||
case '*'
|
||||
__fish_complete_screen_general_list Detached
|
||||
end
|
||||
end
|
||||
|
||||
function __fish_complete_screen_attached --description "Print a list of attached screen sessions"
|
||||
switch (uname)
|
||||
case Darwin
|
||||
__fish_complete_screen_general_list_mac Attached
|
||||
case '*'
|
||||
__fish_complete_screen_general_list Attached
|
||||
end
|
||||
end
|
||||
|
||||
function __fish_complete_screen --description "Print a list of running screen sessions"
|
||||
string join \n (__fish_complete_screen_attached) (__fish_complete_screen_detached)
|
||||
end
|
||||
|
||||
|
||||
# detect socket directory for mac users
|
||||
__fish_detect_screen_socket_dir
|
||||
|
||||
complete -c screen -x
|
||||
complete -c screen -s a -d 'Include all capabilitys'
|
||||
complete -c screen -s A -d 'Adapt window size'
|
||||
complete -c screen -s c -r -d 'Specify init file'
|
||||
complete -c screen -s d -d 'Detach screen' -a '(__fish_complete_screen)'
|
||||
complete -c screen -s D -d 'Detach screen' -a '(__fish_complete_screen)'
|
||||
complete -c screen -s r -d 'Reattach session' -a '(__fish_complete_screen)'
|
||||
complete -c screen -s d -d 'Detach screen' -a '(__fish_complete_screen)' -x
|
||||
complete -c screen -s D -d 'Detach screen' -a '(__fish_complete_screen)' -x
|
||||
complete -c screen -s r -d 'Reattach session' -a '(__fish_complete_screen)' -x
|
||||
complete -c screen -s R -d 'Reattach/create session'
|
||||
complete -c screen -o RR -d 'Reattach/create any session'
|
||||
complete -c screen -s e -x -d 'Escape character'
|
||||
|
@ -32,6 +79,6 @@ complete -c screen -s t -x -d 'Session title'
|
|||
complete -c screen -s U -d 'UTF-8 mode'
|
||||
complete -c screen -s v -d 'Display version and exit'
|
||||
complete -c screen -o wipe -d 'Wipe dead sessions'
|
||||
complete -c screen -s x -d 'Multi attach'
|
||||
complete -c screen -s x -d 'Multi attach' -a '(__fish_complete_screen_attached)' -x
|
||||
complete -c screen -s X -r -d 'Send command'
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user