diff options
Diffstat (limited to 'dot_config/zsh/dot_zshrc')
-rw-r--r-- | dot_config/zsh/dot_zshrc | 129 |
1 files changed, 129 insertions, 0 deletions
diff --git a/dot_config/zsh/dot_zshrc b/dot_config/zsh/dot_zshrc index e1d01f1..ab059fd 100644 --- a/dot_config/zsh/dot_zshrc +++ b/dot_config/zsh/dot_zshrc @@ -11,3 +11,132 @@ RPROMPT="%(?.%F{10}%?.%F{9}%?)%f %T" autoload -U compaudit compinit zrecompile giti autoload -U colors && colors + + +export PATH="/opt/homebrew/bin:/opt/homebrew/sbin:${PATH}" + +# zinit +declare -A ZINIT +ZINIT[HOME_DIR]="${XDG_CONFIG_HOME}/zinit" +ZINIT[ZCOMPDUMP_PATH]="${XDG_CACHE_HOME}/zcompdump-${HOSTNAME}-${ZSH_VERSION}" +source "${XDG_DATA_HOME}/zinit/zinit.git/zinit.zsh" + +# bashcompinit after zinit sets up compdump path +autoload -U +X bashcompinit && bashcompinit + +# Powerlevel10k instant prompt. Any input prompts above, other stuff below +if [[ -r "${XDG_CACHE_HOME}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then + source "${XDG_CACHE_HOME}/p10k-instant-prompt-${(%):-%n}.zsh" +fi + +# Speed up autosuggestions by requiring manual rebind if ever lost +ZSH_AUTOSUGGEST_MANUAL_REBIND=1 + +ZSH_CUSTOM="${XDG_DATA_HOME:-${HOME}/.local/share}/zsh" + +zinit load "${ZSH_CUSTOM}/brew/" +zinit load "${ZSH_CUSTOM}/fzf/" +zinit load "${ZSH_CUSTOM}/completion/" +zinit load "${ZSH_CUSTOM}/clipboard/" +zinit load "${ZSH_CUSTOM}/git/" +zinit load "${ZSH_CUSTOM}/powerlevel10k/" +zinit load "${ZSH_CUSTOM}/coloured-man/" +zinit load "${ZSH_CUSTOM}/zsh-autosuggestions/" +zinit load "${ZSH_CUSTOM}/fast-syntax-highlighting/" +zinit load "${ZSH_CUSTOM}/auto-activate-venv/" +zinit load "${ZSH_CUSTOM}/fzf-z/" +zinit load "${ZSH_CUSTOM}/bindings/" +# zinit load "${ZSH_CUSTOM}/zsh-autocomplete/" + +# zinit has issues, use zsh-defer +# zinit load "${ZSH_CUSTOM}/zsh-edit/" +source "${ZSH_CUSTOM}/zsh-defer/zsh-defer.plugin.zsh" +zsh-defer source "${ZSH_CUSTOM}/zsh-edit/zsh-edit.plugin.zsh" +zsh-defer bindkey '^W' backward-kill-subword +zsh-defer bindkey '^H' backward-kill-shell-word + +zsh-defer source "${ZDOTDIR}/alias.zsh" + +zinit ice as"completion" +zinit snippet "${ZSH_CUSTOM}/completion/_pass" + +zinit ice as"completion" +zinit snippet https://github.com/docker/cli/blob/master/contrib/completion/zsh/_docker + +zinit ice as"completion" +zinit snippet https://github.com/zsh-users/zsh-completions/blob/master/src/_nano + +# get git-extras + git-extras completions +alias pip='noglob python -m pip' + +# zinit load ${ZSH}/plugins/fasd/ +# steal: j/z but use fzf? + +# zinit load ${ZSH}/plugins/fzf/ +# steal: fzf-completion +# steal: fzf-cd-widget +# steal: fzf-history-widget + +zicompinit +zicdreplay + +# echo ${INSTALLED_COMPS} + +# Set editor to micro/nano +if which micro &>/dev/null; then + export EDITOR='micro' + function micro() { + emulate -L zsh + autoload is-at-least + if is-at-least 2.0.0 $(command env micro -version | cut -d' ' -f2); then + unset -f micro + command env micro "$@" + else + local log_exists + if [[ -f log.txt ]]; then + log_exists=1 + fi + command env micro "$@" + if [[ -f log.txt ]] && [[ ${log_exists} != 1 ]]; then + rm log.txt + fi + fi + } +else + export EDITOR='nano' +fi + + +# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh. +if [[ -f "${ZDOTDIR}/.p10k.zsh" ]]; then + source "${ZDOTDIR}/.p10k.zsh" +elif [[ -f "/etc/zsh/p10k.zsh" ]]; then + source "/etc/zsh/p10k.zsh" +fi + +# WSL tricks +if [[ "$(uname -r)" == *microsoft-standard* ]]; then + if [[ $(service ssh status) == *"is not running"* ]]; then + sudo service ssh --full-restart > /dev/null + fi +fi + +# iTerm2 integration +if [[ -e "${HOME}/.local/share/iterm2/integration/shell_integration/zsh" ]] && which hostname &>/dev/null; then + source "${HOME}/.local/share/iterm2/integration/shell_integration/zsh" + iterm2_print_user_vars() { + it2git + } +fi + +# macOS wifi utility +if [[ -f "/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport" ]]; then + alias airport="/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport" +fi + +# JetBrains Toolbox +if [[ -d "${HOME}/Library/Application Support/JetBrains/Toolbox/scripts" ]]; then + export PATH="${PATH}:${HOME}/Library/Application Support/JetBrains/Toolbox/scripts" +fi + +export FZFZ_RECENT_DIRS_TOOL="fasd" |