confirm is broken

This commit is contained in:
Christoph J. Scherr 2024-09-22 23:41:27 +02:00
parent acd2a741b1
commit e0575fce85
1 changed files with 10 additions and 8 deletions

18
.zshrc
View File

@ -46,7 +46,7 @@ alias rg="rg --no-ignore"
alias home="cd $HOME"
alias ff=firefox
alias fd=fdfind
alias shutdown="confirm shutdown"
# alias shutdown="confirm shutdown"
### Functions
function largefiles () { exec 2>/dev/null; du -ah "$@" | grep -P "^\d+(G|T|P|E)\s" }
@ -98,13 +98,14 @@ 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
bash -c "
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: $@"
@ -117,6 +118,7 @@ function confirm-important() {
fi
}
### ---- zsh options -------------------------------------
setopt autocd
setopt HIST_FIND_NO_DUPS