Chunk & Split zshrc into smaller files

This commit is contained in:
pfych 2025-02-19 13:47:48 +11:00
parent 1314b22f27
commit 7fd48fb729
5 changed files with 57 additions and 51 deletions

11
.config/zsh/darwin.sh Normal file
View File

@ -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;

1
.config/zsh/linux.sh Normal file
View File

@ -0,0 +1 @@
export PATH="${PATH}:${HOME}/.local/bin:/usr/local/sbin:${HOME}/.local/share/gem/ruby/2.0.0/bin:/usr/local/bin"

14
.config/zsh/plugins.sh Normal file
View File

@ -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)"
}

21
.config/zsh/shared.sh Normal file
View File

@ -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"

61
.zshrc
View File

@ -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"