-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(completions): add Bash and fish
- Loading branch information
Showing
3 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#! /usr/bin/env fish | ||
|
||
cd "$(path dirname "$(status filename)")" | ||
|
||
set --local src memsparkline.fish | ||
set --local dst $__fish_config_dir/completions/ | ||
|
||
printf 'copying "%s" to "%s"\n' $src $dst | ||
|
||
cp $src $dst |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
_memsparkline() { | ||
local cur prev opts | ||
|
||
COMPREPLY=() | ||
cur=${COMP_WORDS[COMP_CWORD]} | ||
prev=${COMP_WORDS[COMP_CWORD - 1]} | ||
opts='-h --help -v --version -d --dump -l --length -m --mem-format -n --newlines -o --output -q --quiet -r --record -s --sample -t --time-format -w --wait' | ||
|
||
case "${prev}" in | ||
-d | --dump | -o | --output) | ||
COMPREPLY=($(compgen -f -- "${cur}")) | ||
return 0 | ||
;; | ||
-l | --length) | ||
COMPREPLY=($(compgen -W "20 40 60 80" -- "${cur}")) | ||
return 0 | ||
;; | ||
-r | --record | -s | --sample | -w | --wait) | ||
COMPREPLY=($(compgen -W "100 200 500 1000" -- "${cur}")) | ||
return 0 | ||
;; | ||
-m | --mem-format) | ||
COMPREPLY=($(compgen -W "%.0f %.1f %.2f" -- "${cur}")) | ||
return 0 | ||
;; | ||
-t | --time-format) | ||
COMPREPLY=($(compgen -W "%d:%02d:%04.1f" -- "${cur}")) | ||
return 0 | ||
;; | ||
esac | ||
|
||
if [[ ${cur} == -* ]]; then | ||
COMPREPLY=($(compgen -W "${opts}" -- "${cur}")) | ||
return 0 | ||
fi | ||
|
||
# Complete with commands if no other completion applies. | ||
COMPREPLY=($(compgen -c -- "${cur}")) | ||
} | ||
|
||
complete -F _memsparkline memsparkline |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
complete -c memsparkline -s h -l help -d 'Print help message and exit' | ||
complete -c memsparkline -s v -l version -d 'Print version number and exit' | ||
complete -c memsparkline -s d -l dump -d 'File to append memory usage history to' -r | ||
complete -c memsparkline -s l -l length -d 'Sparkline length' -r -a "20 40 60 80" | ||
complete -c memsparkline -s m -l mem-format -d 'Format string for memory amounts' -r -a "%.0f %.1f %.2f" | ||
complete -c memsparkline -s n -l newlines -d 'Print new sparkline on new line' | ||
complete -c memsparkline -s o -l output -d 'Output file to append to' -r | ||
complete -c memsparkline -s q -l quiet -d 'Do not print sparklines' | ||
complete -c memsparkline -s r -l record -d 'How frequently to record memory usage in ms' -r -a "100 200 500 1000" | ||
complete -c memsparkline -s s -l sample -d 'How frequently to sample memory usage in ms' -r -a "100 200 500 1000" | ||
complete -c memsparkline -s t -l time-format -d 'Format string for run time' -r -a "%d:%02d:%04.1f" | ||
complete -c memsparkline -s w -l wait -d 'Set sample and record time simultaneously' -r -a "100 200 500 1000" | ||
|
||
# Complete with available commands. | ||
complete -c memsparkline -n __fish_is_first_token -a "(__fish_complete_command)" |