diff options
Diffstat (limited to 'content/posts/bash-incremental-directory-completion/index.org')
-rw-r--r-- | content/posts/bash-incremental-directory-completion/index.org | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/content/posts/bash-incremental-directory-completion/index.org b/content/posts/bash-incremental-directory-completion/index.org index 1bce8b3..95369fe 100644 --- a/content/posts/bash-incremental-directory-completion/index.org +++ b/content/posts/bash-incremental-directory-completion/index.org @@ -114,11 +114,15 @@ function _repo_completions { complete -F _repo_completions repo #+end_src +In the above code, =repo cd= changes directory to =~/src= and the =-S +/= option for =compgen= will append a trailing (suffix) slash to the +end of the suggestion. + The key here is that you can use =compopt= to dynamically change completion options while running the completion, which lets me check how many directories deep we are into the completion by counting slashes, and disable appending a space until we're a full three directories deep into the completion. - -existing resouces https://iridakos.com/programming/2018/03/01/bash-programmable-completion-tutorial +Here is a good resource on bash completion for further reading. +https://iridakos.com/programming/2018/03/01/bash-programmable-completion-tutorial |