dotfiles/zshrc.zsh

218 lines
5.9 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
# ZSH builtin autoload
2020-12-05 09:42:40 +00:00
if type brew &>/dev/null; then
2022-07-22 17:04:53 +01:00
FPATH=$(brew --prefix)/share/zsh/site-functions:$FPATH
FPATH=$(brew --prefix)/share/zsh/zsh-completions:$FPATH
2020-12-05 09:42:40 +00:00
fi
2022-10-10 17:44:51 +01:00
autoload -Uz compinit promptinit run-help zmv
compinit
promptinit
case $(type run-help) in
2022-07-22 17:04:53 +01:00
(*alias*) unalias run-help;;
esac
alias help=run-help
# Persistant rehash to find new programs in the $PATH
zstyle ':completion:*' rehash true
# You may need to manually set your language environment
export LANG=en_GB.UTF-8
# Preferred editor for local and remote sessions
2024-05-28 21:52:10 +01:00
export EDITOR='nvim'
# Set the DEFAULT_USER variable to me (jonny)
export DEFAULT_USER="jonny"
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"
2024-03-22 15:59:05 +00:00
# Source my own functions
source $HOME/.zsh/functions.zsh
# Determine the running OS
source $HOME/.zsh/platform.zsh
2024-03-22 15:59:05 +00:00
# Detect system appearance
export MACOS_APPEARANCE=`get-system-appearance`
# ZSH syntax highlighting
source $HOME/.zsh/zsh-syntax-highlighting.zsh
# ZSH history substring search
source $HOME/.zsh/zsh-substring-search.zsh
# ZSH autosuggestions
2023-07-30 17:48:18 +01:00
source $HOME/.zsh/zsh-autosuggestions.zsh
# Aliases
source $HOME/.zsh/aliases.zsh
# 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
2023-05-21 18:22:10 +01:00
if type brew &>/dev/null; then
export PATH="$PATH:$(brew --prefix)/go/bin:$(brew --prefix)/opt/go/libexec/bin:$GOPATH/bin"
fi
# GnuPG stuff
GPG_TTY=`tty`
export GPG_TTY
2022-07-22 17:22:49 +01:00
# Add various GNU functions
2023-05-21 18:22:10 +01:00
if type brew &>/dev/null; then
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
2023-05-21 18:22:10 +01:00
if type brew &>/dev/null; then
export PATH="$PATH:$(brew --prefix)/opt/ruby/bin:$HOME/.gem/ruby/2.4.0/bin"
fi
# PostgreSQL binaries
2023-05-21 18:22:10 +01:00
if type brew &>/dev/null; then
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
2023-05-21 18:22:10 +01:00
if type brew &>/dev/null; then
test -d $(brew --prefix)/opt/curl && export PATH="$(brew --prefix)/opt/curl/bin:$PATH"
fi
2022-09-03 12:49:27 +01:00
# Colourised output for `ls`
2024-03-22 15:59:05 +00:00
# export CLICOLOR=true
# export CLICOLOR_FORCE=true
# export LSCOLORS='dxfxcxdxbxegedabagacad'
# export LS_COLORS='di=33;40:ln=35;40:so=32;40:pi=33;40:ex=31;40:bd=34;46:cd=34;43:su=0;41:sg=0;46:tw=0;42:ow=0;43:'
# vivid Dark mode ayu
# vivid Light mode snazzy
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
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
2024-02-10 22:34:30 +00:00
# Setup fzf completions
export FZF_COMPLETION_TRIGGER='~~'
if type fzf > /dev/null; then
eval "$(fzf --zsh)"
fi
2024-02-10 22:34:30 +00:00
# Source the iTerm2 shell integration
test -e ${HOME}/.iterm2_shell_integration.zsh && source ${HOME}/.iterm2_shell_integration.zsh
# Source the untracked `extra` file
test -e $HOME/.extra && source $HOME/.extra
2020-08-28 10:36:07 +01:00
2023-05-21 18:14:03 +01:00
# You Should Use
test -e /opt/homebrew/share/zsh-you-should-use/you-should-use.plugin.zsh && source /opt/homebrew/share/zsh-you-should-use/you-should-use.plugin.zsh
test -e /usr/share/zsh/plugins/zsh-you-should-use/you-should-use.plugin.zsh && source /usr/share/zsh/plugins/zsh-you-should-use/you-should-use.plugin.zsh
2024-01-23 19:10:15 +00:00
# Setup Fast Node Manager
if type fnm > /dev/null; then
eval "$(fnm env --use-on-cd)"
fi
2024-01-23 19:10:15 +00:00
2023-04-13 18:23:43 +01:00
# Setup GitHub Copilot
# first check we even have the genereic `gh` command
if type gh > /dev/null; then
# Now check we have the copilot plugin installed with `gh`
if gh extension list | rg copilot -c > /dev/null; then
eval "$(gh copilot alias -- zsh)"
fi
2023-04-13 18:23:43 +01:00
fi
2022-01-09 09:23:56 +00:00
# Init the fuck
2022-03-20 17:04:03 +00:00
if type thefuck > /dev/null; then
eval "$(thefuck --alias)"
2022-01-09 09:23:56 +00:00
fi
2022-02-17 17:38:15 +00:00
# https://github.com/wfxr/forgit
test -e $HOME/git/forgit/forgit.plugin.zsh && source $HOME/git/forgit/forgit.plugin.zsh
2023-06-18 12:03:10 +01:00
test -e $HOME/git/forgit/completionsgit-forgit.zsh && source $HOME/git/forgit/completionsgit-forgit.zsh
2022-02-17 17:38:15 +00:00
2022-03-13 07:09:28 +00:00
# McFly
2022-03-20 17:03:15 +00:00
if type mcfly > /dev/null; then
eval "$(mcfly init zsh)"
2022-03-13 07:09:28 +00:00
fi
2023-07-30 15:16:53 +01:00
# ngrok completions
if command -v ngrok &>/dev/null; then
eval "$(ngrok completion)"
fi
2024-02-16 18:28:58 +00:00
# zoxide - a better `cd` command
if command -v zoxide &>/dev/null; then
eval "$(zoxide init zsh)"
fi
2020-08-28 10:36:07 +01:00
# Init starship prompt -- https://starship.rs
2024-06-10 20:37:31 +01:00
#eval "$(starship init zsh)"
# Oh My Posh
eval "$(oh-my-posh init zsh --config $HOME/.config/jmb.omp.toml)"
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