#!/bin/sh # see also run.sh # note one can do openrun sh -c 'echo $SHELL' # # To open an rxvt in a given directory: # $ openrun cd /path # # To open an rxvt in a dir and run a program there, then have interactivity, # use: # $ (cd /path; openrun command) # # But, if you need this to be as one command for a window manager shortcut, it # might be better to use cdrun: # $ cdrun openrun command args ... directory WINPROG=/usr/bin/rxvt showhelp () { cat << EOF Usage: $0 [-d directory | -p directory] command args ..." Opens an rxvt, runs command with the given args in it, then execs a shell in the same window. If -d is specified, change to the given directory first. If -p is specified, try to ensure the directory exists by attempting to recursively create it if it doesn't, then cd to that directory first. EOF } case $1 in -h ) showhelp ; exit ;; -d|-p ) opt=$1 ; DIR="$2" if [ -z "$DIR" ]; then echo "$0: -d requires a directory argument." showhelp exit 2 fi # Try to create the dir if -p used if [ x$opt = x-p ]; then mkdir -p "$DIR" fi if [ ! -d "$DIR" ]; then echo "$0: directory $DIR does not exist" exit 1 fi cd "$DIR" shift ; shift ;; esac # $WINPROG -e sh -c $1' "$@"; exec $SHELL' "$@" if [ $# -gt 0 ]; then exec $WINPROG -e run.sh "$@" else exec $WINPROG fi