Files
dotfiles/zsh/.zshrc

129 lines
4.6 KiB
Bash
Raw Normal View History

2021-10-23 17:41:05 +02:00
# 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
2021-01-11 10:35:01 +01:00
[[ -f ~/.zsh/.local_config ]] && source ~/.zsh/.local_config
2018-07-29 16:26:51 +02:00
2025-08-05 14:34:08 +02:00
update_dotfiles() {
cd ~/dotfiles || return
if git fetch --dry-run 2>&1 | grep -q .; then
git pull > /dev/null 2>&1
fi
2025-08-05 12:33:05 +02:00
}
2025-08-05 14:34:08 +02:00
update_dotfiles 2>&1 &!
2025-08-06 10:51:09 +02:00
export LC_OSC52=1
2022-09-06 13:25:54 +02:00
# Load Antidote
2022-10-06 16:36:52 +02:00
mkdir -p ${ZDOTDIR:-~}/.cache/zsh
2022-09-27 13:18:21 +02:00
static_file=${ZDOTDIR:-~}/.cache/zsh/.zsh_plugins.zsh
2022-09-06 13:25:54 +02:00
plugins_txt=${ZDOTDIR:-~}/.zsh/.zsh_plugins.txt
2022-09-06 10:50:17 +02:00
# 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
2025-08-04 11:47:52 +02:00
# Run rehash for external commands
zstyle ":completion:*:commands" rehash 1
2022-09-06 10:50:17 +02:00
# source antidote and load plugins from `${ZDOTDIR:-~}/.zsh_plugins.txt`
source ${ZDOTDIR:-~}/.antidote/antidote.zsh
2022-09-06 13:25:54 +02:00
antidote load ${plugins_txt} ${static_file}
setopt interactivecomments
2025-07-31 15:24:28 +02:00
# History options
HISTSIZE=100000 # Set the amount of lines you want saved
SAVEHIST=100000 # This is required to actually save them, needs to match with HISTSIZE
setopt EXTENDED_HISTORY # Write the history file in the ":start:elapsed;command" format.
setopt INC_APPEND_HISTORY # Write to the history file immediately, not when the shell exits.
setopt SHARE_HISTORY # Share history between all sessions.
setopt HIST_EXPIRE_DUPS_FIRST # Expire duplicate entries first when trimming history.
setopt HIST_IGNORE_DUPS # Don\'t record an entry that was just recorded again.
setopt HIST_IGNORE_ALL_DUPS # Delete old recorded entry if new entry is a duplicate.
setopt HIST_FIND_NO_DUPS # Do not display a line previously found.
setopt HIST_IGNORE_SPACE # Don\'t record an entry starting with a space.
setopt HIST_SAVE_NO_DUPS # Don\'t write duplicate entries in the history file.
setopt HIST_REDUCE_BLANKS # Remove superfluous blanks before recording entry.
2022-09-06 13:25:54 +02:00
# Clear screen by ctrl+q
bindkey '^q' clear-screen
2019-08-22 15:27:20 +02:00
2023-02-21 11:15:19 +01:00
# Bind Ctrl-W to kill-region
bindkey "^w" kill-region
2023-07-21 09:14:10 +02:00
bindkey -v
VI_MODE_SET_CURSOR=true
2023-02-21 11:15:19 +01:00
2018-07-29 16:26:51 +02:00
alias vim=nvim
2019-08-22 15:27:20 +02:00
alias sudo='sudo '
2018-07-29 16:26:51 +02:00
export EDITOR='nvim'
2023-07-21 09:14:10 +02:00
export VISUAL='nvim'
2019-02-28 13:36:24 +01:00
2019-08-22 15:27:20 +02:00
alias ls="ls --color=always"
2023-02-21 11:16:26 +01:00
alias cgrep="grep --color=always"
delzip() {
unzip -Z -1 "$@" | xargs -I{} rm -rf {}
}
# mitmproxy
export MITMPROXY_SSLKEYLOGFILE="~/.mitmproxy/sslkeylogfile.txt"
2021-10-27 14:56:12 +02:00
2024-12-22 12:29:28 +01:00
[[ -f ~/.zsh/.mac_config.zsh ]] && source ~/.zsh/.mac_config.zsh
2023-02-09 16:29:49 +01:00
if `which go &>/dev/null`; then
export PATH="$PATH:$(go env GOPATH)/bin"
export GOPATH=$(go env GOPATH)
fi
2023-10-31 11:54:49 +01:00
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
2023-07-25 13:59:37 +02:00
# 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
2024-10-07 14:31:23 +02:00
# Fixate language
export LANG="en_US.UTF-8"
export LC_CTYPE="en_US.UTF-8"
export TIME_STYLE="long-iso"
# Powerlevel 10k
# Remove padding on right side
ZLE_RPROMPT_INDENT=0
# To customize prompt, run `p10k configure` or edit ~/dotfiles/zsh/.p10k.zsh.
2023-09-03 12:55:52 +02:00
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'
antidote update &> /dev/null &|
2024-10-14 15:44:52 +02:00
# This speeds up pasting w/ autosuggest
# https://github.com/zsh-users/zsh-autosuggestions/issues/238
pasteinit() {
OLD_SELF_INSERT=${${(s.:.)widgets[self-insert]}[2,3]}
zle -N self-insert url-quote-magic # I wonder if you'd need `.url-quote-magic`?
}
pastefinish() {
zle -N self-insert $OLD_SELF_INSERT
}
zstyle :bracketed-paste-magic paste-init pasteinit
zstyle :bracketed-paste-magic paste-finish pastefinish
2024-10-14 15:54:28 +02:00
# https://github.com/zsh-users/zsh-autosuggestions/issues/351
ZSH_AUTOSUGGEST_CLEAR_WIDGETS+=(bracketed-paste)