Files
dotfiles/zsh/.zshrc
2024-10-07 14:29:55 +02:00

87 lines
2.8 KiB
Bash

# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
# Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block; everything else may go below.
[[ -f ~/.zsh/.powerline_config ]] && source ~/.zsh/.powerline_config
[[ -f ~/.zsh/.user_config ]] && source ~/.zsh/.user_config
[[ -f ~/.zsh/.virtual_env_config.zsh ]] && source ~/.zsh/.virtual_env_config.zsh
[[ -f ~/.zsh/.local_config ]] && source ~/.zsh/.local_config
# Load Antidote
mkdir -p ${ZDOTDIR:-~}/.cache/zsh
static_file=${ZDOTDIR:-~}/.cache/zsh/.zsh_plugins.zsh
plugins_txt=${ZDOTDIR:-~}/.zsh/.zsh_plugins.txt
# clone antidote if necessary
if ! [[ -e ${ZDOTDIR:-~}/.antidote ]]; then
git clone https://github.com/mattmc3/antidote.git ${ZDOTDIR:-~}/.antidote
fi
zstyle ':completion:*:ssh:*' hosts off
zstyle ':completion:*:scp:*' hosts off
# source antidote and load plugins from `${ZDOTDIR:-~}/.zsh_plugins.txt`
source ${ZDOTDIR:-~}/.antidote/antidote.zsh
antidote load ${plugins_txt} ${static_file}
setopt interactivecomments
setopt HIST_IGNORE_SPACE
# Clear screen by ctrl+q
bindkey '^q' clear-screen
# Bind Ctrl-W to kill-region
bindkey "^w" kill-region
bindkey -v
VI_MODE_SET_CURSOR=true
alias vim=nvim
alias sudo='sudo '
export EDITOR='nvim'
export VISUAL='nvim'
alias ls="ls --color=always"
alias cgrep="grep --color=always"
delzip() {
unzip -Z -1 "$@" | xargs -I{} rm -rf {}
}
# mitmproxy
export MITMPROXY_SSLKEYLOGFILE="~/.mitmproxy/sslkeylogfile.txt"
[[ -f ~/.zsh/.mac_config ]] && source ~/.zsh/.mac_config
if `which go &>/dev/null`; then
export PATH="$PATH:$(go env GOPATH)/bin"
export GOPATH=$(go env GOPATH)
fi
if [[ -f ~/.ssh/sudo_key ]]; then
[[ -e /tmp/sudo-agent.sock ]] || ssh-agent -a /tmp/sudo-agent.sock &> /dev/null
SSH_AUTH_SOCK=/tmp/sudo-agent.sock ssh-add -l | grep -q `ssh-keygen -lf ~/.ssh/sudo_key | awk '{print $2}'` || SSH_AUTH_SOCK=/tmp/sudo-agent.sock ssh-add ~/.ssh/sudo_key
fi
# Sudo workaround for neovim
export SUDO_ASKPASS=$(command -v ssh-askpass)
# Workaround for async issues https://github.com/romkatv/powerlevel10k/issues/1554
unset ZSH_AUTOSUGGEST_USE_ASYNC
# Powerlevel 10k
# Remove padding on right side
ZLE_RPROMPT_INDENT=0
# To customize prompt, run `p10k configure` or edit ~/dotfiles/zsh/.p10k.zsh.
function load_p10k() {
if test -f ~/dotfiles/zsh/.p10k.mac.zsh; then
source ~/dotfiles/zsh/.p10k.mac.zsh
else
[[ ! -f ~/dotfiles/zsh/.p10k.zsh ]] || source ~/dotfiles/zsh/.p10k.zsh
fi
}
load_p10k
alias screenshot_mode='powerlevel10k_plugin_unload; export PS1="$ "; python3 ~/.config/alacritty/screenshot_mode.py on'
alias screenshot_mode_off='prompt_powerlevel9k_setup; python3 ~/.config/alacritty/screenshot_mode.py off'
export LANG="en_US.UTF-8"
export LC_CTYPE="en_US.UTF-8"
export TIME_STYLE="long-iso"
antidote update &> /dev/null &|