Skip to content

Commit 4e837fe

Browse files
authored
auto-completion file for the FISH shell
1 parent 428946e commit 4e837fe

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

notes.fish

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Notes completion file for fish shell <https://github.com/pimterry/notes>
2+
# Place in ~/.config/fish/completions/
3+
4+
# Set some useful local variables
5+
## lists of commands used by notes
6+
set -l notes_list_commands o open mv rm cat
7+
set -l notes_friendly_commands new open find ls rm cat mv grep
8+
set -l notes_commands n new ls find f grep g search s open o mv rm cat
9+
set -l notes_dir_commands n new grep ls
10+
11+
# NOTES_DIRECTORY
12+
## use NOTES_DIRECTORY variable if set else...
13+
if not set -q NOTES_DIRECTORY
14+
echo "notes dir not set"
15+
## if config file exists, read it
16+
if test -e $HOME/.config/notes/config
17+
set NOTES_DIRECTORY (string split = (grep "NOTES_DIRECTORY" $HOME/.config/notes/config))[2]
18+
end
19+
end
20+
## in case of failure, use default notes dir
21+
if not set -q NOTES_DIRECTORY[1]
22+
set NOTES_DIRECTORY "$HOME/notes"
23+
end
24+
25+
# FILE COMPLETIONS
26+
complete -c notes -f
27+
complete -c notes -n "not __fish_seen_subcommand_from $notes_commands" -a "$notes_friendly_commands"
28+
complete -c notes -n "__fish_seen_subcommand_from $notes_list_commands" -a "(notes find|grep -v '~\$'|sed 's/[.]md\$//')"
29+
complete -c notes -n "__fish_seen_subcommand_from $notes_dir_commands" -a "(find $NOTES_DIRECTORY -type d -printf '%P/\n')"

0 commit comments

Comments
 (0)