Version 0 of tk dialog confirming execution of program

Updated 2014-01-28 21:09:45 by milarepa

Suppose you have an alias on you .bashrc alias shutdown="sudo shutdown -h now" and you would like to confirm the execution.

The following script executes any console, alias or gui program with an extra dialog before execution.

Usage:

tkdialog shutdown

Make sure to 'chmod +x' and put the file into you executables path like /usr/local/bin.

Here is the code:

#!/bin/wish
package require Tk
set msg ""
wm withdraw . 
bind . <Escape> {exit}
set answer [tk_messageBox -type yesno -icon question -message "Do you really want to $argv?" -parent .]
if {$answer=="yes"} { catch { exec zsh -i -c "$argv"} msg }
exit