Here's a short script that I use a lot. To make a new shell script executable, for example, I type:
%cx scriptfile
Using cw adds write permission; c-w takes it away. This is the single script file for all three commands:
#! /bin/sh case "$0" in *cx) chmod +x "$@" ;; *cw) chmod +w "$@" ;; *c-w) chmod -w "$@" ;; *) echo "$0: Help! Shouldn't get here!" 1>&2; exit 1 ;; esac
The script has three links. Put it in a file named cx. Then type:
%chmod +x cx
%ln cx cw
%ln cx c-w
The script tests the name it was called with, in $0
, to decide
which chmod command to run.
This trick saves disk space.
You can add other commands, too, by adding a line to the case
and another link.
Or
you can use aliases (22.9).
-