From 805f2d06bb793b58a14f39a65b1fa5e143aefe26 Mon Sep 17 00:00:00 2001 From: Andrei Stoica Date: Mon, 18 Mar 2024 14:56:28 -0400 Subject: [PATCH] alias and zsh startup optimization --- .aliases | 25 ++++++++++++++++++++++-- .zshrc | 58 ++++++++++---------------------------------------------- 2 files changed, 33 insertions(+), 50 deletions(-) diff --git a/.aliases b/.aliases index deef585..7ce1581 100644 --- a/.aliases +++ b/.aliases @@ -1,7 +1,28 @@ # Complex aliasses ## Open notes folder in nvim then return -function notes() {cd $HOME/Notes; nvim; cd -;}; -function sb() {cd $HOME/second-brain/; git pull; nvim; git add .; git commit; git push; cd -;}; +function notes() { cd $HOME/Notes; nvim; cd -; }; +function sb() { cd $HOME/second-brain/; git pull; nvim; git add .; git commit; git push; cd -; }; + +## Open work folder with fuzzy finder +function work() { + work_dirs=( "$HOME/clones" "$HOME/sandbox" ) + goto="" + if [ ! -z $1 ]; then + goto=$(find $work_dirs -maxdepth 1 -mindepth 1 -type d | fzf -f $1) + fi + + if [ -z "$goto" -o $(wc -l <<< "$goto") -ne 1 ]; then + goto=$(find $work_dirs -maxdepth 1 -mindepth 1 -type d | fzf --query=$1 --preview "tree -C -L 2 {}") + fi + + [ -z $goto ] && return + if [ -z $TMUX ]; then + tmux new -A -s "$(basename -- $goto)" -c "$goto" + else + tmux new -d -s "$(basename -- $goto)" -c "$goto" + tmux switch-client -t "$(basename -- $goto)" + fi +} # simple alias clj='rlwrap java -cp ~/Clojure/clojure-1.8.0.jar clojure.main' diff --git a/.zshrc b/.zshrc index d2bbef7..894bf7a 100644 --- a/.zshrc +++ b/.zshrc @@ -1,3 +1,6 @@ +zmodload zsh/zprof +export NVM_LAZY_LOAD=true +export NVM_COMPLETION=true # If you come from bash you might have to change your $PATH. export PATH=$HOME/bin:/usr/local/bin:/usr/lib65/openjdk-17/bin:$PATH @@ -109,53 +112,12 @@ export PATH=$HOME/.cargo/bin:$PATH # adding local to path export PATH=$HOME/.local/bin:$PATH -# Open work folder with fuzzy finder -function work() { - work_dirs=( "$HOME/clones" "$HOME/sandbox" ) - - goto=$(find $work_dirs -maxdepth 1 -mindepth 1 -type d | fzf --query=$1 --preview "tree -C -L 2 {}") - [ -z $goto ] && return - - if [ -z $TMUX ] - then - tmux new -A -s "$(basename -- $goto)" -c "$goto" - else - tmux new -d -s "$(basename -- $goto)" -c "$goto" - tmux switch-client -t "$(basename -- $goto)" - fi - -} - -# JINA_CLI_BEGIN - -## autocomplete -if [[ ! -o interactive ]]; then - return -fi - -compctl -K _jina jina - -_jina() { - local words completions - read -cA words - - if [ "${#words}" -eq 2 ]; then - completions="$(jina commands)" - else - completions="$(jina completions ${words[2,-2]})" - fi - - reply=(${(ps: -:)completions}) -} - -# session-wise fix -ulimit -n 4096 -export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES - -# JINA_CLI_END - export NVM_DIR="$HOME/.nvm" -[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm -[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion +#[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm +nvm() { + unset -f nvm + export NVM_DIR=~/.nvm + [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm + nvm "$@" +}