Skip to content

Shell Tips & Tricks

kekkoudesu edited this page Jul 10, 2023 · 1 revision

Shell Functions For Quick Access

When WINE installs menu items for an app, they automatically point to the right wineprefix, which is great. But if you're a commandline user, what you really want is a convenient way to access those wineprefixes from the commandline.

Here's one way—add these three shell functions to your ~/.bashrc:

prefix() { export WINEPREFIX="$HOME/.local/share/wineprefixes/$1" }

goc() { cd $WINEPREFIX/drive_c }

lsp() { ls $* $HOME/.local/share/wineprefixes }

Those let you select or go to any wineprefix, or list them all.

You can export a wineprefix in ~/.local/share/wineprefixes with prefix and then go to it with goc:

prefix vn32
goc

You might also find this one handy; it relies on the fact that most winetricks verbs that install apps also install batch files to start those apps:

run() { prefix $1 goc wine cmd /c run-$1.bat }

Although there's probably a better way to do that.

Shell Scripting

Adding New Verbs shows you, step by step, how to create your first Winetricks verb.

You can get a lot done without knowing much of the syntax of the Unix shell, but at some point, you'll need to start learning it. Here are a few resources that might help you get started.

Tutorials

  • "An Introduction to the Unix Shell", S. R. Bourne, 1978 (PDF, HTML) - is a simple introduction to the fundamentals. The language was simpler then, but it's still worth reading.
  • "Portable Shell Programming" by Bruce Blinn. Excellent, slim book. Worth buying used, you should be able to get it for $10

Reference