Annoyingly, the native-Linux rc(1) port doesn't accept the same syntax
as Plan 9 From User Space.
* Plan 9 requires braces around command substitutions, so `{hostname}
rather than `hostname.
* Plan 9 doesn't have here-strings, so use echo instead.
* Plan 9 is pickier about concatenating unset variables, so set them
empty explicitly.
* Plan 9 has a bizarre `if not' syntax rather than allowing `else'
clauses.
This last is the most annoying difference, since the only thing
acceptable to both implementations is to repeat the condition.
Prefer the Plan 9 version throughout, and seddery the script to make the
native port version. Fortunately they end up in different places;
otherwise we'd be really stuffed.
## Shells.
DOTLINKS += .profile .shell-rc .shell-logout
## Shells.
DOTLINKS += .profile .shell-rc .shell-logout
DOTLINKS += .zprofile .zshrc .zlogout .zshenv
DOTLINKS += .bash_profile .bash_completion .bash_logout
DOTLINKS += .bashrc .inputrc
DOTLINKS += .zprofile .zshrc .zlogout .zshenv
DOTLINKS += .bash_profile .bash_completion .bash_logout
DOTLINKS += .bashrc .inputrc
.bash_logout_SRC = shell-logout
.zlogout_SRC = shell-logout
.bash_logout_SRC = shell-logout
.zlogout_SRC = shell-logout
+## The Plan 9 `rc' shell. This needs special hacking, because the Linux port
+## and Plan 9 From User Space have incompatible syntax.
+DOTLINKS += lib/profile
+lib/profile_SRC = rcrc
+all:: $(HOME)/.rcrc
+$(HOME)/.rcrc: dot/rcrc
+ $(call v_tag,SED)sed 's/; if not/else/' $< >$@.new && mv $@.new $@
+
## Git.
DOTSUBST += .gitconfig
SCRIPTLINKS += git-copyright-dates
## Git.
DOTSUBST += .gitconfig
SCRIPTLINKS += git-copyright-dates
###--------------------------------------------------------------------------
### Prompt machinery.
###--------------------------------------------------------------------------
### Prompt machinery.
if (~ $TERM linux* screen* xterm* vt100* eterm*) {
bold = `{tput bold} unbold = `{tput sgr0}
if (~ $TERM linux* screen* xterm* vt100* eterm*) {
bold = `{tput bold} unbold = `{tput sgr0}
bold = '' unbold = ''
}
if (~ `{id -u} 0) {
bold = '' unbold = ''
}
if (~ `{id -u} 0) {
- left = `{iconv -f utf8 -t //translit <<< «}
- right = `{iconv -f utf8 -t //translit <<< »}
-} else {
+ left = `{echo « | iconv -f utf8 -t //translit}
+ right = `{echo » | iconv -f utf8 -t //translit}
+}; if not {
u = `{id -un}
if (~ $u mdw mwooding) {
u = '' left = '[' right = ']'
u = `{id -un}
if (~ $u mdw mwooding) {
u = '' left = '[' right = ']'
u = $u^@ left = '{' right = '}'
}
u = $u^@ left = '{' right = '}'
}
- if (~ $__mdw_tty `tty) {
+ if (~ $__mdw_tty `{tty}) {
- } else {
- __mdw_tty = `tty
+ }; if not {
+ __mdw_tty = `{tty}
}
}
if (~ $#SSH_CLIENT 0 && ! ~ $__mdw_sechost $host) {
sec_l = '(' sec_r = ')'
}
}
if (~ $#SSH_CLIENT 0 && ! ~ $__mdw_sechost $host) {
sec_l = '(' sec_r = ')'
+}; if not {
+ sec_l = '' sec_r = ''
if (~ $cwd $home $home/*) {
if (~ $cwd $home $home/*) {
- cwd = `{sed 's:^' ^ $home ^':~:' <<< $cwd}
+ cwd = `{echo $cwd | sed 's:^' ^ $home ^':~:'}
}
prompt = ($bold$left$sec_l$u$host$sec_r^' '^$cwd$right$unbold '')
}
}
prompt = ($bold$left$sec_l$u$host$sec_r^' '^$cwd$right$unbold '')
}
###--------------------------------------------------------------------------
### Convenient aliases.
###--------------------------------------------------------------------------
### Convenient aliases.
fn ls {
if (test -t 1) {
builtin ls $LS_OPTIONS '--color=auto' $*
fn ls {
if (test -t 1) {
builtin ls $LS_OPTIONS '--color=auto' $*
grep = $1; shift
if (test -t 1) {
builtin $grep '--color=always' $* | mdw-pager
grep = $1; shift
if (test -t 1) {
builtin $grep '--color=always' $* | mdw-pager