fork/fish-shell

git clone https://git.julia.blue/fork/fish-shell

Johannes AltmanningerMerge branch 'completions-to-use-expanded-tokens'a9618477e

master
1.7 KiB47 linesraw
1function __fish_lunchy_needs_command
2    set -l cmd (commandline -xpc)
3
4    if test (count $cmd) -eq 1
5        return 0
6    end
7
8    return 1
9end
10
11function __fish_lunchy_using_command
12    set -l cmd (commandline -xpc)
13    set -l cmd_count (count $cmd)
14
15    if test $cmd_count -lt 2
16        return 1
17    end
18
19    for arg in $argv
20        if test $arg = $cmd[2]
21            return 0
22        end
23    end
24
25    return 1
26end
27
28complete -f -c lunchy -s v -l verbose -d 'Show command executions'
29
30# Commands
31complete -f -c lunchy -n __fish_lunchy_needs_command -a install -d 'Installs [file] to ~/Library/LaunchAgents or /Library/LaunchAgents'
32complete -f -c lunchy -n __fish_lunchy_needs_command -a 'ls list' -d 'Show the list of installed agents'
33complete -f -c lunchy -n __fish_lunchy_needs_command -a start -d 'Start the first matching agent'
34complete -f -c lunchy -n __fish_lunchy_needs_command -a stop -d 'Stop the first matching agent'
35complete -f -c lunchy -n __fish_lunchy_needs_command -a restart -d 'Stop and start the first matching agent'
36complete -f -c lunchy -n __fish_lunchy_needs_command -a status -d 'Show the PID and label for all agents'
37complete -f -c lunchy -n __fish_lunchy_needs_command -a edit -d 'Opens the launchctl daemon file in the default editor'
38
39# Commands with service completion
40complete -f -c lunchy -n '__fish_lunchy_using_command ls list start stop restart status edit' -a '(lunchy ls)' -d Service
41
42# Command: start
43complete -f -c lunchy -n '__fish_lunchy_using_command start' -s w -l write -d 'Persist command'
44complete -f -c lunchy -n '__fish_lunchy_using_command start' -s F -l force -d 'Force start (disabled) agents'
45
46# Command: stop
47complete -f -c lunchy -n '__fish_lunchy_using_command stop' -s w -l write -d 'Persist command'