dotfiles/zshrc.zsh

172 lines
5 KiB
Bash
Raw Normal View History

# User configuration
# history
HISTFILE=~/.histfile
HISTSIZE=10000
SAVEHIST=10000
2020-08-28 10:36:07 +01:00
# vim binddings
bindkey -v
2020-08-28 10:36:07 +01:00
# You may need to manually set your language environment
export LANG=en_GB.UTF-8
# Preferred editor for local and remote sessions
export EDITOR=nvim
2022-03-20 18:05:57 +00:00
# Autoadd to PATH (neede for MacTex)
# It prepends to $PATH, so we do it first then add our own
if [[ -f /usr/libexec/path_helper ]]; then
2022-07-22 17:04:53 +01:00
eval $(/usr/libexec/path_helper)
fi
2022-03-20 18:05:57 +00:00
# Add our own dirs to the $PATH
if [[ -f /opt/homebrew/bin/brew ]]; then
eval "$(/opt/homebrew/bin/brew shellenv)"
fi
if [[ -f /usr/local/bin/brew ]]; then
eval "$(/usr/local/bin/brew shellenv)"
fi
export PATH="$HOME/.local/bin:$PATH"
# credit Paul Irish: https://github.com/paulirish/dotfiles/blob/606d85f083eb53853789ce9dcaf31a49756471bd/.zshrc#L80
# Automatically list directory contents on `cd`.
# Switched to using `exa` instead of `ls`.
ezacd () {
2022-07-22 17:04:53 +01:00
emulate -L zsh;
eza --oneline --long --classify --icons --header
}
chpwd_functions=(${chpwd_functions[@]} "ezacd")
# Go Lang stuff
2020-11-16 17:39:32 +00:00
export GOPATH=$HOME/go
if (( ${+commands[brew]} )); then
2023-05-21 18:22:10 +01:00
export PATH="$PATH:$(brew --prefix)/go/bin:$(brew --prefix)/opt/go/libexec/bin:$GOPATH/bin"
fi
2022-07-22 17:22:49 +01:00
# Add various GNU functions
# Prepend them to the PATH so they override any system installed versions
if (( ${+commands[brew]} )); then
2023-05-21 18:22:10 +01:00
export PATH="$(brew --prefix)/opt/coreutils/libexec/gnubin:$PATH"
export PATH="$(brew --prefix)/opt/findutils/libexec/gnubin:$PATH"
export PATH="$(brew --prefix)/opt/gnu-sed/libexec/gnubin:$PATH"
export PATH="$(brew --prefix)/opt/grep/libexec/gnubin:$PATH"
fi
2022-07-22 17:22:49 +01:00
2022-07-13 15:47:41 +01:00
# Add Totara Docker helper functions
export PATH="$PATH:$HOME/git/totara-docker-dev/bin"
# Set the rip (Rm ImProved) graveyard
export GRAVEYARD="$HOME/.local/share/Trash"
# composer global
export PATH="$PATH:$HOME/.composer/vendor/bin"
# rust/cargo bin PATH
export PATH="$PATH:$HOME/.cargo/bin"
# Ruby PATH
if (( ${+commands[brew]} )); then
export PATH="$PATH:$(brew --prefix)/opt/ruby/bin"
2023-05-21 18:22:10 +01:00
fi
# PostgreSQL binaries
if (( ${+commands[brew]} )); then
2023-05-21 18:22:10 +01:00
test -d $(brew --prefix)/pgsql && export PATH="$PATH:$(brew --prefix)/pgsql/bin"
fi
# PHP binaries
test -d $HOME/.php/bin && export PATH="$PATH:$HOME/.php/bin"
2022-07-22 17:04:53 +01:00
# JetBrains Toolbox scripts
test -d "$HOME/Library/Application Support/JetBrains/Toolbox/scripts" && export PATH="$PATH:$HOME/Library/Application Support/JetBrains/Toolbox/scripts"
2022-09-03 12:49:27 +01:00
# Homebrew cURL if we have it
if (( ${+commands[brew]} )); then
2023-05-21 18:22:10 +01:00
test -d $(brew --prefix)/opt/curl && export PATH="$(brew --prefix)/opt/curl/bin:$PATH"
fi
2022-09-03 12:49:27 +01:00
# Load plugins via Sheldon
if (( ${+commands[sheldon]} )); then
eval "$(sheldon source)"
fi
# Detect system appearance
export MACOS_APPEARANCE=`get-system-appearance`
# Colourised output for `ls`
2024-03-22 15:59:05 +00:00
# vivid Dark mode ayu
# vivid Light mode catppuccin-latte
2023-06-04 18:49:01 +01:00
if type vivid &>/dev/null; then
2024-03-22 15:59:05 +00:00
local vividTheme="ayu"
if [[ $MACOS_APPEARANCE == "light" ]]; then
vividTheme="catppuccin-latte"
2024-03-22 15:59:05 +00:00
fi
2024-03-22 15:59:05 +00:00
export LS_COLORS="$(vivid generate $vividTheme)"
2023-06-04 18:49:01 +01:00
fi
2023-07-30 21:26:04 +01:00
# Set colour scheme got bat
2024-03-22 15:59:05 +00:00
# bat Dark mode OneHalfDark
2024-06-09 16:47:03 +01:00
# bat Light mode gruvbox-light
2024-03-22 15:59:05 +00:00
local batTheme="OneHalfDark"
if [[ $MACOS_APPEARANCE == "light" ]]; then
2024-05-15 19:49:21 +01:00
batTheme="gruvbox-light"
2024-03-22 15:59:05 +00:00
fi
export BAT_THEME=$batTheme
# Source the untracked `extra` file
test -e $HOME/.extra && source $HOME/.extra
2020-08-28 10:36:07 +01:00
# Set the prompt
# We need zsh git integration
# Autoload zsh's `add-zsh-hook` and `vcs_info` functions
# (-U autoload w/o substition, -z use zsh style)
autoload -Uz add-zsh-hook vcs_info
# Set prompt substitution so we can use the vcs_info_message variable
setopt prompt_subst
# Run the `vcs_info` hook to grab git info before displaying the prompt
add-zsh-hook precmd vcs_info
# Style the vcs_info message
zstyle ':vcs_info:*' enable git
zstyle ':vcs_info:git*' formats '⎇ %b%u%c'
# Format when the repo is in an action (merge, rebase, etc)
zstyle ':vcs_info:git*' actionformats '%F{14}⏱ %*%f'
zstyle ':vcs_info:git*' unstagedstr '*'
zstyle ':vcs_info:git*' stagedstr '+'
# This enables %u and %c (unstaged/staged changes) to work,
# but can be slow on large repos
zstyle ':vcs_info:*:*' check-for-changes true
2024-09-20 21:18:21 +01:00
# First show the Loading indicator in the right prompt if shell plugins are still loading
RPROMPT='%F{8}$(if [[ -n $SHELL_LOADING ]]; then echo "Loading... "; fi)'
# Then we can also show the git branch
RPROMPT+='${vcs_info_msg_0_}'
# First set a dot that changes colour on success/fail or previous command
PROMPT='%(?.%F{blue}⏺.%F{red}⏺)%f '
# Show a symbol for the OS
# First we set the os_symbol variable we will use in the prompt
if [[ "$OSTYPE" == "darwin"* ]]; then
os_symbol=""
elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
os_symbol="󰣇"
else
os_symbol="" # Fallback symbol if OS is neither macOS nor Linux
fi
PROMPT+='${os_symbol} '
# Then show the working directory
PROMPT+='%2~ '
# Finally we can adjust the prompt to show if we are a user or sudo
PROMPT+='%(!.#.$) '
2024-03-22 15:59:05 +00:00
# Finally we can have zsh auto source this rc file on command
# attribution: https://www.reddit.com/r/commandline/comments/12g76v/
trap "source $HOME/.zshrc" USR1