#!/bin/sh # # usage: # # wp # - list prefixes in ~/wp/ # # wp prefix # - if ~/wp/prefix exists, child shell into it and set WINEPREFIX # - otherwise, prompt to create the given prefix and # then do as above if new prefix was created # - child shell is bash and you can get out of it via the # usual means (^D, exit) # - PS1 is set to reflect the choice of prefix # # NOTE: the script sets WINEARCH to win32. Hack around it # if you play new games. q() { echo $@ exit 1 } list() { ls ~/wp/|cat exit 0 } [ $# == 1 ] || list if [ ! -e "$HOME/wp/$1" ]; then echo -n 'Create new prefix? [Y/n] ' read ans case "$ans" in y) ;; Y) ;; n) q "cancel" ;; N) q "cancel" ;; "") ;; *) q "cancel" ;; esac fi TEMPFILE=`mktemp` { printf '. ~/.bashrc\n' printf 'WINEPREFIX=%s/wp/%s\n' "$HOME" "$1" printf 'WINEARCH=win32\n' printf 'PS1="wp/%s \\W> "\n' "$1" printf 'export WINEPREFIX WINEARCH\n' printf 'wineboot -i\n' printf 'if [ ! $? ]; then\n' printf ' echo wineboot failed\n' printf ' exit 1\n' printf 'fi\n' printf 'cd "$WINEPREFIX"' } >> $TEMPFILE bash --rcfile $TEMPFILE rm -f "$TEMPFILE"