File tree Expand file tree Collapse file tree 3 files changed +88
-0
lines changed
Expand file tree Collapse file tree 3 files changed +88
-0
lines changed Original file line number Diff line number Diff line change 1+ _stagfs_completion() {
2+ local IFS=$'\n'
3+ local response
4+
5+ response=$(env COMP_WORDS="${COMP_WORDS[*]}" COMP_CWORD=$COMP_CWORD _STAGFS_COMPLETE=bash_complete $1)
6+
7+ for completion in $response; do
8+ IFS=',' read type value <<< "$completion"
9+
10+ if [[ $type == 'dir' ]]; then
11+ COMPREPLY=()
12+ compopt -o dirnames
13+ elif [[ $type == 'file' ]]; then
14+ COMPREPLY=()
15+ compopt -o default
16+ elif [[ $type == 'plain' ]]; then
17+ COMPREPLY+=($value)
18+ fi
19+ done
20+
21+ return 0
22+ }
23+
24+ _stagfs_completion_setup() {
25+ complete -o nosort -F _stagfs_completion stagfs
26+ }
27+
28+ _stagfs_completion_setup;
29+
Original file line number Diff line number Diff line change 1+ function _stagfs_completion;
2+ set -l response (env _STAGFS_COMPLETE=fish_complete COMP_WORDS=(commandline -cp ) COMP_CWORD=(commandline -t ) stagfs);
3+
4+ for completion in $response ;
5+ set -l metadata (string split " ," $completion );
6+
7+ if test $metadata [1] = " dir" ;
8+ __fish_complete_directories $metadata [2];
9+ else if test $metadata [1] = " file" ;
10+ __fish_complete_path $metadata [2];
11+ else if test $metadata [1] = " plain" ;
12+ echo $metadata [2];
13+ end ;
14+ end ;
15+ end ;
16+
17+ complete --no-files --command stagfs --arguments " (_stagfs_completion)" ;
18+
Original file line number Diff line number Diff line change 1+ #compdef stagfs
2+
3+ _stagfs_completion() {
4+ local -a completions
5+ local -a completions_with_descriptions
6+ local -a response
7+ (( ! $+commands[stagfs] )) && return 1
8+
9+ response=("${(@f)$(env COMP_WORDS="${words[*]}" COMP_CWORD=$((CURRENT-1)) _STAGFS_COMPLETE=zsh_complete stagfs)}")
10+
11+ for type key descr in ${response}; do
12+ if [[ "$type" == "plain" ]]; then
13+ if [[ "$descr" == "_" ]]; then
14+ completions+=("$key")
15+ else
16+ completions_with_descriptions+=("$key":"$descr")
17+ fi
18+ elif [[ "$type" == "dir" ]]; then
19+ _path_files -/
20+ elif [[ "$type" == "file" ]]; then
21+ _path_files -f
22+ fi
23+ done
24+
25+ if [ -n "$completions_with_descriptions" ]; then
26+ _describe -V unsorted completions_with_descriptions -U
27+ fi
28+
29+ if [ -n "$completions" ]; then
30+ compadd -U -V unsorted -a completions
31+ fi
32+ }
33+
34+ if [[ $zsh_eval_context[-1] == loadautofunc ]]; then
35+ # autoload from fpath, call function directly
36+ _stagfs_completion "$@"
37+ else
38+ # eval/source/. command, register function for later
39+ compdef _stagfs_completion stagfs
40+ fi
41+
You can’t perform that action at this time.
0 commit comments