-
Notifications
You must be signed in to change notification settings - Fork 30
Add fish shell completion script #58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 5 commits
c6fae49
d03e244
165a34b
d247e26
b948f9d
7066e9a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| #!/usr/bin/env fish | ||
|
|
||
| set -l times week month year previous-week previous-month previous-year | ||
| set -l commands show add edit copy log search add-category list-category set-category order-category rename-category usage | ||
| set -l paged_commands log usage | ||
| set -l note_commands add | ||
| set -l dated_commands show add edit | ||
|
playonverbs marked this conversation as resolved.
Outdated
|
||
| set -l ranged_commands copy log search | ||
| set -l cat_commands show add edit copy log search set-category rename-category | ||
| set -l name_cat_commands add-category rename-category | ||
| set -l desc_cat_commands add-category set-category | ||
|
|
||
| # read category file path from config. default to ~/stup | ||
| cat "$HOME/.config/stup.conf" 2> /dev/null | read -d = -l _ category_dir ; or set -l category_dir "$HOME/stup" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Then comes the issue when Does fish not have that simple fallback system? |
||
|
|
||
| # disable file completions | ||
| complete -c stup -f | ||
|
|
||
| # subcommands listed in $commands | ||
| complete -c stup -n "not __fish_seen_subcommand_from $commands" -x -a "$commands" | ||
|
|
||
| # default `add` behaviour with no subcommands | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The default command can be changed in the config file, but respecting it could awfully increase complexity… (so I don’t require it) |
||
| complete -c stup -n "not __fish_seen_subcommand_from $commands" -s "@" -l at -d "Note timestamp" | ||
| complete -c stup -n "not __fish_seen_subcommand_from $commands" -s c -l category -a "(cat $category_dir/categories.conf)" | ||
| complete -c stup -n "not __fish_seen_subcommand_from $commands" -s n -l note -d "Note content" | ||
|
|
||
| # version and help | ||
| complete -c stup -s v -l version -d "Print current version" | ||
| complete -c stup -s h -l help | ||
|
|
||
| # @/at options | ||
| complete -c stup -n "__fish_seen_subcommand_from $dated_commands" -s "@" -l at -d "Note timestamp" | ||
|
|
||
| # from/to options | ||
| complete -c stup -n "__fish_seen_subcommand_from $ranged_commands" -s f -l from | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are no |
||
| complete -c stup -n "__fish_seen_subcommand_from $ranged_commands" -s t -l to | ||
|
|
||
| complete -c stup -n "__fish_contains_opt -s @ at ; and __fish_seen_subcommand_from $dated_commands" -x -a "$times" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should complete dates, not ranges |
||
| complete -c stup -n "__fish_contains_opt -s f from ; or __fish_contains_opt -s t to ; and __fish_seen_subcommand_from $ranged_commands" -x -a "$times" | ||
|
|
||
| # note options | ||
| complete -c stup -n "__fish_seen_subcommand_from $note_commands" -s n -l note -d "Note content" | ||
|
|
||
| # add (no-)pager option for paged commands | ||
| complete -c stup -n "__fish_seen_subcommand_from $paged_commands" -l no-pager -d "Disable pager" | ||
| complete -c stup -n "__fish_seen_subcommand_from $paged_commands" -l pager -d "Use pager" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
| # complete from category file | ||
| complete -c stup -n "__fish_seen_subcommand_from $cat_commands" -s c -l category -a "(cat $category_dir/categories.conf)" | ||
|
|
||
| complete -c stup -n "__fish_seen_subcommand_from $name_cat_commands" -l category-name | ||
| complete -c stup -n "__fish_seen_subcommand_from $desc_cat_commands" -l category-description | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
list-categor*ies*,set-category*-description*,order-categor*ies*&
version?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have had an issue with the
stup versioncommand returningError: Unknown command "version"(using bothfishandbash). This is why I originally didn't include the subcommand.However it's functionality that should work and the error can be raised in a separate issue, so I'll add the subcommand.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, you’re right. I didn’t check if it works.