Home Theory News Documentation Download Bio |
An environment variable can be set to a command alias by starting
it with an exclamation point. The text of the variable is then
executed every time the environment variable is evaluated. This
alleviates the need for certain "magic" environment variables, and
allows for interesting new experiments.
For example - OLDDIR is a simple environment variable, set to the path of a particular directory, which it will always refer to when expanded. CWD is an environment variable command alias, set to the "pwd" command, and will be re-evaluated every time it is used:
mpsh$ cd /tmp mpsh$ setenv OLDDIR=(pwd) mpsh$ setenv CWD="!pwd" mpsh$ echo $OLDDIR $CWD /tmp /tmp mpsh$ cd /usr mpsh$ echo $OLDDIR $CWD /tmp /usr Read the X Windows cut buffer:
mpsh$ setenv x="!xcb -p 0" Display the date in the prompt string:
mpsh$ setenv mpsh-prompt="!echo (date '+%l:%M') 'mpsh% '" Whether or not the expanded text includes newlines is controlled by the mpsh internal setting mpsh-exp-nl. It defaults to false: no newlines. Command alias variables can be displayed with the -sa or -qa option:
mpsh$ setenv -sa mpsh$ setenv -qa Environment variable command aliases are deleted with the -d option, and cleared with the -ca option:
mpsh$ setenv -d name mpsh$ setenv -ca
|