dotfiles/zsh/.zshrc

255 lines
6.3 KiB
Bash
Raw Normal View History

2023-11-27 23:32:20 +01:00
# zmodload zsh/zprof
# Start configuration added by Zim install {{{
#
# User configuration sourced by interactive shells
#
# -----------------
# Zsh configuration
# -----------------
#
# History
#
# Remove older command from the history if a duplicate is to be added.
setopt HIST_IGNORE_ALL_DUPS
#
# Input/output
#
# Set editor default keymap to emacs (`-e`) or vi (`-v`)
bindkey -e
# Prompt for spelling correction of commands.
#setopt CORRECT
# Customize spelling correction prompt.
#SPROMPT='zsh: correct %F{red}%R%f to %F{green}%r%f [nyae]? '
# Remove path separator from WORDCHARS.
WORDCHARS=${WORDCHARS//[\/]}
2022-03-26 23:56:09 +01:00
export ZIM_HOME=$HOME/.zim
2024-02-27 02:25:37 +01:00
# export MPD_HOST=fsi-hase.fsmi.uni-karlsruhe.de
2023-11-27 23:32:20 +01:00
# --------------------
# Module configuration
# --------------------
#
# completion
#
# Set a custom path for the completion dump file.
# If none is provided, the default ${ZDOTDIR:-${HOME}}/.zcompdump is used.
#zstyle ':zim:completion' dumpfile "${ZDOTDIR:-${HOME}}/.zcompdump-${ZSH_VERSION}"
#
# git
#
# Set a custom prefix for the generated aliases. The default prefix is 'G'.
#zstyle ':zim:git' aliases-prefix 'g'
#
# input
#
# Append `../` to your input for each `.` you type after an initial `..`
#zstyle ':zim:input' double-dot-expand yes
#
# termtitle
#
# Set a custom terminal title format using prompt expansion escape sequences.
# See http://zsh.sourceforge.net/Doc/Release/Prompt-Expansion.html#Simple-Prompt-Escapes
# If none is provided, the default '%n@%m: %~' is used.
#zstyle ':zim:termtitle' format '%1~'
#
# zsh-autosuggestions
#
# Customize the style that the suggestions are shown with.
# See https://github.com/zsh-users/zsh-autosuggestions/blob/master/README.md#suggestion-highlight-style
#ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=10'
#
# zsh-syntax-highlighting
#
# Set what highlighters will be used.
# See https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/docs/highlighters.md
ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets)
# Customize the main highlighter styles.
# See https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/docs/highlighters/main.md#how-to-tweak-it
#typeset -A ZSH_HIGHLIGHT_STYLES
#ZSH_HIGHLIGHT_STYLES[comment]='fg=10'
# ------------------
# Initialize modules
# ------------------
if [[ ! ${ZIM_HOME}/init.zsh -nt ${ZDOTDIR:-${HOME}}/.zimrc ]]; then
# Update static initialization script if it does not exist or it's outdated, before sourcing it
source ${ZIM_HOME}/zimfw.zsh init -q
fi
source ${ZIM_HOME}/init.zsh
# ------------------------------
# Post-init module configuration
# ------------------------------
#
# zsh-history-substring-search
#
# Bind ^[[A/^[[B manually so up/down works both before and after zle-line-init
bindkey '^[[A' history-substring-search-up
bindkey '^[[B' history-substring-search-down
# Bind up and down keys
zmodload -F zsh/terminfo +p:terminfo
if [[ -n ${terminfo[kcuu1]} && -n ${terminfo[kcud1]} ]]; then
bindkey ${terminfo[kcuu1]} history-substring-search-up
bindkey ${terminfo[kcud1]} history-substring-search-down
fi
bindkey '^P' history-substring-search-up
bindkey '^N' history-substring-search-down
bindkey -M vicmd 'k' history-substring-search-up
bindkey -M vicmd 'j' history-substring-search-down
# }}} End configuration added by Zim install
2023-08-18 19:26:07 +02:00
autoload compinit; compinit
autoload -U +X bashcompinit && bashcompinit
export FZF_DEFAULT_COMMAND='fd --type f'
2023-11-27 23:32:20 +01:00
source /usr/share/fzf-tab-completion/zsh/fzf-zsh-completion.sh
source /usr/share/fzf/key-bindings.zsh
2021-02-12 17:26:14 +01:00
2019-02-17 12:04:04 +01:00
alias pdfdiff="diffpdf"
2021-02-12 17:26:14 +01:00
alias cb="xclip -sel clipboard"
2021-04-08 05:39:49 +02:00
alias vi="nvim"
alias vim="nvim"
2023-11-27 23:32:20 +01:00
alias ls="eza"
alias lln="eza -l -snew --time-style relative"
2019-04-13 17:34:22 +02:00
2021-02-09 02:48:42 +01:00
# GPG for SSH
export GPG_TTY="$(tty)"
export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket)
gpgconf --launch gpg-agent
2021-02-12 17:26:14 +01:00
# Editor
2023-03-25 13:45:12 +01:00
export EDITOR=nvim
2021-02-12 17:26:14 +01:00
2021-11-18 14:41:37 +01:00
export PATH="$HOME/.jenv/bin:$PATH"
eval "$(jenv init -)"
2022-06-20 15:57:56 +02:00
eval "$(direnv hook zsh)"
2023-08-18 19:26:07 +02:00
if [[ -n "${LIGHTMODE}" ]]; then
export BAT_THEME="Solarized (light)"
fi
2022-03-16 23:36:19 +01:00
export PATH="$PATH:$HOME/.local/bin"
2022-11-02 19:15:10 +01:00
export PATH="$HOME/.bin:$PATH"
2023-03-25 13:45:12 +01:00
export PATH="${PATH}:${HOME}/.krew/bin"
2021-11-18 14:41:37 +01:00
export TERM=xterm-256color
2023-08-18 19:26:07 +02:00
export GROFF_NO_SGR=1 # man page colors in less
2022-06-01 19:09:59 +02:00
alias light="mqtt pub -t cmnd/Workbench/POWER -m "
2022-11-02 19:15:10 +01:00
alias ac="mqtt pub -t tele/Comfee/cmnd/POWER -m "
2022-06-01 19:10:21 +02:00
source /usr/share/fzf-tab-completion/zsh/fzf-zsh-completion.sh
bindkey '^I' fzf_completion
2022-06-01 19:13:02 +02:00
source =(thefuck -a)
2022-06-01 19:13:31 +02:00
source =(hcloud completion zsh)
source =(kubectl completion zsh)
source =(kubectl completion zsh | sed 's/kubectl/k/g')
alias k="kubectl"
source =(helm completion zsh)
export KUBECONFIG="$HOME/.kube/config"
2022-06-01 19:13:54 +02:00
alias gl="git lg"
alias gs="git status"
alias gd="git diff"
2022-06-20 15:57:56 +02:00
alias gds="git diff --staged"
2022-06-01 19:13:54 +02:00
alias gc="git commit"
2022-06-20 15:57:56 +02:00
alias gcf="git commit --fixup=@"
alias ga="git add"
2022-06-01 19:13:54 +02:00
alias gp="git push"
2023-03-25 13:45:12 +01:00
alias gpa="git push -o ci.variable=\"AUTO_APPLY=true\""
2022-06-20 15:57:56 +02:00
2022-08-01 20:07:27 +02:00
alias e="$EDITOR"
alias o='handlr open'
alias vs="nvim -S Session.vim"
2023-08-18 19:26:07 +02:00
alias cat='bat -p'
alias svcmail='echo "svc-$(openssl rand -hex 5)@rad4day.de"'
2023-01-17 22:59:44 +01:00
# Yes I know this is a bad idea
# also I don't care.
2023-03-25 13:45:12 +01:00
alias hugo='docker run -v "$PWD:/src" -w "/src" -u $UID:$GID -p 1313:1313 --rm klakegg/hugo:ext-alpine'
2023-01-17 22:59:44 +01:00
2022-06-23 12:13:24 +02:00
# Simple calculator
function calc() {
local result=""
result="$(printf "scale=10;$*\n" | bc --mathlib | tr -d '\\\n')"
# └─ default (when `--mathlib` is used) is 20
#
if [[ "$result" == *.* ]]; then
# improve the output for decimal numbers
printf "$result" |
sed -e 's/^\./0./' `# add "0" for cases like ".5"` \
-e 's/^-\./-0./' `# add "0" for cases like "-.5"`\
-e 's/0*$//;s/\.$//' # remove trailing zeros
else
printf "$result"
fi
printf "\n"
}
2023-11-27 23:32:20 +01:00
bindkey "^[[H" beginning-of-line # wtf why is this suddenly broken?
function ghcd() {
if [[ -d "/tmp/github/$@" ]]; then
pushd "/tmp/github/$@"
return
fi
local repo=$(gh search repos "$@" | fzf --exit-0 | cut -f1)
local repo_path="/tmp/github/${repo:t}"
[[ -z "$repo" ]] && return 1
[[ ! -d /tmp/github ]] && mkdir /tmp/github
if [[ -d "$repo_path" ]]; then
pushd "$repo_path"
return
fi
gh repo clone "$repo" "$repo_path" \
&& pushd "$repo_path"
}
2024-02-27 02:25:37 +01:00
function mpc() {
if [ "$1" = "searchinsert" ]; then
shift
SEARCH=$(mpc search "$@" | head -n1)
command mpc insert "${SEARCH}"
else
command mpc $@
fi
}
2023-11-27 23:32:20 +01:00
# zprof