summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2025-04-20 12:38:04 +0300
committerPaul Buetow <paul@buetow.org>2025-04-20 12:38:04 +0300
commit43ebf1f7050b620c4a2706da7473fd45570c1b69 (patch)
tree844227d494b826f630e8e1f7d312fddee803fd66
parent11708c519139f48d628041897291abb0d4bebaab (diff)
more on fish
-rw-r--r--dotfiles/fish/conf.d/dotfiles.fish47
-rw-r--r--dotfiles/fish/conf.d/notes.fish32
2 files changed, 79 insertions, 0 deletions
diff --git a/dotfiles/fish/conf.d/dotfiles.fish b/dotfiles/fish/conf.d/dotfiles.fish
new file mode 100644
index 0000000..2f11beb
--- /dev/null
+++ b/dotfiles/fish/conf.d/dotfiles.fish
@@ -0,0 +1,47 @@
+set -gx DOTFILES_DIR ~/git/rexfiles/dotfiles
+
+function dotfiles::update
+ set -l prev_pwd (pwd)
+ cd $DOTFILES_DIR
+ rex home
+ cd "$prev_pwd"
+end
+
+function dotfiles::update::git
+ set -l prev_pwd (pwd)
+ cd $DOTFILES_DIR
+ git pull
+ git commit -a
+ git push
+ rex home
+ cd "$prev_pwd"
+end
+
+function dotfiles::fuzzy::edit
+ set -l prev_pwd (pwd)
+ cd $DOTFILES_DIR
+ set -l dotfile (find . -type f -not -path '*/.git/*' | fzf)
+ $EDITOR "$dotfile"
+ if echo "$dotfile" | grep -F -q .fish
+ echo "Sourcing $dotfile"
+ source "$dotfile"
+ end
+ cd "$prev_pwd"
+end
+
+function dotfiles::rexify
+ cd $DOTFILES_DIR
+ rex home
+ cd -
+end
+
+function dotfiles::random::edit
+ $EDITOR (find . -type f | sort -R | head -n 1)
+ cd -
+end
+
+abbr -a .u 'dotfiles::update'
+abbr -a .ug 'dotfiles::update::git'
+abbr -a .e 'dotfiles::fuzzy::edit'
+abbr -a .rex 'dotfiles::rexify'
+abbr -a .re 'dotfiles::random::edit'
diff --git a/dotfiles/fish/conf.d/notes.fish b/dotfiles/fish/conf.d/notes.fish
new file mode 100644
index 0000000..8a69619
--- /dev/null
+++ b/dotfiles/fish/conf.d/notes.fish
@@ -0,0 +1,32 @@
+set NOTES_DIR ~/Notes
+
+function notes::edit
+ cd ~/Notes
+ $VISUAL (find . -type f | fzf)
+ cd - >/dev/null
+end
+
+function notes::quick
+ set -l name $argv[1]
+ set -l file "$NOTES_DIR/$name.md"
+ if not test -f "$file"
+ echo "# $name" >>"$file"
+ end
+ $EDITOR "$file"
+end
+
+function notes::quick::find
+ set -l name $argv[1]
+ set -l note (find $NOTES_DIR/ -iregex ".*$name.*\.\(md\|txt\)" | head -n 1)
+ if not test -f "$note"
+ echo "Could not find any note in $NOTES_DIR"
+ return
+ end
+ $EDITOR "$note"
+end
+
+abbr -a ,ne 'notes::edit'
+abbr -a cdnodes "cd $NOTES_DIR"
+abbr -a ,nq 'notes::quick'
+abbr -a ,nf 'notes::quick::find'
+abbr -a ,nr "ranger $NOTES_DIR"