summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--01_Internal.zsh5
-rw-r--r--user:hugues/KeyBindings.zsh8
2 files changed, 12 insertions, 1 deletions
diff --git a/01_Internal.zsh b/01_Internal.zsh
index 8624ede..df9731e 100644
--- a/01_Internal.zsh
+++ b/01_Internal.zsh
@@ -631,3 +631,8 @@ _process_tree()
done
}
+# Asks confirmation before executing parameters
+confirm() {
+ read -q "?Are you sure? " && $@
+}
+
diff --git a/user:hugues/KeyBindings.zsh b/user:hugues/KeyBindings.zsh
index fb241f4..1c4a693 100644
--- a/user:hugues/KeyBindings.zsh
+++ b/user:hugues/KeyBindings.zsh
@@ -164,9 +164,15 @@ bindkey -v
# This setup may change the `ESC' keybinding to `C-d'. That defeats the
# possibility to exit zsh by pressing `C-d' (which usually sends EOF).
# With this widget, you can type `:q<RET>' to exit the shell from vicmd.
+if [ $( _process_tree | grep -o zsh | wc -l ) -gt 1 ]
+then
+ CONFIRM_EXIT=""
+else
+ CONFIRM_EXIT="confirm "
+fi
function ft-zshexit {
[[ -o hist_ignore_space ]] && BUFFER=' '
- BUFFER="${BUFFER}exit"
+ BUFFER="${BUFFER}${CONFIRM_EXIT}exit"
zle .accept-line
}
zle -N q ft-zshexit