From 61eb72e69a51da9b6d7bcd34fee5e12e75d19282 Mon Sep 17 00:00:00 2001 From: quak Date: Thu, 23 Jan 2025 22:23:12 +0100 Subject: [PATCH] added shell completions for push subcommands and pop --- navigate_bash_setup | 26 +++++++++++++++++++++++--- todo.md | 5 +++-- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/navigate_bash_setup b/navigate_bash_setup index ea2fbc9..38c8766 100644 --- a/navigate_bash_setup +++ b/navigate_bash_setup @@ -21,12 +21,32 @@ function book { __call_navigate "bookmark $@" } -# completion for `book` +# completion function for `book` function _book { CURRENT_WORD=${COMP_WORDS[COMP_CWORD]} - BOOKMARKS="$(__call_navigate bookmark names)" - COMPREPLY=($(compgen -W "${BOOKMARKS}" -- $CURRENT_WORD)) + if [[ COMP_CWORD -eq 1 ]]; then + BOOKMARKS="add remove $(__call_navigate bookmark names)" + COMPREPLY=($(compgen -W "${BOOKMARKS}" -- $CURRENT_WORD)) + elif [[ COMP_CWORD -eq 2 ]]; then + if [[ COMP_WORDS[1] -eq "remove" ]]; then + BOOKMARKS="$(__call_navigate bookmark names)" + COMPREPLY=($(compgen -W "${BOOKMARKS}" -- $CURRENT_WORD)) + fi + elif [[ COMP_CWORD -eq 3 ]]; then + if [[ COMP_WORDS[1] -eq "add" ]]; then + COMPREPLY=($(compgen -o dirnames -- $CURRENT_WORD)) + fi + fi +} + +# completion function for `pop` +function _pop { + CURRENT_WORD=${COMP_WORDS[COMP_CWORD]} + if [[ COMP_CWORD -eq 1 ]]; then + COMPREPLY=($(compgen -W "all ")) + fi } complete -o dirnames push +complete -F _pop pop complete -F _book book diff --git a/todo.md b/todo.md index 9c799f4..7df9eee 100644 --- a/todo.md +++ b/todo.md @@ -7,7 +7,7 @@ - [x] implement procedural macro for config - [x] .. to parse config - [ ] .. to write default config - - [ ] .. ignore comments in config file + - [x] .. ignore comments in config file - [x] parse config file - [ ] apply config -- partially more done than before :) - [x] `show-bookmarks-on-book` @@ -16,4 +16,5 @@ - [x] bookmarks - [x] do not resolve links in bookmarks - [ ] push to push path in stack -- [ ] write documentation +- [/] write documentation +- [x] change config file extension to `.toml`