diff options
author | Sami Kerola | 2013-03-23 18:41:32 +0100 |
---|---|---|
committer | Sami Kerola | 2013-04-01 18:41:50 +0200 |
commit | 76dceb10a19be9bbfd667cfd02baba59626803d8 (patch) | |
tree | 131dceda3aed8ac3015f67b13d529fe6cbfaeb22 /shell-completion/lslocks | |
parent | bash-completion: login-utils (diff) | |
download | kernel-qcow2-util-linux-76dceb10a19be9bbfd667cfd02baba59626803d8.tar.gz kernel-qcow2-util-linux-76dceb10a19be9bbfd667cfd02baba59626803d8.tar.xz kernel-qcow2-util-linux-76dceb10a19be9bbfd667cfd02baba59626803d8.zip |
bash-completion: misc-utils
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Diffstat (limited to 'shell-completion/lslocks')
-rw-r--r-- | shell-completion/lslocks | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/shell-completion/lslocks b/shell-completion/lslocks new file mode 100644 index 000000000..f55c17ecb --- /dev/null +++ b/shell-completion/lslocks @@ -0,0 +1,43 @@ +_lslocks_module() +{ + local cur prev OPTS + COMPREPLY=() + cur="${COMP_WORDS[COMP_CWORD]}" + prev="${COMP_WORDS[COMP_CWORD-1]}" + case $prev in + '-p'|'--pid') + local PIDS + # /proc/locks can have 8 to 9 fields, see commit + # 55c0d16bab8cc84b72bf11cb2fdd8aa6205ac608 + PIDS="$(awk '{print $(NF-3)}' /proc/locks)" + COMPREPLY=( $(compgen -W "$PIDS" -- $cur) ) + return 0 + ;; + '-o'|'--output') + # FIXME: how to append to a string with compgen? + local OUTPUT + OUTPUT="COMMAND PID TYPE SIZE MODE M START END PATH BLOCKER" + compopt -o nospace + COMPREPLY=( $(compgen -W "$OUTPUT" -S ',' -- $cur) ) + return 0 + ;; + + esac + case $cur in + -*) + OPTS="-p --pid + -o --output + -n --noheadings + -r --raw + -u --notruncate + -h --help + -V --version" + COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) + return 0 + ;; + esac + compopt -o filenames + COMPREPLY=( $(compgen -f -- $cur) ) + return 0 +} +complete -F _lslocks_module lslocks |