aboutsummaryrefslogtreecommitdiff
path: root/xtopen
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2021-06-09 20:06:41 +0200
committerJohn Ankarström <john@ankarstrom.se>2021-06-09 20:06:41 +0200
commitce7991fea8e639afefe37aae1c0158a1ecc8d4f6 (patch)
tree6cf0bd65a5cbd62cc8a521d9a088b8b49519d202 /xtopen
parent5b5aaac9b0e00ef1e4e3f538eb3b7737d722e412 (diff)
downloadxutil-ce7991fea8e639afefe37aae1c0158a1ecc8d4f6.tar.gz
xtopen: Append " (cwd)" to title of xterm window
Diffstat (limited to 'xtopen')
-rwxr-xr-xxtopen27
1 files changed, 26 insertions, 1 deletions
diff --git a/xtopen b/xtopen
index c972369..af284e4 100755
--- a/xtopen
+++ b/xtopen
@@ -1,2 +1,27 @@
#!/bin/sh
-exec xterm -title "$*" -e "$@"
+
+# xtopen -- run command in xterm
+
+abbr() {
+ case "$1" in
+ /home/$USER/*) a='~'${1#/home/$USER} ;;
+ /home/$USER) a='~' ;;
+ /home/*) a='~'${1#/home/} ;;
+ *) a=$1 ;;
+ esac
+ printf '%s\n' "$a"
+}
+
+if [ $# -eq 0 ]; then
+ xmessage -buttons sorry:0 -default sorry -nearmouse \
+ error: missing argument
+ exit 1
+fi
+
+if ! which "$1" 2>/dev/null; then
+ xmessage -default okay -nearmouse \
+ error: program "$1" not found
+ exit 1
+fi
+
+exec xterm -title "$* (`abbr "$PWD"`)" -e "$@"