dotfiles/.config/zsh/.zshrc

150 lines
4.7 KiB
Bash
Raw Normal View History

2021-03-23 17:04:33 +00:00
###############
# shell setup #
###############
# uncomment to get profiling data with zprof
#zmodload zsh/zprof
autoload -Uz zmv
autoload -Uz add-zsh-hook
autoload -Uz compinit
compinit -d "$XDG_CACHE_HOME/zcompdump"
zstyle ':completion:*' menu select
eval "$(zoxide init zsh)"
bindkey -e
bindkey "\e[1~" beginning-of-line
# ctrl+arrow keys
bindkey "^[[1;5D" backward-word
bindkey "^[[1;5C" forward-word
bindkey "\e[4~" end-of-line
bindkey "\e[3~" delete-char
# ctrl+backspace
bindkey '^H' backward-kill-word
# F9: duplicate last argument
bindkey -s "\e[20~" "!#\$^I"
paste-clipboard () {
LBUFFER+="$(xclip -sel clip -o)"
}
zle -N paste-clipboard
bindkey "\e[2~" paste-clipboard
#########################
# variables and aliases #
#########################
#export PS1="%n@%m:%~> "
export LANG=de_DE.utf8
export LC_CTYPE=C.utf8
export TIME_STYLE=long-iso
export NPM_PACKAGES="${HOME}/.local/share/npm"
export PATH="$HOME/.local/bin/git-fuzzy/bin:$HOME/.local/bin:$HOME/.cache/cargo/bin:$PATH:$HOME/.local/share/npm/bin"
export EDITOR=vim
alias ski="sk --ansi -c 'rg --color=always --line-number \"{}\"'"
alias ls-partitions="lsblk"
alias ls-network="sudo ss -lntup"
alias lh="ls -trhgGN --color=always | tr -s ' ' | cut -d' ' -f4-"
alias gitdots="git --git-dir=./.local/share/dotfiles --work-tree=$HOME"
alias heroku=/opt/heroku/bin/heroku
alias tectonic="tectonic -w https://ttassets.z13.web.core.windows.net/tlextras-2020.0r0.tar"
alias nix-build-env="nix-shell -I nixpkgs=/home/arne/nixpkgs -p binutils pkg-config gnumake cmake gcc llvm llvmPackages.libclang llvmPackages.clang clang qt515.qmake glibc libgit2 ocl-icd openssl bzip2 libsass sqlite ncurses5 alsaLib xorg.libX11 manpages --run"
alias nix-shell="nix-shell -I nixpkgs=/home/arne/nixpkgs"
alias add="git fuzzy status"
alias rga-pdf='rga --rga-adapters=poppler'
alias java-jacoco='java -javaagent:$HOME/.cache/m2/repository/org/jacoco/org.jacoco.agent/0.8.6/org.jacoco.agent-0.8.6-runtime.jar=port=36320,destfile=jacoco-it.exec,output=tcpserver'
export GIT_ASKPASS='/run/current-system/sw/bin/ksshaskpass'
export AFL_DIR=/nix/store/1gcd7pcpp5bqkqy94y9py14w7bl6ps5y-afl-2.57b/bin/
#############
# XDG fixes #
#############
export XDG_CONFIG_HOME="$HOME/.config"
export XDG_DATA_HOME="$HOME/.local/share"
export XDG_CACHE_HOME="$HOME/.cache"
export CARGO_HOME="$XDG_CACHE_HOME/cargo"
export RUSTUP_HOME="$XDG_CACHE_HOME/rustup"
export CARGO_TARGET_DIR="$CARGO_HOME/target"
export MATHEMATICA_USERBASE="$XDG_CACHE_HOME/mathematica"
export SQLITE_HISTORY="$XDG_DATA_HOME/sqlite_history"
export WINEPREFIX="$XDG_CACHE_HOME/wine"
export VIMINIT="set nocp | source ${XDG_CONFIG_HOME:-$HOME/.config}/vim/vimrc"
alias mvn="env HOME=$XDG_CACHE_HOME mvn --global-settings /home/arne/.config/maven/settings.xml -Dmaven.repo.local=$XDG_CACHE_HOME/m2/repository -Duser.home=$XDG_CACHE_HOME"
alias idle="HOME=/home/arne/.config idle3.8"
alias xscreensaver="HOME=$XDG_CONFIG_HOME xscreensaver"
alias xscreensaver-demo="HOME=$XDG_CONFIG_HOME xscreensaver-demo"
alias codium="HOME=$XDG_CACHE_HOME codium"
alias bitcoin-qt="HOME=$XDG_DATA_HOME bitcoin-qt"
#################
# history setup #
#################
source $HOME/.local/bin/zsh-histdb/sqlite-history.zsh
histdb-fzf-widget() {
local selected num
setopt localoptions noglobsubst noposixbuiltins pipefail 2> /dev/null
selected=( $(histdb --sep 999 | awk -F'999' '{print $4}' | tac | awk '!seen[$0]++' | tac |
FZF_DEFAULT_OPTS="--tac --height ${FZF_TMUX_HEIGHT:-40%} $FZF_DEFAULT_OPTS -n2..,.. --tiebreak=index --bind=ctrl-r:toggle-sort $FZF_CTRL_R_OPTS --query=${(qqq)LBUFFER} +m" fzf) )
LBUFFER=$selected
zle redisplay
typeset -f zle-line-init >/dev/null && zle zle-line-init
return $ret
}
zle -N histdb-fzf-widget
bindkey '^R' histdb-fzf-widget
# disable default histfile
HISTFILE=
SAVEHIST=0
HISTSIZE=1000
unsetopt SHARE_HISTORY # don't share history between sessions
setopt HIST_IGNORE_SPACE
function mouse_around_rand {
while true; do
sleep "$1"
xdotool mousemove_relative -- $(($RANDOM % 10)) $(($RANDOM % 10))
xdotool mousemove_relative -- -$(($RANDOM % 10)) -$(($RANDOM % 10))
done
}
function git_github()
{
git config user.name FliegendeWurst
git config user.email '2012gdwu+github@posteo.de'
}
function git_github_ak()
{
git config user.name arnek01
git config user.email 2012gdwu@posteo.de
git config commit.gpgsign false
}
function git_ak()
{
git config --replace user.name Arne\ Keller
git config --replace user.email arne.keller@posteo.de
git config commit.gpgsign false
}
function git_gitlab_ak()
{
git config --replace user.name Arne\ Keller
git config user.email arne.keller@posteo.de
git config commit.gpgsign false
}
function git_kit()
{
git config --replace user.name Arne\ Keller
git config --replace user.email arne.keller@student.kit.edu
}