Skip to content

Instantly share code, notes, and snippets.

@paulmr
Created October 4, 2018 08:29
Show Gist options
  • Save paulmr/c7dfb85666d6f3d13ce0914e3ce033a3 to your computer and use it in GitHub Desktop.
Save paulmr/c7dfb85666d6f3d13ce0914e3ce033a3 to your computer and use it in GitHub Desktop.
simple (fish) shell script to execute a command via an X dialog box
#!/bin/fish
set -l histfile ~/.x-shell-command-history
set -l lastcmd ""
if test -f $histfile
set lastcmd (cat $histfile)
end
if set -l command (zenity --entry --entry-text="$lastcmd" --text="Command to execute:" --title="x-shell-command")
set -l output (eval $command)
if test $status -eq 0
if test -n "$output"
zenity --info --text="$output"
end
else
zenity --error --text="$output"
end
echo "$command" >$histfile
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment