diff --git a/.config/zsh/.zshrc b/.config/zsh/.zshrc index 3939e69..fc398fa 100644 --- a/.config/zsh/.zshrc +++ b/.config/zsh/.zshrc @@ -8,6 +8,7 @@ autoload -Uz zmv autoload -Uz add-zsh-hook autoload -Uz compinit +autoload -U colors && colors compinit -d "$XDG_CACHE_HOME/zcompdump" zstyle ':completion:*' menu select @@ -35,50 +36,83 @@ bindkey "\e[2~" paste-clipboard # variables and aliases # ######################### -#export PS1="%n@%m:%~> " +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" +} export LANG=de_DE.utf8 export LC_CTYPE=C.utf8 +export EXA_COLORS='*.opus=38;5;248:*.ogg=38;5;248' 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 PATH="$HOME/.local/bin:$PATH" export EDITOR=vim alias ski="sk --ansi -c 'rg --color=always --line-number \"{}\"'" +alias ls="exa" 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 gitdots="git --git-dir=$HOME/.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-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" alias nix-shell="nix-shell -I nixpkgs=/home/arne/nixpkgs" +alias nix-zshell="nix-shell --run zsh" 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/ +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)" ############# # XDG fixes # ############# -export XDG_CONFIG_HOME="$HOME/.config" -export XDG_DATA_HOME="$HOME/.local/share" -export XDG_CACHE_HOME="$HOME/.cache" +#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 RUSTUP_HOME="$HOME/.local/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 idle="HOME=/home/arne/.config idle3.9" 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 # @@ -97,9 +131,24 @@ histdb-fzf-widget() { return $ret } +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 +} zle -N histdb-fzf-widget +zle -N files-fzf-widget bindkey '^R' histdb-fzf-widget +bindkey '^T' files-fzf-widget # disable default histfile HISTFILE= @@ -120,6 +169,7 @@ function git_github() { git config user.name FliegendeWurst git config user.email '2012gdwu+github@posteo.de' + git config core.sshCommand "env SSH_ASKPASS=/run/current-system/sw/bin/ksshaskpass ssh -i ~/.ssh/github_id_ed25519 -F /dev/null" } function git_github_ak() @@ -141,9 +191,11 @@ function git_gitlab_ak() git config --replace user.name Arne\ Keller git config user.email arne.keller@posteo.de git config commit.gpgsign false + git config core.sshCommand "env SSH_ASKPASS=/run/current-system/sw/bin/ksshaskpass ssh -i ~/.ssh/gitlab_ak -F /dev/null" } function git_kit() { git config --replace user.name Arne\ Keller git config --replace user.email arne.keller@student.kit.edu + git config core.sshCommand "env SSH_ASKPASS=/run/current-system/sw/bin/ksshaskpass ssh -i ~/.ssh/id_newkey2021 -F /dev/null" }