diff --git a/.confirm_reboot b/.confirm_reboot deleted file mode 100644 index 848461b..0000000 --- a/.confirm_reboot +++ /dev/null @@ -1,16 +0,0 @@ -### to prevent accidental shudown, add confirm dialog to commands: -confirm() { - # call with a prompt string or use a default - read -r -p "${1:-Server: $HOST - Are you sure? [y/N]} " response - case "$response" in - [yY][eE][sS]|[yY]) - true - ;; - *) - false - ;; - esac -} -alias reboot="confirm && reboot" -alias shutdown="confirm && shutdown" -alias poweroff="confirm && poweroff" \ No newline at end of file diff --git a/.zshrc b/.zshrc index aedd6c8..4200226 100644 --- a/.zshrc +++ b/.zshrc @@ -193,5 +193,52 @@ alias geoes="sshuttle --dns -r es -x 192.189.78.0/23 -x 192.168.178.0/23 -x 128. #### Show OS Info on startup #if [ -f /usr/bin/screenfetch ]; then screenfetch; fi -### to enable confirmatoin for reboot uncomment next line -source .confirm_reboot +### to prevent accidental shudown, add confirm dialog to commands: +askreboot() { + autoload colors; colors + read -q "answ?Server: $fg[red]$HOST$reset_color - Continue (y/N)?" + if [[ "$answ" =~ ^[Yy]$ ]] + then + echo + echo "OK - Rebooting..." + sleep 2 + reboot + else + echo + echo "Canceling..." + return + fi +} +askshutdown() { + read -q "answ?Server: $fg[red]$HOST$reset_color - Continue (y/N)?" + if [[ "$answ" =~ ^[Yy]$ ]] + then + echo + echo "OK - Shutting down..." + sleep 2 + shutdown + else + echo + echo "Canceling..." + return + fi +} +askpoweroff() { + read -q "answ?Server: $fg[red]$HOST$reset_color - Continue (y/N)?" + if [[ "$answ" =~ ^[Yy]$ ]] + then + echo + echo "OK - Powering down..." + sleep 2 + poweroff + else + echo + echo "Canceling..." + return + fi +} +alias reboot="askreboot" +alias shutdown="askshutdown" +alias poweroff="askpoweroff" + + diff --git a/README.md b/README.md index 5ee9526..ed5d5d2 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,6 @@ - `git clone https://git.gc4.at/linux/nerd-fonts.git` - `cd nerd-fonts && ./install.sh` - `gem install colorls` - - Install - mkdir ~/.dotfiles - cd ~/.dotfiles @@ -43,6 +42,12 @@ - Change /`usr/bin/bash` to `/usr/bin/zsh` in `/etc/passwd` for your user - AD/Ldap User - AD/Ldap Users do no have an entry, so you need to grep it from AD/LDAP wit `getent passwd USERNAME` and then paste it into `/etc/passwd` +- Import bash history with ruby script + - `ruby ~/.dotfiles/zsh-settings/bash_to_zsh_history.rb` + +- Confirmation dialog on reboot / poweroff / shutdown + - If you want to disable the confirmation dialog for reboots / shutdowns, comment out the aliases in .zshrc + - Sources: - Check the Repos for instructions: - https://git.gc4.at/linux/nerd-fonts