confirm
This commit is contained in:
parent
ab2faa658b
commit
acd2a741b1
26
.zshrc
26
.zshrc
|
@ -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" }
|
||||
|
@ -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
|
||||
|
@ -271,4 +291,10 @@ export NVM_DIR="$HOME/.config/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
|
||||
|
||||
# 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
|
||||
|
|
Loading…
Reference in New Issue