Skip to content

Commit

Permalink
Add fish shell completions: options & all themes autocompletion (#49)
Browse files Browse the repository at this point in the history
* Add completions/fish/base16-universal-manager.fish

Allows for autocompletion of commands and available themes

* README:Add 'Shell completions' section under 'Installation'
  • Loading branch information
paul-ri authored Feb 26, 2021
1 parent 641180e commit 62eca0c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ go build

If you get errors on missing dependencies, install them as usual with `go get`.

### Shell completions
* [fish shell](https://github.com/fish-shell/fish-shell) completions: Add the [`completions/fish/base16-universal-manager.fish`](completions/fish/base16-universal-manager.fish) to `~/.config/fish/completions/`

wget https://raw.githubusercontent.com/pinpox/base16-universal-manager/master/completions/fish/base16-universal-manager.fish -O ~/.config/fish/completions/base16-universal-manager.fish

## Usage

To run, just execute the application without any command line flags. It will
Expand Down
17 changes: 17 additions & 0 deletions completions/fish/base16-universal-manager.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Fish completions for base16-universal-manager

# Never complete with filenames
complete -f -c base16-universal-manager -d "A command line tool to install base16 templates and set themes globally"

# Complete available themes
set -l themes_list (sed -n 's/^\(.*\).yaml:.*/\1/p' ~/.cache/base16-universal-manager/schemeslist.yaml)
complete -f -c base16-universal-manager -n "__fish_seen_subcommand_from --scheme; and test (count (commandline -opc)) -eq 2" -a "$themes_list"

# Description for each command
set -l base16_universal_manager_commands (base16-universal-manager --help-long | sed -En 's/^ (--(\w-?)+).*/\1/p')
set -l base16_universal_manager_commands_help (base16-universal-manager --help-long | sed 1,3d | sed -En 's/.{21}([A-Z].*)/\1/p')
set -l i 1
for command in $base16_universal_manager_commands
complete -f -c base16-universal-manager -n "not __fish_seen_subcommand_from $base16_universal_manager_commands" -a "$command" -d "$base16_universal_manager_commands_help[$i]"
set -l i (math $i + 1)
end

0 comments on commit 62eca0c

Please sign in to comment.