mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-03 02:39:28 +01:00
adding the bash completition script for the client
This commit is contained in:
parent
ee850f38d6
commit
e2d66136d3
1 changed files with 48 additions and 0 deletions
48
contrib/lightning-cli.bash-completion
Normal file
48
contrib/lightning-cli.bash-completion
Normal file
|
@ -0,0 +1,48 @@
|
|||
# bash programmable completion for lncli
|
||||
# copy to /etc/bash_completion.d and restart your shell session
|
||||
# Copyright (c) by Andreas M. Antonopoulos
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
# modified by Tomas Stary (2018) for lightning-cli
|
||||
|
||||
_lightning_cli() {
|
||||
local cur prev words=() cword
|
||||
local lightning_cli
|
||||
|
||||
# lightning_cli might not be in $PATH
|
||||
lightning_cli="$1"
|
||||
|
||||
COMPREPLY=()
|
||||
_get_comp_words_by_ref -n = cur prev words cword
|
||||
|
||||
case "$cur" in
|
||||
-*=*) # prevent nonsense completions
|
||||
return 0
|
||||
;;
|
||||
*)
|
||||
local helpopts globalcmds
|
||||
|
||||
|
||||
# get the global options, starting with --
|
||||
if [[ -z "$cur" || "$cur" =~ ^- ]]; then
|
||||
globalcmds=$($lightning_cli --help 2>&1 | awk '$1 ~ /^-/ { sub(/,/, ""); print $1}')
|
||||
fi
|
||||
|
||||
|
||||
# get the regular commands
|
||||
if [[ -z "$cur" || "$cur" =~ ^[a-z] ]]; then
|
||||
helpopts=$($lightning_cli help 2>/dev/null | awk '{print $4}' | sed 's@[,"]@@g')
|
||||
fi
|
||||
|
||||
COMPREPLY=( $( compgen -W "$helpopts $globalcmds" -X "*," -- "$cur" ) )
|
||||
esac
|
||||
} &&
|
||||
complete -F _lightning_cli lightning-cli
|
||||
|
||||
# Local variables:
|
||||
# mode: shell-script
|
||||
# sh-basic-offset: 4
|
||||
# sh-indent-comment: t
|
||||
# indent-tabs-mode: nil
|
||||
# End:
|
||||
# ex: ts=4 sw=4 et filetype=sh
|
Loading…
Add table
Reference in a new issue