From ec64f2a0f46de093e3d5ef92d620c0487e04ed84 Mon Sep 17 00:00:00 2001 From: Noah Masur Date: Thu, 17 Dec 2020 19:29:55 -0700 Subject: [PATCH] speed up fish start with individual function files --- fish.configlink/config.fish | 7 +- fish.configlink/functions/aliases.fish | 12 +- fish.configlink/functions/awstools.fish | 8 -- fish.configlink/functions/brewinfo.fish | 9 ++ fish.configlink/functions/brews.fish | 10 ++ fish.configlink/functions/brewsearch.fish | 9 ++ fish.configlink/functions/copy.fish | 3 + fish.configlink/functions/fuck.fish | 9 ++ fish.configlink/functions/git-add-fuzzy.fish | 15 +++ .../functions/git-checkout-fuzzy.fish | 4 + fish.configlink/functions/git-commits.fish | 10 ++ .../functions/git-delete-fuzzy.fish | 4 + .../functions/git-force-delete-fuzzy.fish | 4 + .../functions/git-fuzzy-branch.fish | 12 ++ .../functions/git-merge-fuzzy.fish | 4 + fish.configlink/functions/git-show-fuzzy.fish | 4 + fish.configlink/functions/git.fish | 39 +++++++ fish.configlink/functions/gittools.fish | 110 ------------------ fish.configlink/functions/journal.fish | 10 ++ fish.configlink/functions/mactools.fish | 42 ------- fish.configlink/functions/meeting.fish | 10 ++ fish.configlink/functions/note-dates.fish | 7 ++ fish.configlink/functions/note-header.fish | 4 + fish.configlink/functions/note.fish | 10 ++ fish.configlink/functions/notes.fish | 78 ------------- fish.configlink/functions/prj.fish | 4 + fish.configlink/functions/projects.fish | 13 --- fish.configlink/functions/quicknote.fish | 5 + fish.configlink/functions/syncnotes.fish | 9 ++ fish.configlink/functions/today.fish | 11 ++ fish.configlink/functions/unsetaws.fish | 6 + 31 files changed, 225 insertions(+), 257 deletions(-) delete mode 100644 fish.configlink/functions/awstools.fish create mode 100644 fish.configlink/functions/brewinfo.fish create mode 100644 fish.configlink/functions/brews.fish create mode 100644 fish.configlink/functions/brewsearch.fish create mode 100644 fish.configlink/functions/copy.fish create mode 100644 fish.configlink/functions/fuck.fish create mode 100644 fish.configlink/functions/git-add-fuzzy.fish create mode 100644 fish.configlink/functions/git-checkout-fuzzy.fish create mode 100644 fish.configlink/functions/git-commits.fish create mode 100644 fish.configlink/functions/git-delete-fuzzy.fish create mode 100644 fish.configlink/functions/git-force-delete-fuzzy.fish create mode 100644 fish.configlink/functions/git-fuzzy-branch.fish create mode 100644 fish.configlink/functions/git-merge-fuzzy.fish create mode 100644 fish.configlink/functions/git-show-fuzzy.fish create mode 100644 fish.configlink/functions/git.fish delete mode 100644 fish.configlink/functions/gittools.fish create mode 100644 fish.configlink/functions/journal.fish delete mode 100644 fish.configlink/functions/mactools.fish create mode 100644 fish.configlink/functions/meeting.fish create mode 100644 fish.configlink/functions/note-dates.fish create mode 100644 fish.configlink/functions/note-header.fish create mode 100644 fish.configlink/functions/note.fish create mode 100644 fish.configlink/functions/prj.fish delete mode 100644 fish.configlink/functions/projects.fish create mode 100644 fish.configlink/functions/quicknote.fish create mode 100644 fish.configlink/functions/syncnotes.fish create mode 100644 fish.configlink/functions/today.fish create mode 100644 fish.configlink/functions/unsetaws.fish diff --git a/fish.configlink/config.fish b/fish.configlink/config.fish index bc23ff9..2663adf 100644 --- a/fish.configlink/config.fish +++ b/fish.configlink/config.fish @@ -8,6 +8,8 @@ if status --is-interactive set PATH $PATH /usr/local/bin ~/.local/bin $DOTS/bin ~/.cargo/bin set CDPATH . $HOME set EDITOR nvim + set PROJ $HOME/dev/work + set NOTES_PATH $HOME/notes # Use `vi` in the shell with cursor shapes fish_vi_key_bindings @@ -33,11 +35,6 @@ if status --is-interactive # Individual features aliases - notes - awstools - mactools - gittools - projects # Fuzzy finder fzf_key_bindings diff --git a/fish.configlink/functions/aliases.fish b/fish.configlink/functions/aliases.fish index 6192ed4..bf3f205 100644 --- a/fish.configlink/functions/aliases.fish +++ b/fish.configlink/functions/aliases.fish @@ -8,6 +8,8 @@ function aliases --description 'All aliases' abbr -a lh 'ls -lh' # Pretty vertical list abbr -a ll 'ls -alhF' # Include hidden files abbr -a c 'cd' + abbr -a .. 'cd ..' + alias proj='cd $PROJ' # Tmux abbr -a ta 'tmux attach-session' @@ -36,6 +38,7 @@ function aliases --description 'All aliases' abbr -a gbD 'git branch -D' abbr -a gr 'git reset' abbr -a grh 'git reset --hard' + abbr -a grm 'git reset --mixed' abbr -a gm 'git merge' abbr -a gmf 'git-merge-fuzzy' abbr -a gcp 'git cherry-pick' @@ -48,6 +51,10 @@ function aliases --description 'All aliases' abbr -a vimrc 'vim $HOME/.config/nvim/init.vim' # Edit ".vimrc" file end + # Notes + abbr -a qn 'quicknote' + abbr -a sn 'syncnotes' + # Improved CLI Tools alias ping='prettyping --nolegend' abbr -a cat 'bat' # Swap cat with bat @@ -121,7 +128,10 @@ function aliases --description 'All aliases' # Rust abbr -a ca 'cargo' - # Non-MacOS + # macOS + abbr -a casks 'vim $DOTS/homebrew/Caskfile' + + # Non-macOS if [ (uname) = "Linux" ] alias pbcopy='xclip -selection clipboard -in' alias pbpaste='xclip -selection clipboard -out' diff --git a/fish.configlink/functions/awstools.fish b/fish.configlink/functions/awstools.fish deleted file mode 100644 index 1c4810a..0000000 --- a/fish.configlink/functions/awstools.fish +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/local/fish - -function awstools --description "AWS bindings" - function unsetaws --description "Clear AWS credentials environment variables" - set -e AWS_ACCESS_KEY_ID - set -e AWS_SECRET_ACCESS_KEY - end -end diff --git a/fish.configlink/functions/brewinfo.fish b/fish.configlink/functions/brewinfo.fish new file mode 100644 index 0000000..bf75329 --- /dev/null +++ b/fish.configlink/functions/brewinfo.fish @@ -0,0 +1,9 @@ +function brewinfo --description "Lookup brew plugins" + set -l inst (brew search | eval "fzf $FZF_DEFAULT_OPTS -m --header='[brew:info]'") + + if not test (count $inst) = 0 + for prog in $inst + brew info "$prog" + end + end +end diff --git a/fish.configlink/functions/brews.fish b/fish.configlink/functions/brews.fish new file mode 100644 index 0000000..f1d573a --- /dev/null +++ b/fish.configlink/functions/brews.fish @@ -0,0 +1,10 @@ +function brews --description "Open Homebrew bundles file" + set -lx brewdir $DOTS/homebrew + set -l brewfile (basename $brewdir/*.Brewfile \ + | fzf \ + --height 70% \ + --preview-window right:70% \ + --preview 'bat --color=always $brewdir/{}' \ + ) + and vim $brewdir/$brewfile +end diff --git a/fish.configlink/functions/brewsearch.fish b/fish.configlink/functions/brewsearch.fish new file mode 100644 index 0000000..5ff6519 --- /dev/null +++ b/fish.configlink/functions/brewsearch.fish @@ -0,0 +1,9 @@ +function brewsearch --description "Install brew plugins" + set -l inst (brew search | eval "fzf $FZF_DEFAULT_OPTS -m --header='[brew:install]'") + + if not test (count $inst) = 0 + for prog in $inst + brew install "$prog" + end + end +end diff --git a/fish.configlink/functions/copy.fish b/fish.configlink/functions/copy.fish new file mode 100644 index 0000000..0f8f037 --- /dev/null +++ b/fish.configlink/functions/copy.fish @@ -0,0 +1,3 @@ +function copy --description 'Copy file contents into clipboard' + cat $argv | pbcopy +end diff --git a/fish.configlink/functions/fuck.fish b/fish.configlink/functions/fuck.fish new file mode 100644 index 0000000..90d4f19 --- /dev/null +++ b/fish.configlink/functions/fuck.fish @@ -0,0 +1,9 @@ +function fuck -d "Correct your previous console command" + set -l fucked_up_command $history[1] + env TF_SHELL=fish TF_ALIAS=fuck PYTHONIOENCODING=utf-8 thefuck $fucked_up_command THEFUCK_ARGUMENT_PLACEHOLDER $argv | read -l unfucked_command + if [ "$unfucked_command" != "" ] + eval $unfucked_command + builtin history delete --exact --case-sensitive -- $fucked_up_command + builtin history merge ^ /dev/null + end +end diff --git a/fish.configlink/functions/git-add-fuzzy.fish b/fish.configlink/functions/git-add-fuzzy.fish new file mode 100644 index 0000000..a2eafe7 --- /dev/null +++ b/fish.configlink/functions/git-add-fuzzy.fish @@ -0,0 +1,15 @@ +function git-add-fuzzy + set gitfile (git status -s \ + | fzf \ + --height 50% \ + -m \ + --preview-window right:70% \ + --preview 'set -l IFS; set gd (git diff --color=always (echo {} | awk \'{$1=$1};1\' | cut -d" " -f2)); if test "$gd"; echo "$gd"; else; bat --color=always (echo {} | awk \'{$1=$1};1\' | cut -d" " -f2); end') + and for gf in $gitfile + set gf (echo $gf \ + | awk '{$1=$1};1' \ + | cut -d' ' -f2 \ + ) + and git add $gf + end +end diff --git a/fish.configlink/functions/git-checkout-fuzzy.fish b/fish.configlink/functions/git-checkout-fuzzy.fish new file mode 100644 index 0000000..1b47663 --- /dev/null +++ b/fish.configlink/functions/git-checkout-fuzzy.fish @@ -0,0 +1,4 @@ +function git-checkout-fuzzy + set branch (git-fuzzy-branch "checkout branch...") + and git checkout $branch +end diff --git a/fish.configlink/functions/git-commits.fish b/fish.configlink/functions/git-commits.fish new file mode 100644 index 0000000..03c3613 --- /dev/null +++ b/fish.configlink/functions/git-commits.fish @@ -0,0 +1,10 @@ +function git-commits + set commitline (git log \ + --pretty="format:%C(auto)%ar %h%d %s" \ + | fzf \ + --height 50% \ + --preview 'git show --color=always (echo {} | cut -d" " -f4)' \ + ) + and set commit (echo $commitline | cut -d" " -f4) + and echo $commit +end diff --git a/fish.configlink/functions/git-delete-fuzzy.fish b/fish.configlink/functions/git-delete-fuzzy.fish new file mode 100644 index 0000000..82cd5e7 --- /dev/null +++ b/fish.configlink/functions/git-delete-fuzzy.fish @@ -0,0 +1,4 @@ +function git-delete-fuzzy + set branch (git-fuzzy-branch "delete branch...") + and git branch -d $branch +end diff --git a/fish.configlink/functions/git-force-delete-fuzzy.fish b/fish.configlink/functions/git-force-delete-fuzzy.fish new file mode 100644 index 0000000..119b5f0 --- /dev/null +++ b/fish.configlink/functions/git-force-delete-fuzzy.fish @@ -0,0 +1,4 @@ +function git-force-delete-fuzzy + set branch (git-fuzzy-branch "force delete branch...") + and git branch -D $branch +end diff --git a/fish.configlink/functions/git-fuzzy-branch.fish b/fish.configlink/functions/git-fuzzy-branch.fish new file mode 100644 index 0000000..f60acaf --- /dev/null +++ b/fish.configlink/functions/git-fuzzy-branch.fish @@ -0,0 +1,12 @@ +function git-fuzzy-branch -a header + set -l current (git rev-parse --abbrev-ref HEAD | tr -d '\n') + set -l branch (git branch \ + --format "%(refname:short)" \ + | fzf \ + --height 50% \ + --header="On $current, $header" \ + --preview-window right:70% \ + --preview 'git log {} --color=always --pretty="format:%C(auto)%ar %h%d %s"' \ + ) + and echo $branch +end diff --git a/fish.configlink/functions/git-merge-fuzzy.fish b/fish.configlink/functions/git-merge-fuzzy.fish new file mode 100644 index 0000000..82fb7e9 --- /dev/null +++ b/fish.configlink/functions/git-merge-fuzzy.fish @@ -0,0 +1,4 @@ +function git-merge-fuzzy + set branch (git-fuzzy-branch "merge from...") + and git merge $branch +end diff --git a/fish.configlink/functions/git-show-fuzzy.fish b/fish.configlink/functions/git-show-fuzzy.fish new file mode 100644 index 0000000..619d6cf --- /dev/null +++ b/fish.configlink/functions/git-show-fuzzy.fish @@ -0,0 +1,4 @@ +function git-show-fuzzy + set commit (git log --pretty=oneline | fzf | cut -d' ' -f1) + and git show $commit +end diff --git a/fish.configlink/functions/git.fish b/fish.configlink/functions/git.fish new file mode 100644 index 0000000..19e1b73 --- /dev/null +++ b/fish.configlink/functions/git.fish @@ -0,0 +1,39 @@ +function git + if contains f $argv + switch $argv[1] + case "checkout" + git-checkout-fuzzy + case "add" + git-add-fuzzy + case "show" + git-show-fuzzy + case "merge" + git-merge-fuzzy + case "branch" + if test "$argv[2]" = "-d" + git-delete-fuzzy + else if test "$argv[2]" = "-D" + git-force-delete-fuzzy + else + echo "Not a fuzzy option." + return 1 + end + case "reset" + set commit (git-commits) + and if test "$argv[2]" = "--hard" + git reset --hard $commit + else + git reset $commit + end + case "*" + echo "No fuzzy option." + return 1 + end + else + if count $argv > /dev/null + command git $argv + else + command git status -sb + end + end +end diff --git a/fish.configlink/functions/gittools.fish b/fish.configlink/functions/gittools.fish deleted file mode 100644 index 134814d..0000000 --- a/fish.configlink/functions/gittools.fish +++ /dev/null @@ -1,110 +0,0 @@ -#!/usr/local/bin/fish - -function gittools - - function git-fuzzy-branch -a header - set -l current (git rev-parse --abbrev-ref HEAD | tr -d '\n') - set -l branch (git branch \ - --format "%(refname:short)" \ - | fzf \ - --height 50% \ - --header="On $current, $header" \ - --preview-window right:70% \ - --preview 'git log {} --color=always --pretty="format:%C(auto)%ar %h%d %s"' \ - ) - and echo $branch - end - - function git-commits - set commitline (git log \ - --pretty="format:%C(auto)%ar %h%d %s" \ - | fzf \ - --height 50% \ - --preview 'git show --color=always (echo {} | cut -d" " -f4)' \ - ) - and set commit (echo $commitline | cut -d" " -f4) - and echo $commit - end - - function git-checkout-fuzzy - set branch (git-fuzzy-branch "checkout branch...") - and git checkout $branch - end - - function git-show-fuzzy - set commit (git log --pretty=oneline | fzf | cut -d' ' -f1) - and git show $commit - end - - function git-add-fuzzy - set gitfile (git status -s \ - | fzf \ - --height 50% \ - -m \ - --preview-window right:70% \ - --preview 'set -l IFS; set gd (git diff --color=always (echo {} | awk \'{$1=$1};1\' | cut -d" " -f2)); if test "$gd"; echo "$gd"; else; bat --color=always (echo {} | awk \'{$1=$1};1\' | cut -d" " -f2); end') - and for gf in $gitfile - set gf (echo $gf \ - | awk '{$1=$1};1' \ - | cut -d' ' -f2 \ - ) - and git add $gf - end - end - - function git-merge-fuzzy - set branch (git-fuzzy-branch "merge from...") - and git merge $branch - end - - function git-delete-fuzzy - set branch (git-fuzzy-branch "delete branch...") - and git branch -d $branch - end - - function git-force-delete-fuzzy - set branch (git-fuzzy-branch "force delete branch...") - and git branch -D $branch - end - - function git - if contains f $argv - switch $argv[1] - case "checkout" - git-checkout-fuzzy - case "add" - git-add-fuzzy - case "show" - git-show-fuzzy - case "merge" - git-merge-fuzzy - case "branch" - if test "$argv[2]" = "-d" - git-delete-fuzzy - else if test "$argv[2]" = "-D" - git-force-delete-fuzzy - else - echo "Not a fuzzy option." - return 1 - end - case "reset" - set commit (git-commits) - and if test "$argv[2]" = "--hard" - git reset --hard $commit - else - git reset $commit - end - case "*" - echo "No fuzzy option." - return 1 - end - else - if count $argv > /dev/null - command git $argv - else - command git status -sb - end - end - end - -end diff --git a/fish.configlink/functions/journal.fish b/fish.configlink/functions/journal.fish new file mode 100644 index 0000000..c5a94c6 --- /dev/null +++ b/fish.configlink/functions/journal.fish @@ -0,0 +1,10 @@ +function journal --description "Create today's journal" + note-dates + if [ -f $TODAY_NOTE_FILE ] + echo "Already exists." + else + note-header + printf $JOURNAL_HEADER > $TODAY_NOTE_FILE + echo "New journal added." + end +end diff --git a/fish.configlink/functions/mactools.fish b/fish.configlink/functions/mactools.fish deleted file mode 100644 index 1cb8b3c..0000000 --- a/fish.configlink/functions/mactools.fish +++ /dev/null @@ -1,42 +0,0 @@ -#!/usr/local/bin/fish - -function mactools - - function copy --description 'Copy file contents into clipboard' - cat $argv | pbcopy - end - - abbr -a casks 'vim $DOTS/homebrew/Caskfile' - - function brews --description "Open Homebrew bundles file" - set -lx brewdir $DOTS/homebrew - set -l brewfile (basename $brewdir/*.Brewfile \ - | fzf \ - --height 70% \ - --preview-window right:70% \ - --preview 'bat --color=always $brewdir/{}' \ - ) - and vim $brewdir/$brewfile - end - - function brewinfo --description "Lookup brew plugins" - set -l inst (brew search | eval "fzf $FZF_DEFAULT_OPTS -m --header='[brew:info]'") - - if not test (count $inst) = 0 - for prog in $inst - brew info "$prog" - end - end - end - - function brewsearch --description "Install brew plugins" - set -l inst (brew search | eval "fzf $FZF_DEFAULT_OPTS -m --header='[brew:install]'") - - if not test (count $inst) = 0 - for prog in $inst - brew install "$prog" - end - end - end - -end diff --git a/fish.configlink/functions/meeting.fish b/fish.configlink/functions/meeting.fish new file mode 100644 index 0000000..e9b1ff9 --- /dev/null +++ b/fish.configlink/functions/meeting.fish @@ -0,0 +1,10 @@ +function meeting --description "Describe a meeting" -a "name" + note-dates + set today_date (date -j +"%Y-%m-%d") + set time (date +"%I:%M%p" | tr '[:upper:]' '[:lower:]') + set meeting_name (echo $name | tr ' ' '-' | tr '[:upper:]' '[:lower:]') + set meeting_note $today_date-$meeting_name + printf "[$TODAY_NOTE](journal/$TODAY_NOTE.md) | #meeting\n\n# $name\n\n---\n\n" > $NOTES_PATH/$meeting_note.md + printf "\n\n---\n\n$time - [$name](../$meeting_note.md)\n\n---\n\n" >> $TODAY_NOTE_FILE + open "obsidian://open?vault=notes&file=$meeting_note" +end diff --git a/fish.configlink/functions/note-dates.fish b/fish.configlink/functions/note-dates.fish new file mode 100644 index 0000000..f4e4c6b --- /dev/null +++ b/fish.configlink/functions/note-dates.fish @@ -0,0 +1,7 @@ +function note-dates + set -g TODAY_NOTE (date +"%Y-%m-%d_%a") + set -g YESTERDAY_NOTE (date -jv "-1d" +"%Y-%m-%d_%a") + set -g TOMORROW_NOTE (date -jv "+1d" +"%Y-%m-%d_%a") + set -g LONG_DATE (date +"%A, %B %e, %Y" | sed 's/ */ /g') + set -g TODAY_NOTE_FILE $NOTES_PATH/journal/$TODAY_NOTE.md +end diff --git a/fish.configlink/functions/note-header.fish b/fish.configlink/functions/note-header.fish new file mode 100644 index 0000000..590f5c8 --- /dev/null +++ b/fish.configlink/functions/note-header.fish @@ -0,0 +1,4 @@ +function note-header + set -g CURRENT_WEATHER (curl -s "https://wttr.in/?format=1") + set -g JOURNAL_HEADER "[Yesterday]($YESTERDAY_NOTE.md) | [Home](home.md) | [Tomorrow]($TOMORROW_NOTE.md)\n\n$LONG_DATE\n$CURRENT_WEATHER\n#journal\n\n---\n\n# Today's Goals\n\n\n# Journal\n\n" +end diff --git a/fish.configlink/functions/note.fish b/fish.configlink/functions/note.fish new file mode 100644 index 0000000..42df0f4 --- /dev/null +++ b/fish.configlink/functions/note.fish @@ -0,0 +1,10 @@ +function note --description "Edit or create a note" -a "filename" + if test -n "$filename" + vim $NOTES_PATH/$filename.md + else + set file (ls $NOTES_PATH | fzf) + if [ $status -eq 0 ] + vim $NOTES_PATH/$file + end + end +end diff --git a/fish.configlink/functions/notes.fish b/fish.configlink/functions/notes.fish index 82a1de5..1836738 100644 --- a/fish.configlink/functions/notes.fish +++ b/fish.configlink/functions/notes.fish @@ -1,83 +1,5 @@ #!/usr/local/bin/fish -function notes --description "Notes functions" - set -gx NOTES_PATH $HOME/notes - function note_dates - set -g TODAY_NOTE (date +"%Y-%m-%d_%a") - set -g YESTERDAY_NOTE (date -jv "-1d" +"%Y-%m-%d_%a") - set -g TOMORROW_NOTE (date -jv "+1d" +"%Y-%m-%d_%a") - set -g LONG_DATE (date +"%A, %B %e, %Y" | sed 's/ */ /g') - set -g TODAY_NOTE_FILE $NOTES_PATH/journal/$TODAY_NOTE.md - end - function note_header - set -g CURRENT_WEATHER (curl -s "https://wttr.in/?format=1") - set -g JOURNAL_HEADER "[Yesterday]($YESTERDAY_NOTE.md) | [Home](home.md) | [Tomorrow]($TOMORROW_NOTE.md)\n\n$LONG_DATE\n$CURRENT_WEATHER\n#journal\n\n---\n\n# Today's Goals\n\n\n# Journal\n\n" - end - - function journal --description "Create today's journal" - note_dates - if [ -f $TODAY_NOTE_FILE ] - echo "Already exists." - else - note_header - printf $JOURNAL_HEADER > $TODAY_NOTE_FILE - echo "New journal added." - end - end - - function today --description "Open today's journal" - note_dates - if [ -f $TODAY_NOTE_FILE ] - vim $TODAY_NOTE_FILE - else - note_header - printf $JOURNAL_HEADER > $TODAY_NOTE_FILE - echo "New journal added." - vim $TODAY_NOTE_FILE - end - end - - function meeting --description "Describe a meeting" -a "name" - note_dates - set today_date (date -j +"%Y-%m-%d") - set time (date +"%I:%M%p" | tr '[:upper:]' '[:lower:]') - set meeting_name (echo $name | tr ' ' '-' | tr '[:upper:]' '[:lower:]') - set meeting_note $today_date-$meeting_name - printf "[$TODAY_NOTE](journal/$TODAY_NOTE.md) | #meeting\n\n# $name\n\n---\n\n" > $NOTES_PATH/$meeting_note.md - printf "\n\n---\n\n$time - [$name](../$meeting_note.md)\n\n---\n\n" >> $TODAY_NOTE_FILE - open "obsidian://open?vault=notes&file=$meeting_note" - end - - function note --description "Edit or create a note" -a "filename" - if test -n "$filename" - vim $NOTES_PATH/$filename.md - else - set file (ls $NOTES_PATH | fzf) - if [ $status -eq 0 ] - vim $NOTES_PATH/$file - end - end - end - - abbr -a qn 'quicknote' - function quicknote --description "Write a quick note" -a "note" - note_dates - set time (date +"%I:%M%p" | tr '[:upper:]' '[:lower:]') - printf "\n\n---\n\n#### $time\n$note\n" >> $TODAY_NOTE_FILE - end - - abbr -a sn 'syncnotes' - function syncnotes --description "Full git commit on notes" - set current_dir $PWD - cd $NOTES_PATH - git pull - git add -A - git commit -m "autosync" - git push - cd $current_dir - end - -end diff --git a/fish.configlink/functions/prj.fish b/fish.configlink/functions/prj.fish new file mode 100644 index 0000000..6efcf72 --- /dev/null +++ b/fish.configlink/functions/prj.fish @@ -0,0 +1,4 @@ +function prj --description "cd to a project" + set projdir (ls $PROJ | fzf) + and cd $PROJ/$projdir +end diff --git a/fish.configlink/functions/projects.fish b/fish.configlink/functions/projects.fish deleted file mode 100644 index 9ab9d5e..0000000 --- a/fish.configlink/functions/projects.fish +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/local/fish - -function projects --description "Projects tools" - - set PROJ $HOME/dev/work - alias proj='cd $PROJ' - - function prj --description "cd to a project" - set projdir (ls $PROJ | fzf) - and cd $PROJ/$projdir - end - -end diff --git a/fish.configlink/functions/quicknote.fish b/fish.configlink/functions/quicknote.fish new file mode 100644 index 0000000..40a955d --- /dev/null +++ b/fish.configlink/functions/quicknote.fish @@ -0,0 +1,5 @@ +function quicknote --description "Write a quick note" -a "note" + note-dates + set time (date +"%I:%M%p" | tr '[:upper:]' '[:lower:]') + printf "\n\n---\n\n#### $time\n$note\n" >> $TODAY_NOTE_FILE +end diff --git a/fish.configlink/functions/syncnotes.fish b/fish.configlink/functions/syncnotes.fish new file mode 100644 index 0000000..98924cb --- /dev/null +++ b/fish.configlink/functions/syncnotes.fish @@ -0,0 +1,9 @@ +function syncnotes --description "Full git commit on notes" + set current_dir $PWD + cd $NOTES_PATH + git pull + git add -A + git commit -m "autosync" + git push + cd $current_dir +end diff --git a/fish.configlink/functions/today.fish b/fish.configlink/functions/today.fish new file mode 100644 index 0000000..5f5c411 --- /dev/null +++ b/fish.configlink/functions/today.fish @@ -0,0 +1,11 @@ +function today --description "Open today's journal" + note-dates + if [ -f $TODAY_NOTE_FILE ] + vim $TODAY_NOTE_FILE + else + note-header + printf $JOURNAL_HEADER > $TODAY_NOTE_FILE + echo "New journal added." + vim $TODAY_NOTE_FILE + end +end diff --git a/fish.configlink/functions/unsetaws.fish b/fish.configlink/functions/unsetaws.fish new file mode 100644 index 0000000..6d6ad47 --- /dev/null +++ b/fish.configlink/functions/unsetaws.fish @@ -0,0 +1,6 @@ +#!/usr/bin/local/fish + +function unsetaws --description "Clear AWS credentials environment variables" + set -e AWS_ACCESS_KEY_ID + set -e AWS_SECRET_ACCESS_KEY +end