From 7fd48fb7293c6b772f4fb8d1abbe00ebe87021c7 Mon Sep 17 00:00:00 2001 From: pfych Date: Wed, 19 Feb 2025 13:47:48 +1100 Subject: [PATCH] Chunk & Split zshrc into smaller files --- .config/zsh/darwin.sh | 11 ++++++++ .config/zsh/linux.sh | 1 + .config/zsh/plugins.sh | 14 ++++++++++ .config/zsh/shared.sh | 21 +++++++++++++++ .zshrc | 61 +++++++----------------------------------- 5 files changed, 57 insertions(+), 51 deletions(-) create mode 100644 .config/zsh/darwin.sh create mode 100644 .config/zsh/linux.sh create mode 100644 .config/zsh/plugins.sh create mode 100644 .config/zsh/shared.sh diff --git a/.config/zsh/darwin.sh b/.config/zsh/darwin.sh new file mode 100644 index 0000000..a7a99ba --- /dev/null +++ b/.config/zsh/darwin.sh @@ -0,0 +1,11 @@ +if [[ $(uname -m) == 'arm64' ]]; then + # Homebrew has a different location on M series devices + eval "$(/opt/homebrew/bin/brew shellenv)" +fi + +export PATH="/usr/local/opt/grep/libexec/gnubin:$PATH:${HOME}/.local/bin:/usr/local/sbin:${HOME}/.local/share/gem/ruby/2.0.0/bin:/usr/local/bin" +export ANDROID_SDK_ROOT=/Users/$USER/Library/Android/sdk + +eval "$(rbenv init - zsh)" + +alias date=gdate; diff --git a/.config/zsh/linux.sh b/.config/zsh/linux.sh new file mode 100644 index 0000000..766a5a0 --- /dev/null +++ b/.config/zsh/linux.sh @@ -0,0 +1 @@ +export PATH="${PATH}:${HOME}/.local/bin:/usr/local/sbin:${HOME}/.local/share/gem/ruby/2.0.0/bin:/usr/local/bin" diff --git a/.config/zsh/plugins.sh b/.config/zsh/plugins.sh new file mode 100644 index 0000000..36b9e4b --- /dev/null +++ b/.config/zsh/plugins.sh @@ -0,0 +1,14 @@ +source "$CONFIGDIR/zsh/plugins/zsh-git-prompt/zshrc.sh" +source "$CONFIGDIR/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" +source "$CONFIGDIR/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh" + +# Autocomplete +ZSH_AUTOSUGGEST_USE_ASYNC=true +ZSH_AUTOSUGGEST_STRATEGY=(history completion) + +# Prompt +precmd() { + PROMPT="[%c] " + RPROMPT="$(git_super_status)" +} + diff --git a/.config/zsh/shared.sh b/.config/zsh/shared.sh new file mode 100644 index 0000000..095d76a --- /dev/null +++ b/.config/zsh/shared.sh @@ -0,0 +1,21 @@ +# Use NVIM +alias vim=nvim + +# NVM +export NVM_DIR="$CONFIGDIR/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 + +# Nodejs +export SKIP_PREFLIGHT_CHECK=true + +# FZF +export FZF_DEFAULT_COMMAND='find . -type d \( -name Pods -o -name .yarn -o -name node_modules -o -name .git -o -path name \) -prune -false -o -name "*"' +[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh + +# thefuck +eval $(thefuck --alias) +alias a=fuck + +# Load extra functions +source "$CONFIGDIR/scripts/scripts.sh" diff --git a/.zshrc b/.zshrc index 10ca3c3..4b550ad 100644 --- a/.zshrc +++ b/.zshrc @@ -1,58 +1,17 @@ -# Path -if [[ $(uname) == "Darwin" ]]; then - if [[ $(uname -m) == 'arm64' ]]; then - # Homebrew has a different location on M series devices - eval "$(/opt/homebrew/bin/brew shellenv)" - fi - - export PATH="/usr/local/opt/grep/libexec/gnubin:$PATH:${HOME}/.local/bin:/usr/local/sbin:${HOME}/.local/share/gem/ruby/2.0.0/bin:/usr/local/bin" - export ANDROID_SDK_ROOT=/Users/$USER/Library/Android/sdk - alias date=gdate; - eval "$(rbenv init - zsh)" -else - export PATH="${PATH}:${HOME}/.local/bin:/usr/local/sbin:${HOME}/.local/share/gem/ruby/2.0.0/bin:/usr/local/bin" -fi - # Config export CONFIGDIR="${HOME}/.config" export XDG_CONFIG_HOME=$CONFIGDIR export EDITOR=nvim -# Plugins -source "$CONFIGDIR/zsh/plugins/zsh-git-prompt/zshrc.sh" -source "$CONFIGDIR/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" -source "$CONFIGDIR/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh" +# OS Specific +if [[ $(uname) == "Darwin" ]]; then + source "$CONFIGDIR/zsh/darwin.sh" +else + source "$CONFIGDIR/zsh/linux.sh" +fi -# Use NVIM -alias vim=nvim +# Load shared config +source "$CONFIGDIR/zsh/shared.sh" -# NVM -export NVM_DIR="$CONFIGDIR/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 - -# Autocomplete -ZSH_AUTOSUGGEST_USE_ASYNC=true -ZSH_AUTOSUGGEST_STRATEGY=(history completion) - -# Prompt -precmd() { - PROMPT="[%c] " - RPROMPT="$(git_super_status)" -} -# Added by serverless binary installer -export PATH="$HOME/.serverless/bin:$PATH" - -# Nodejs -export SKIP_PREFLIGHT_CHECK=true - -# FZF -export FZF_DEFAULT_COMMAND='find . -type d \( -name Pods -o -name .yarn -o -name node_modules -o -name .git -o -path name \) -prune -false -o -name "*"' -[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh - -# thefuck -eval $(thefuck --alias) -alias a=fuck - -# Load extra functions -source ~/.config/scripts/scripts.sh +# Load plugin related items +source "$CONFIGDIR/zsh/plugins.sh"