This commit is contained in:
Christoph J. Scherr 2024-09-22 12:40:12 +02:00
parent ab2faa658b
commit acd2a741b1
1 changed files with 30 additions and 4 deletions

34
.zshrc
View File

@ -46,6 +46,7 @@ alias rg="rg --no-ignore"
alias home="cd $HOME"
alias ff=firefox
alias fd=fdfind
alias shutdown="confirm shutdown"
### Functions
function largefiles () { exec 2>/dev/null; du -ah "$@" | grep -P "^\d+(G|T|P|E)\s" }
@ -65,7 +66,7 @@ function condac() {
# calculate on shell with `c 1+1`
function c() { printf "%s\n" "$@" | bc -l; }
# Call Python and execute multiple statements from args
function py() {
function py() {
python <<< "
from math import *
@ -81,12 +82,12 @@ def evaluate_and_print(code):
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}'
}
function git-verify-commit () {
function git-verify-commit () {
git verify-commit $1
ret=$?
if [ $ret -ne 0 ]; then
@ -96,6 +97,25 @@ else
fi
return $ret
}
function confirm() {
echo "To be executed: $@"
read -p "Confirm (Y/N): " -n 1 -r
case "$REPLY" in
y|Y ) echo "es"; eval $@;;
n|N ) echo "o";;
* ) echo -e "\ninvalid";;
esac
}
function confirm-important() {
echo "Write 'yes do as i say' to confirm that you REALLY want to do this: $@"
read
if [[ "${REPLY,,}" = "yes do as i say" ]]
then
eval $@
else
echo "aborting"
fi
}
### ---- zsh options -------------------------------------
setopt autocd
@ -266,9 +286,15 @@ zstyle ':completion:*' menu select
fpath+=~/.zfunc
export NVM_DIR="$HOME/.config/nvm"
# diese Scheiße läd so ewig, wer auch immer dachte dass das so eine gute idee
# diese Scheiße läd so ewig, wer auch immer dachte dass das so eine gute idee
# ist gehört gefeuert. Das muss jeden Tag viele leute minuten kosten.
# [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
# [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
# on demand nvm
function load_nvm() {
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
}
# zprof