zshrc from work

This commit is contained in:
Christoph J. Scherr 2024-07-26 17:52:01 +02:00
parent b737c6a9cb
commit 77aa12bf56
1 changed files with 43 additions and 17 deletions

60
.zshrc
View File

@ -60,8 +60,28 @@ function condac() {
}
# calculate on shell with `c 1+1`
function c() { printf "%s\n" "$@" | bc -l; }
# call python in a print from args
function py() { python -c "from math import *; print($*)" }
# Call Python and execute multiple statements from args
function py() {
python <<< "
from math import *
def evaluate_and_print(code):
for expr in code.split(';'):
expr = expr.strip()
if '=' in expr:
exec(expr)
else:
result = eval(expr)
print(f\"{expr} => {result}\")
if __name__ == \"__main__\":
expr = '$*'
evaluate_and_print(expr)
"
}
function countlines() {
find . -type f -name "$1" -exec wc -l {} \; | awk '{print $0} {total += $1} END {print "Total lines:", total}'
}
### ---- zsh options -------------------------------------
setopt autocd
@ -89,14 +109,6 @@ setopt hist_ignore_dups # ignore duplicated commands history list
setopt hist_ignore_space # ignore commands that start with space
setopt hist_verify # show command with history expansion to user before running it
### load unversioned zsh code
if [ -f ~/.zsh.local ]; then
source ~/.zsh.local
else
touch ~/.zsh.local
fi
### --- Inputs Config ------------------------------------
# vim keys, then override stuff.
bindkey -v
@ -188,11 +200,16 @@ fpath=($ZSH/plugins/zsh-completions/src $fpath)
ZAQ_PREFIXES+=('git commit( [^ ]##)# -[^ -]#m')
ZAQ_PREFIXES_GREEDY+=('py #')
ZAQ_PREFIXES_GREEDY+=('countlines #')
### --- fzf Config ------------------------------------
export FZF_CTRL_T_OPTS="--preview '(highlight -O ansi -l {} 2> /dev/null || cat {} || tree -C {}) 2> /dev/null | head -200'"
export FZF_CTRL_R_OPTS='--no-sort --exact'
### --- nnn Config ------------------------------------
source ~/.local/share/nnn/quitcd/quitcd.bash_zsh
export NNN_PLUG='j:jump;z:autojump;'
### --- kitty Config ------------------------------------
# $KITTY_TERM is a custom envar I set in the kitty conf
# this stuff does not work nicely with tmux, just make them regular aliases. Shows an error if you use them in another terminal
@ -215,11 +232,20 @@ else
eval "$(zoxide init zsh)"
fi
### --- pyenv Config -------------------------------------
if [ -d $HOME/.pyenv ]; then
export PYENV_ROOT="$HOME/.pyenv"
[[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init - zsh)"
pyenv activate std 2> /dev/null > /dev/null
### load unversioned zsh code
if [ -f ~/.zsh.local ]; then
source ~/.zsh.local
else
touch ~/.zsh.local
fi
### --- pyenv Config -------------------------------------
export PYENV_ROOT="$HOME/.pyenv"
[[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init - zsh)"
. "$HOME/.cargo/env"
zstyle ':completion:*' menu select
fpath+=~/.zfunc