mirror of
https://github.com/nmasur/dotfiles
synced 2024-11-10 02:52:55 +00:00
speed up fish start with individual function files
This commit is contained in:
parent
1c79530fb1
commit
bf8b563e5e
@ -8,6 +8,27 @@ if status --is-interactive
|
|||||||
set PATH $PATH /usr/local/bin ~/.local/bin $DOTS/bin ~/.cargo/bin
|
set PATH $PATH /usr/local/bin ~/.local/bin $DOTS/bin ~/.cargo/bin
|
||||||
set CDPATH . $HOME
|
set CDPATH . $HOME
|
||||||
set EDITOR nvim
|
set EDITOR nvim
|
||||||
|
set PROJ $HOME/dev/work
|
||||||
|
set NOTES_PATH $HOME/notes
|
||||||
|
|
||||||
|
# Aliases
|
||||||
|
alias reload='source $DOTS/fish.configlink/config.fish'
|
||||||
|
alias ls 'exa'
|
||||||
|
alias proj 'cd $PROJ'
|
||||||
|
if command -v nvim > /dev/null
|
||||||
|
alias vim='nvim'
|
||||||
|
abbr -a vimrc 'vim $HOME/.config/nvim/init.vim'
|
||||||
|
end
|
||||||
|
alias ping='prettyping --nolegend'
|
||||||
|
alias weather='curl wttr.in/$WEATHER_CITY'
|
||||||
|
alias moon='curl wttr.in/Moon'
|
||||||
|
alias ipinfo='curl ipinfo.io'
|
||||||
|
alias worldmap='telnet mapscii.me'
|
||||||
|
alias connect='docker run --rm -v ~/.aws:/root/.aws -v ~/.ssh:/root/.ssh -it connect-aws'
|
||||||
|
if [ (uname) = "Linux" ]
|
||||||
|
alias pbcopy='xclip -selection clipboard -in'
|
||||||
|
alias pbpaste='xclip -selection clipboard -out'
|
||||||
|
end
|
||||||
|
|
||||||
# Use `vi` in the shell with cursor shapes
|
# Use `vi` in the shell with cursor shapes
|
||||||
fish_vi_key_bindings
|
fish_vi_key_bindings
|
||||||
@ -29,15 +50,7 @@ if status --is-interactive
|
|||||||
zoxide init fish | source
|
zoxide init fish | source
|
||||||
|
|
||||||
# Colors
|
# Colors
|
||||||
theme_gruvbox
|
# theme_gruvbox
|
||||||
|
|
||||||
# Individual features
|
|
||||||
aliases
|
|
||||||
notes
|
|
||||||
awstools
|
|
||||||
mactools
|
|
||||||
gittools
|
|
||||||
projects
|
|
||||||
|
|
||||||
# Fuzzy finder
|
# Fuzzy finder
|
||||||
fzf_key_bindings
|
fzf_key_bindings
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
#!/usr/local/bin/fish
|
#!/usr/local/bin/fish
|
||||||
|
|
||||||
function aliases --description 'All aliases'
|
function abbrs --description 'All abbreviations'
|
||||||
|
|
||||||
# Directory aliases
|
# Directory aliases
|
||||||
alias ls 'exa' # exa = improved ls
|
|
||||||
abbr -a l 'ls' # Quicker shortcut for ls
|
abbr -a l 'ls' # Quicker shortcut for ls
|
||||||
abbr -a lh 'ls -lh' # Pretty vertical list
|
abbr -a lh 'ls -lh' # Pretty vertical list
|
||||||
abbr -a ll 'ls -alhF' # Include hidden files
|
abbr -a ll 'ls -alhF' # Include hidden files
|
||||||
abbr -a c 'cd'
|
abbr -a c 'cd'
|
||||||
|
abbr -a .. 'cd ..'
|
||||||
|
abbr -a -- - 'cd -'
|
||||||
|
|
||||||
# Tmux
|
# Tmux
|
||||||
abbr -a ta 'tmux attach-session'
|
abbr -a ta 'tmux attach-session'
|
||||||
@ -36,6 +37,7 @@ function aliases --description 'All aliases'
|
|||||||
abbr -a gbD 'git branch -D'
|
abbr -a gbD 'git branch -D'
|
||||||
abbr -a gr 'git reset'
|
abbr -a gr 'git reset'
|
||||||
abbr -a grh 'git reset --hard'
|
abbr -a grh 'git reset --hard'
|
||||||
|
abbr -a grm 'git reset --mixed'
|
||||||
abbr -a gm 'git merge'
|
abbr -a gm 'git merge'
|
||||||
abbr -a gmf 'git-merge-fuzzy'
|
abbr -a gmf 'git-merge-fuzzy'
|
||||||
abbr -a gcp 'git cherry-pick'
|
abbr -a gcp 'git cherry-pick'
|
||||||
@ -43,44 +45,27 @@ function aliases --description 'All aliases'
|
|||||||
|
|
||||||
# Vim
|
# Vim
|
||||||
abbr -a v 'vim'
|
abbr -a v 'vim'
|
||||||
if command -v nvim > /dev/null
|
abbr -a vimrc 'vim $HOME/.vimrc'
|
||||||
alias vim='nvim' # Use neovim if installed
|
|
||||||
abbr -a vimrc 'vim $HOME/.config/nvim/init.vim' # Edit ".vimrc" file
|
# Notes
|
||||||
end
|
abbr -a qn 'quicknote'
|
||||||
|
abbr -a sn 'syncnotes'
|
||||||
|
|
||||||
# Improved CLI Tools
|
# Improved CLI Tools
|
||||||
alias ping='prettyping --nolegend'
|
|
||||||
abbr -a cat 'bat' # Swap cat with bat
|
abbr -a cat 'bat' # Swap cat with bat
|
||||||
abbr -a h 'http -Fh --all' # Curl site for headers
|
abbr -a h 'http -Fh --all' # Curl site for headers
|
||||||
|
|
||||||
# Fun CLI Tools
|
# Fun CLI Tools
|
||||||
abbr goo 'googler'
|
abbr goo 'googler'
|
||||||
abbr gooj 'googler -j'
|
abbr gooj 'googler -j'
|
||||||
alias weather='curl wttr.in/$WEATHER_CITY'
|
|
||||||
alias moon='curl wttr.in/Moon'
|
|
||||||
alias ipinfo='curl ipinfo.io'
|
|
||||||
alias worldmap='telnet mapscii.me'
|
|
||||||
function ip
|
|
||||||
if count $argv > /dev/null
|
|
||||||
curl ipinfo.io/$argv
|
|
||||||
else
|
|
||||||
curl checkip.amazonaws.com
|
|
||||||
end
|
|
||||||
end
|
|
||||||
function qr
|
|
||||||
qrencode $argv[1] -o /tmp/qr.png | open /tmp/qr.png
|
|
||||||
end
|
|
||||||
function psf
|
|
||||||
ps aux | rg -v "$USER.*rg $argv" | rg $argv
|
|
||||||
end
|
|
||||||
|
|
||||||
# Dotfile and config shortcuts
|
# Dotfile and config shortcuts
|
||||||
alias reload='source $DOTS/fish.configlink/config.fish' # Refresh fish shell
|
abbr -a s 'sudo'
|
||||||
abbr -a boot '$DOTS/scripts/bootstrap'
|
abbr -a boot '$DOTS/scripts/bootstrap'
|
||||||
abbr -a sshc 'vim ~/.ssh/config'
|
abbr -a sshc 'vim ~/.ssh/config'
|
||||||
abbr -a hosts 'sudo nvim /etc/hosts'
|
abbr -a hosts 'sudo nvim /etc/hosts'
|
||||||
abbr -a frc 'vim $HOME/.config/fish/config.fish'
|
abbr -a frc 'vim $HOME/.config/fish/config.fish'
|
||||||
abbr -a falias 'vim $HOME/.config/fish/functions/aliases.fish'
|
abbr -a falias 'vim $HOME/.config/fish/functions/abbrs.fish'
|
||||||
|
|
||||||
# Cheat Sheets
|
# Cheat Sheets
|
||||||
abbr -a ssl 'openssl req -new -newkey rsa:2048 -nodes' \
|
abbr -a ssl 'openssl req -new -newkey rsa:2048 -nodes' \
|
||||||
@ -96,7 +81,6 @@ function aliases --description 'All aliases'
|
|||||||
abbr -a de 'docker exec -it'
|
abbr -a de 'docker exec -it'
|
||||||
abbr -a dpy 'docker run --rm -it -v $PWD:/project python:alpine python'
|
abbr -a dpy 'docker run --rm -it -v $PWD:/project python:alpine python'
|
||||||
abbr -a alp 'docker run --rm -it -v $PWD:/project alpine sh'
|
abbr -a alp 'docker run --rm -it -v $PWD:/project alpine sh'
|
||||||
alias connect='docker run --rm -v ~/.aws:/root/.aws -v ~/.ssh:/root/.ssh -it connect-aws'
|
|
||||||
|
|
||||||
# Terraform
|
# Terraform
|
||||||
abbr -a te 'terraform'
|
abbr -a te 'terraform'
|
||||||
@ -116,15 +100,11 @@ function aliases --description 'All aliases'
|
|||||||
abbr -a pl 'poetry run pylint *'
|
abbr -a pl 'poetry run pylint *'
|
||||||
abbr -a black 'poetry run black --target-version py38 .'
|
abbr -a black 'poetry run black --target-version py38 .'
|
||||||
abbr -a bl 'poetry run black --target-version py38 .'
|
abbr -a bl 'poetry run black --target-version py38 .'
|
||||||
alias domisty='cd $PROJ/misty && ./buildrun.sh'
|
|
||||||
|
|
||||||
# Rust
|
# Rust
|
||||||
abbr -a ca 'cargo'
|
abbr -a ca 'cargo'
|
||||||
|
|
||||||
# Non-MacOS
|
# macOS
|
||||||
if [ (uname) = "Linux" ]
|
abbr -a casks 'vim $DOTS/homebrew/Caskfile'
|
||||||
alias pbcopy='xclip -selection clipboard -in'
|
|
||||||
alias pbpaste='xclip -selection clipboard -out'
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
@ -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
|
|
9
fish.configlink/functions/brewinfo.fish
Normal file
9
fish.configlink/functions/brewinfo.fish
Normal file
@ -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
|
10
fish.configlink/functions/brews.fish
Normal file
10
fish.configlink/functions/brews.fish
Normal file
@ -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
|
9
fish.configlink/functions/brewsearch.fish
Normal file
9
fish.configlink/functions/brewsearch.fish
Normal file
@ -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
|
3
fish.configlink/functions/copy.fish
Normal file
3
fish.configlink/functions/copy.fish
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
function copy --description 'Copy file contents into clipboard'
|
||||||
|
cat $argv | pbcopy
|
||||||
|
end
|
9
fish.configlink/functions/fuck.fish
Normal file
9
fish.configlink/functions/fuck.fish
Normal file
@ -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
|
15
fish.configlink/functions/git-add-fuzzy.fish
Normal file
15
fish.configlink/functions/git-add-fuzzy.fish
Normal file
@ -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
|
4
fish.configlink/functions/git-checkout-fuzzy.fish
Normal file
4
fish.configlink/functions/git-checkout-fuzzy.fish
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
function git-checkout-fuzzy
|
||||||
|
set branch (git-fuzzy-branch "checkout branch...")
|
||||||
|
and git checkout $branch
|
||||||
|
end
|
10
fish.configlink/functions/git-commits.fish
Normal file
10
fish.configlink/functions/git-commits.fish
Normal file
@ -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
|
4
fish.configlink/functions/git-delete-fuzzy.fish
Normal file
4
fish.configlink/functions/git-delete-fuzzy.fish
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
function git-delete-fuzzy
|
||||||
|
set branch (git-fuzzy-branch "delete branch...")
|
||||||
|
and git branch -d $branch
|
||||||
|
end
|
4
fish.configlink/functions/git-force-delete-fuzzy.fish
Normal file
4
fish.configlink/functions/git-force-delete-fuzzy.fish
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
function git-force-delete-fuzzy
|
||||||
|
set branch (git-fuzzy-branch "force delete branch...")
|
||||||
|
and git branch -D $branch
|
||||||
|
end
|
12
fish.configlink/functions/git-fuzzy-branch.fish
Normal file
12
fish.configlink/functions/git-fuzzy-branch.fish
Normal file
@ -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
|
4
fish.configlink/functions/git-merge-fuzzy.fish
Normal file
4
fish.configlink/functions/git-merge-fuzzy.fish
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
function git-merge-fuzzy
|
||||||
|
set branch (git-fuzzy-branch "merge from...")
|
||||||
|
and git merge $branch
|
||||||
|
end
|
4
fish.configlink/functions/git-show-fuzzy.fish
Normal file
4
fish.configlink/functions/git-show-fuzzy.fish
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
function git-show-fuzzy
|
||||||
|
set commit (git log --pretty=oneline | fzf | cut -d' ' -f1)
|
||||||
|
and git show $commit
|
||||||
|
end
|
39
fish.configlink/functions/git.fish
Normal file
39
fish.configlink/functions/git.fish
Normal file
@ -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
|
@ -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
|
|
7
fish.configlink/functions/ip.fish
Normal file
7
fish.configlink/functions/ip.fish
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
function ip
|
||||||
|
if count $argv > /dev/null
|
||||||
|
curl ipinfo.io/$argv
|
||||||
|
else
|
||||||
|
curl checkip.amazonaws.com
|
||||||
|
end
|
||||||
|
end
|
10
fish.configlink/functions/journal.fish
Normal file
10
fish.configlink/functions/journal.fish
Normal file
@ -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
|
@ -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
|
|
10
fish.configlink/functions/meeting.fish
Normal file
10
fish.configlink/functions/meeting.fish
Normal file
@ -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
|
7
fish.configlink/functions/note-dates.fish
Normal file
7
fish.configlink/functions/note-dates.fish
Normal file
@ -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
|
4
fish.configlink/functions/note-header.fish
Normal file
4
fish.configlink/functions/note-header.fish
Normal file
@ -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
|
10
fish.configlink/functions/note.fish
Normal file
10
fish.configlink/functions/note.fish
Normal file
@ -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
|
@ -1,83 +1,5 @@
|
|||||||
#!/usr/local/bin/fish
|
#!/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
|
|
||||||
|
4
fish.configlink/functions/prj.fish
Normal file
4
fish.configlink/functions/prj.fish
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
function prj --description "cd to a project"
|
||||||
|
set projdir (ls $PROJ | fzf)
|
||||||
|
and cd $PROJ/$projdir
|
||||||
|
end
|
@ -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
|
|
3
fish.configlink/functions/psf.fish
Normal file
3
fish.configlink/functions/psf.fish
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
function psf
|
||||||
|
ps aux | rg -v "$USER.*rg $argv" | rg $argv
|
||||||
|
end
|
3
fish.configlink/functions/qr.fish
Normal file
3
fish.configlink/functions/qr.fish
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
function qr
|
||||||
|
qrencode $argv[1] -o /tmp/qr.png | open /tmp/qr.png
|
||||||
|
end
|
5
fish.configlink/functions/quicknote.fish
Normal file
5
fish.configlink/functions/quicknote.fish
Normal file
@ -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
|
9
fish.configlink/functions/syncnotes.fish
Normal file
9
fish.configlink/functions/syncnotes.fish
Normal file
@ -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
|
11
fish.configlink/functions/today.fish
Normal file
11
fish.configlink/functions/today.fish
Normal file
@ -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
|
6
fish.configlink/functions/unsetaws.fish
Normal file
6
fish.configlink/functions/unsetaws.fish
Normal file
@ -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
|
Loading…
Reference in New Issue
Block a user