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
2022-02-07 08:03:36 +00:00
autoload -U colors && colors
2021-03-23 17:04:33 +00:00
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 #
#########################
2022-02-07 08:03:36 +00:00
RPROMPT = " %{ $fg [green]%}%~%{ $reset_color %}% "
PS1 = '%B%(?..[%?] )%b%n@%U%m%u> '
if ( ( $+IN_NIX_SHELL) ) ; then
PS1 = " ( $IN_NIX_SHELL ) $PS1 "
fi
check_nix_run( ) {
local path_copy
local -a bins
bins = ( )
path_copy = " $PATH "
while [ [ " $path_copy " = ~ '\/nix\/store\/[^/]{33}([^/]+)\/[^:]+:?' ] ] ; do
bins += " $match [1] "
path_copy = " ${ path_copy : $MEND } "
done
if [ [ " ${# bins [@] } " > 0 ] ] ; then
old_ps1 = " $PS1 "
PS1 = " ( $bins [@]) $PS1 "
in_nix_run = 1
fi
}
check_nix_run
hide_nix_run( ) {
PS1 = " $old_ps1 "
}
2021-03-23 17:04:33 +00:00
export LANG = de_DE.utf8
export LC_CTYPE = C.utf8
2022-02-07 08:03:36 +00:00
export EXA_COLORS = '*.opus=38;5;248:*.ogg=38;5;248'
2021-03-23 17:04:33 +00:00
export TIME_STYLE = long-iso
export NPM_PACKAGES = " ${ HOME } /.local/share/npm "
2022-02-07 20:29:23 +00:00
export SSH_ASKPASS_REQUIRE = 'prefer'
2022-02-07 08:03:36 +00:00
export PATH = " $HOME /.local/bin: $PATH "
2021-03-23 17:04:33 +00:00
export EDITOR = vim
alias ski = "sk --ansi -c 'rg --color=always --line-number \"{}\"'"
2022-02-07 08:03:36 +00:00
alias ls = "exa"
2021-03-23 17:04:33 +00:00
alias ls-partitions= "lsblk"
alias ls-network= "sudo ss -lntup"
alias lh = "ls -trhgGN --color=always | tr -s ' ' | cut -d' ' -f4-"
2022-02-07 08:03:36 +00:00
alias gitdots = " git --git-dir= $HOME /.local/share/dotfiles --work-tree= $HOME "
2021-03-23 17:04:33 +00:00
alias heroku = /opt/heroku/bin/heroku
alias tectonic = "tectonic -w https://ttassets.z13.web.core.windows.net/tlextras-2020.0r0.tar"
2022-02-07 08:03:36 +00:00
alias nix-build-env= "nix-shell -I nixpkgs=/home/arne/nixpkgs -p binutils pkg-config gnumake cmake llvm llvmPackages.libclang llvmPackages.clang clang glibc libgit2 ocl-icd bzip2 libsass sqlite ncurses5 alsaLib xorg.libX11 manpages"
2021-03-23 17:04:33 +00:00
alias nix-shell= "nix-shell -I nixpkgs=/home/arne/nixpkgs"
2022-02-07 08:03:36 +00:00
alias nix-zshell= "nix-shell --run zsh"
2021-03-23 17:04:33 +00:00
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'
2022-02-07 08:03:36 +00:00
export NIX_PATH = 'nixpkgs=/home/arne/nixpkgs:nixos-config=/etc/nixos/configuration.nix'
nix-run( ) {
ARGS = ( " $@ " )
nix run -I nixpkgs = /home/arne/nixpkgs ${ ARGS [@]/#/nixpkgs. } -c zsh
}
#############
# utilities #
#############
#eval "$(navi widget zsh)"
2021-03-23 17:04:33 +00:00
#############
# XDG fixes #
#############
2022-02-07 08:03:36 +00:00
#export XDG_CONFIG_HOME="$HOME/.config"
#export XDG_DATA_HOME="$HOME/.local/share"
#export XDG_CACHE_HOME="$HOME/.cache"
2021-03-23 17:04:33 +00:00
export CARGO_HOME = " $XDG_CACHE_HOME /cargo "
2022-02-07 08:03:36 +00:00
export RUSTUP_HOME = " $HOME /.local/rustup "
2021-03-23 17:04:33 +00:00
export CARGO_TARGET_DIR = " $CARGO_HOME /target "
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 "
2022-02-07 08:03:36 +00:00
alias idle = "HOME=/home/arne/.config idle3.9"
2021-03-23 17:04:33 +00:00
alias xscreensaver = " HOME= $XDG_CONFIG_HOME xscreensaver "
alias xscreensaver-demo= " HOME= $XDG_CONFIG_HOME xscreensaver-demo "
#################
# 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
}
2022-02-07 08:03:36 +00:00
files-fzf-widget( ) {
local selected
setopt localoptions noglobsubst noposixbuiltins pipefail 2> /dev/null
[ -d .git ] && echo .git || git rev-parse --git-dir > /dev/null 2>& 1
if [ ! $? -eq 0 ] ; then
return
fi
selected = ( $( git ls-files --exclude-standard | fzf --tac --preview 'bat --color=always --style=numbers --line-range=:50 {}' ) )
LBUFFER = $selected
zle redisplay
typeset -f zle-line-init >/dev/null && zle zle-line-init
return $ret
}
2021-03-23 17:04:33 +00:00
zle -N histdb-fzf-widget
2022-02-07 08:03:36 +00:00
zle -N files-fzf-widget
2021-03-23 17:04:33 +00:00
bindkey '^R' histdb-fzf-widget
2022-02-07 08:03:36 +00:00
bindkey '^T' files-fzf-widget
2021-03-23 17:04:33 +00:00
# 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'
2022-02-07 08:03:36 +00:00
git config core.sshCommand "env SSH_ASKPASS=/run/current-system/sw/bin/ksshaskpass ssh -i ~/.ssh/github_id_ed25519 -F /dev/null"
2021-03-23 17:04:33 +00:00
}
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
2022-02-07 08:03:36 +00:00
git config core.sshCommand "env SSH_ASKPASS=/run/current-system/sw/bin/ksshaskpass ssh -i ~/.ssh/gitlab_ak -F /dev/null"
2021-03-23 17:04:33 +00:00
}
function git_kit( )
{
git config --replace user.name Arne\ Keller
git config --replace user.email arne.keller@student.kit.edu
2022-02-07 08:03:36 +00:00
git config core.sshCommand "env SSH_ASKPASS=/run/current-system/sw/bin/ksshaskpass ssh -i ~/.ssh/id_newkey2021 -F /dev/null"
2021-03-23 17:04:33 +00:00
}