Skip to content

Commit ad7df57

Browse files
committed
cmd/loop: enable auto-completion
Save the output of "loop completion bash" to ~/.bash_completion.d/loop and restart bash or do ". ~/.bash_completion.d/loop".
1 parent 1a40b46 commit ad7df57

File tree

2 files changed

+30
-4
lines changed

2 files changed

+30
-4
lines changed

README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,32 @@ To execute a Loop In:
6464
loop in <amt_in_satoshis>
6565
```
6666

67+
### Bash completion
68+
69+
To enable command line auto-completion for `loop` command, do this:
70+
71+
```
72+
$ mkdir -p ~/.local/share/bash-completion/completions/
73+
$ loop completion bash > ~/.local/share/bash-completion/completions/loop
74+
$ . ~/.local/share/bash-completion/completions/loop
75+
$ echo '. ~/.local/share/bash-completion/completions/loop' >> ~/.bashrc
76+
```
77+
78+
It will complete commands and flags if you type `loop ` and press TAB:
79+
```
80+
$ loop static <TAB>
81+
help listswaps new
82+
in listunspent summary
83+
listdeposits listwithdrawals withdraw
84+
85+
$ loop static in --<TAB>
86+
--all --label --payment_timeout --utxo
87+
--amount --last_hop --route_hints
88+
```
89+
90+
It also supports zsh, fish, and powershell. Just replace "bash" with your shell
91+
name in the command above and ajust the completion file location.
92+
6793
### More info
6894
For more information about using Loop checkout our [Loop FAQs](./docs/faqs.md).
6995

cmd/loop/main.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ var (
9494
)
9595

9696
const (
97-
9897
// satAmtFmt formats a satoshi value into a one line string, intended to
9998
// prettify the terminal output. For Instance,
10099
// fmt.Printf(f, "Estimated on-chain fee:", fee)
@@ -163,9 +162,10 @@ func fatal(err error) {
163162

164163
func main() {
165164
rootCmd := &cli.Command{
166-
Name: "loop",
167-
Usage: "control plane for your loopd",
168-
Version: loop.RichVersion(),
165+
Name: "loop",
166+
Usage: "control plane for your loopd",
167+
Version: loop.RichVersion(),
168+
EnableShellCompletion: true,
169169
Flags: []cli.Flag{
170170
&cli.StringFlag{
171171
Name: "rpcserver",

0 commit comments

Comments
 (0)