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 home="cd $HOME"
alias ff=firefox alias ff=firefox
alias fd=fdfind alias fd=fdfind
alias shutdown="confirm shutdown" # 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" }
@ -98,13 +98,14 @@ fi
return $ret return $ret
} }
function confirm() { function confirm() {
echo "To be executed: $@" bash -c "
read -p "Confirm (Y/N): " -n 1 -r echo \"To be executed: $@\";
case "$REPLY" in read -p \"Confirm (Y/N): \" -n 1 -r;
y|Y ) echo "es"; eval $@;; case \"\$REPLY\" in
n|N ) echo "o";; y|Y ) echo \"es\"; eval $@;;
* ) echo -e "\ninvalid";; n|N ) echo \"o\";;
esac * ) echo -e \"\ninvalid\";;
esac" $@
} }
function confirm-important() { function confirm-important() {
echo "Write 'yes do as i say' to confirm that you REALLY want to do this: $@" echo "Write 'yes do as i say' to confirm that you REALLY want to do this: $@"
@ -117,6 +118,7 @@ function confirm-important() {
fi fi
} }
### ---- zsh options ------------------------------------- ### ---- zsh options -------------------------------------
setopt autocd setopt autocd
setopt HIST_FIND_NO_DUPS setopt HIST_FIND_NO_DUPS