aboutsummaryrefslogtreecommitdiff
path: root/xtopen
blob: af284e4fe129b9548931e6dfa1121725aacbac11 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/bin/sh

# 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 "$@"