If you have a personal bin/ directory in your path (e.g. /home/user/bin,
place a shell script there with the name 'script' (same name as the binary), with the following contents:
exec /usr/bin/script # full path to your script(1) binary
Now, within script running, you can test for the environment variable SCRIPT_RUNNING, and do whatever you want based on it.
Actually, there's a far easier way. The following says it all, create three files, ~/bin/script, ~/bin/script-shell and ~/.scriptrc:
~ > ls ~/bin/script ~/bin/script-shell ~/.scriptrc
-rw-r--r-- 1 roadowl users 23 Oct 18 16:52 /home/roadowl/.scriptrc
-rwx------ 1 roadowl users 49 Oct 18 16:53 /home/roadowl/bin/script
-rwx------ 1 roadowl users 56 Oct 18 16:55 /home/roadowl/bin/script-shell
~/bin > cat script
exec /usr/bin/script -c script-shell
~/bin > cat script-shell
exec /bin/bash --rcfile /home/bjd/.scriptrc
~/bin > cat ~/.scriptrc
export PS1="[script] "
If your current shell is bash, don't forget to run
hash -r after creating these files, to ensure ~/bin/script is run when 'script' is entered as a command (check with
As before, note that you must have ~/bin in your PATH, preceding the standard path for this to work.