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 home="cd $HOME"
alias ff=firefox alias ff=firefox
alias fd=fdfind alias fd=fdfind
alias shutdown="confirm shutdown"
### Functions ### Functions
function largefiles () { exec 2>/dev/null; du -ah "$@" | grep -P "^\d+(G|T|P|E)\s" } 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` # calculate on shell with `c 1+1`
function c() { printf "%s\n" "$@" | bc -l; } function c() { printf "%s\n" "$@" | bc -l; }
# Call Python and execute multiple statements from args # Call Python and execute multiple statements from args
function py() { function py() {
python <<< " python <<< "
from math import * from math import *
@ -81,12 +82,12 @@ def evaluate_and_print(code):
if __name__ == \"__main__\": if __name__ == \"__main__\":
expr = '$*' expr = '$*'
evaluate_and_print(expr) evaluate_and_print(expr)
" "
} }
function countlines() { function countlines() {
find . -type f -name "$1" -exec wc -l {} \; | awk '{print $0} {total += $1} END {print "Total lines:", total}' 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 git verify-commit $1
ret=$? ret=$?
if [ $ret -ne 0 ]; then if [ $ret -ne 0 ]; then
@ -96,6 +97,25 @@ else
fi fi
return $ret 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 ------------------------------------- ### ---- zsh options -------------------------------------
setopt autocd setopt autocd
@ -266,9 +286,15 @@ zstyle ':completion:*' menu select
fpath+=~/.zfunc fpath+=~/.zfunc
export NVM_DIR="$HOME/.config/nvm" 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. # 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/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
# [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion # [ -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 # zprof