diff --git a/deploy.sh b/deploy.sh index fc4de77..24fb17c 100755 --- a/deploy.sh +++ b/deploy.sh @@ -6,7 +6,9 @@ # Relative path/name as keys, destination path as values declare -A configs=( - ["zshrc"]="$HOME/.zshrc" + ["zsh/zshrc"]="$HOME/.zshrc" + ["zsh/zsh_functions"]="$HOME/.config/zsh/zsh_functions.zsh" + ["zsh/zsh_aliases"]="$HOME/.config/zsh/zsh_aliases.zsh" ["fb-custom.zsh-theme"]="$HOME/.oh-my-zsh/custom/themes" ["nvim/init.lua"]="$HOME/.config/nvim/init.lua" ["nvim/lua"]="$HOME/.config/nvim/" diff --git a/zsh/zsh_aliases b/zsh/zsh_aliases new file mode 100644 index 0000000..6e828a8 --- /dev/null +++ b/zsh/zsh_aliases @@ -0,0 +1,9 @@ +# Aliases Universal +alias rm="rm -I" # Prompt for removal of more than three files or recursively to give some protection of mistakes +alias mv="mv -i" # Prompt before moving files +alias df="df -h" # Always use the human readable formatting +alias du="du -h -d 1" # Always use human readable format and only for the current dir by default +alias k="killall" # Quick killall +alias p="ps aux | grep $1" # Quick +alias n="$EDITOR" # Just open the usual editor +alias todo="nvim ~/.zettelkasten/TODO.md" diff --git a/zsh/zsh_functions b/zsh/zsh_functions new file mode 100644 index 0000000..6c08619 --- /dev/null +++ b/zsh/zsh_functions @@ -0,0 +1,18 @@ +### Custom functions +# Timing function for checking zsh load speed +function timezsh() { + shell=$SHELL + for i in $(seq 1 10) + do + ts=$(date +%s%N) + $SHELL -i -c exit + echo $((($(date +%s%N) - $ts)/1000000))ms + done +} + +# Custom rsync move function that also removes empty directories that have their contents removed +# NOTE: This will delete *any* empty directories in the CWD +function rmv() { + rsync -avzhP --remove-source-files --ignore-existing "${@:1:$#-1}" "${@:$#}" && \ + find ./* -depth -type d -empty -exec rmdir "{}" \; +} diff --git a/zshrc b/zsh/zshrc similarity index 51% rename from zshrc rename to zsh/zshrc index c8b53e4..3cea589 100644 --- a/zshrc +++ b/zsh/zshrc @@ -1,4 +1,5 @@ # call `zprof` to profile all calls in the current shell +# Uncomment here and at the bottom of the file, then fully reopen a terminal # zmodload zsh/zprof # Install oh-my-zsh if it doesn't exist @@ -11,9 +12,6 @@ fi ## Path variables # Path to your oh-my-zsh installation. export ZSH="$HOME/.oh-my-zsh" -export XDG_CONFIG_HOME="$HOME/.config" -export XDG_DATA_HOME="$HOME/.local/share" -export XDG_CACHE_HOME="$HOME/.cache" export MANPAGER="less -R --use-color -Dd+r -Du+b" # Colored MAN pages @@ -22,22 +20,7 @@ ZSH_THEME="fb-custom" # Uncomment the following line to use hyphen-insensitive completion. # Case-sensitive completion must be off. _ and - will be interchangeable. HYPHEN_INSENSITIVE="true" - -# History -HISTCONTROL=ignoreboth - -# Uncomment one of the following lines to change the auto-update behavior -zstyle ':omz:update' mode reminder frequency 14 - -# Keybindings -bindkey "^a" beginning-of-line -bindkey "^e" end-of-line -# bindkey "^h" backward-word -# bindkey "^k" kill-line -# bindkey "^j" backward-word -# bindkey "^k" forward-word -# bindkey "^J" history-search-forward -# bindkey "^K" history-search-backward +DISABLE_AUTO_UPDATE="true" ### Plugins # Install the zsh-autosuggestions plugin if it doesn't exist @@ -47,14 +30,8 @@ then fi plugins=( - aws - copypath - dotenv fzf - git - history zsh-autosuggestions - virtualenv virtualenvwrapper # Used for autoloading project .venvs ) @@ -65,20 +42,11 @@ source $ZSH/oh-my-zsh.sh setopt NO_clobber # Do not clobber files by default setopt hist_ignore_all_dups # Replace old history with the newest call to an identical call setopt hist_ignore_space # Remove history lines that start with spaces -# setopt correctall # Correct commands # Experimental setopt append_history inc_append_history share_history -# setopt auto_menu menu_complete -# setopt autocd setopt auto_param_slash setopt no_case_glob no_case_match -# setopt globdots - -# Enable compinit advanced completion -zmodload zsh/complist -autoload -Uz compinit && compinit -autoload -U colors && colors # Completion options # Give descriptions of what the types of completions given @@ -105,32 +73,13 @@ then eval $(keychain --eval --quiet --nogui --noask) fi -### Custom functions -# Timing function for checking zsh load speed -timezsh() { - shell=$SHELL - for i in $(seq 1 10) - do - ts=$(date +%s%N) - $SHELL -i -c exit - echo $((($(date +%s%N) - $ts)/1000000))ms - done -} - -# Aliases Universal -alias rm="rm -Iv" # Prompt for removal of more than three files or recursively to give some protection of mistakes -alias df="df -h" # Always use the human readable formatting -alias du="du -h -d 1" # Always use human readable format and only for the current dir by default -alias k="killall" # Quick killall -alias p="ps aux | grep $1" # Quick -alias v="$EDITOR" # Just open the usual editor -alias todo="nvim ~/.zettelkasten/TODO.md" - ### Environment specific include files include_files=( - "$HOME/.zsh_aliases" - "$HOME/.zsh_exports" - "$HOME/.zsh_local" + "$HOME/.config/zsh/fb_theme.zsh" + "$HOME/.config/zsh/zsh_local.zsh" + "$HOME/.config/zsh/zsh_aliases.zsh" + "$HOME/.config/zsh/zsh_exports.zsh" + "$HOME/.config/zsh/zsh_functions.zsh" ) for file in $include_files; do @@ -142,14 +91,5 @@ for file in $include_files; do source $file done -# Custom rsync move function that also removes empty directories that have their contents removed -# NOTE: This will delete *any* empty directories in the CWD -rmv() { - rsync -avzhP --remove-source-files --ignore-existing "${@:1:$#-1}" "${@:$#}" && \ - find ./* -depth -type d -empty -exec rmdir "{}" \; -} - -# NVM required config -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 +# Call to zprof for startup timings +# zprof