CS155 Customization
csh
reads from ~/.cshrc
bash
reads from ~/.bashrc
ksh
reads from ~/.kshrc
zsh
reads from ~/.zshrc
rc
files?
~/.cshrc
contains C-shell syntax,
~/.bashrc
contains commands in the style of bash
, etc.
bash
.
Customization usually means setting environment variables.
export var="value" export TZ="America/Denver"
Remember, all examples from now on are bash
only.
date
is often
spawned by the shell, so it’s a “child” of the shell.
To help the shell find programs in another directory, add it to the
beginning of the environment variable PATH
:
% ruler 50 /tmp/pmwiki-bash-scriptKiGwBS: line 10: ruler: command not found % echo $PATH /bin % export PATH="~/bin:$PATH" % echo $PATH ~/bin:/bin % ruler 50 12345678901234567890123456789012345678901234567890 1 2 3 4 5
Why did we use "double quotes" as opposed to 'single quotes'?
To change your interactive prompt, set the appropriate variable:
PS1="$USER> "
Why didn’t we use export
? That’s because this variable is
private to the shell, and not for the use of other programs.
To create a new command, use alias
:
% date Sun Dec 22 02:35:45 MST 2024 % alias date="echo How about a date?" % date How about a date? % unalias date % date Sun Dec 22 02:35:45 MST 2024 % alias mkx="chmod u+x" % touch zulu % ls -l zulu -rw------- 1 cs155 class 0 Dec 22 02:35 zulu % mkx zulu % ls -l zulu -rwx------ 1 cs155 class 0 Dec 22 02:35 zulu
Aliases are not self-recursive:
% touch a b c d e f g h i j k l m n o p % rm * % touch a b c d e f g h i j k l m n o p % alias rm='rm -I' % rm * rm: remove 16 arguments? y % touch x y z % rm *
rm -I
prompts if more than three files are to be removed.
% touch x % umask ugo=rwx % touch y % umask u=rwx,g=r,o= % touch z % ls -l total 0 -rw------- 1 cs155 class 0 Dec 22 02:35 x -rw-rw-rw- 1 cs155 class 0 Dec 22 02:35 y -rw-r----- 1 cs155 class 0 Dec 22 02:35 z
umask
sets the default permissions for new files.
umask ugo=rwx
umask u=rwx,go=
umask
command in ~/.bashrc
.