mirror of
https://github.com/notwa/rc
synced 2025-02-04 23:33:23 -08:00
use recombine
for all shells
This commit is contained in:
parent
474a42f658
commit
5299f0725f
4 changed files with 13 additions and 36 deletions
13
home/bashrc
13
home/bashrc
|
@ -36,20 +36,9 @@ _temporary_scope_() {
|
|||
PROMPT_COMMAND="[ \$? = 0 ] && PS1=\$'$ret_okay' || PS1=\$'$ret_fail'"
|
||||
}; _temporary_scope_; unset -f _temporary_scope_
|
||||
|
||||
. ~/.shrc
|
||||
|
||||
#ADDPATH "$HOME/sh" # this doesn't work for all scripts at the moment
|
||||
dummy() { :; } ### @- return 0, ignoring arguments.
|
||||
|
||||
# combine everything matching "YES_BASH" in ~/sh/ into ~/.sh-bash.
|
||||
# unlike zsh, we do not check the sha1sum of the output.
|
||||
if [ -s ~/sh/recombine ] && (. ~/sh/recombine) > ~/.sh-bash; then
|
||||
preload=dummy
|
||||
. ~/.sh-bash
|
||||
unset preload
|
||||
elif [ -f ~/.sh-bash ]; then
|
||||
rm ~/.sh-bash
|
||||
fi
|
||||
. ~/.shrc
|
||||
|
||||
alias reload='cd; exec bash' ### @- **TODO:** respect initctl like in `.zshrc`.
|
||||
[ ! -e ~/.lol ] || . ~/.lol
|
||||
|
|
|
@ -4,6 +4,14 @@
|
|||
unset FANCY; _=: && [ -z $_ ] && FANCY=1 || FANCY=0 # detect zsh and bash
|
||||
if [ "$FANCY" = 0 ]; then . ~/.prep; fi # handle stuff like /etc/profile and $PATH
|
||||
|
||||
# combine everything matching "YES_MYSHELL" in ~/sh/ into ~/.sh-myshell.
|
||||
[ -z "${0##/*}" ] && sh=zsh || sh="$0" # zsh replaces $0, so hardcode it
|
||||
if [ -s ~/sh/recombine ] && (. ~/sh/recombine) > ~/.sh-"$sh"; then
|
||||
preload=:; . ~/.sh-"$sh"; unset preload
|
||||
elif [ -f ~/.sh-"$sh" ]; then
|
||||
rm ~/.sh-"$sh"
|
||||
fi
|
||||
|
||||
# {{{1 utilities
|
||||
|
||||
have() { if [ -z "$ZSH_VERSION" ]; then which -- "$1"; else whence -p -- "$1"; fi; } 2>/dev/null
|
||||
|
|
21
home/zshrc
21
home/zshrc
|
@ -61,28 +61,7 @@ autoload edit-command-line
|
|||
autoload history-search-end
|
||||
zmodload zsh/mathfunc
|
||||
|
||||
# combine everything matching "YES_ZSH" in ~/sh/ into ~/.sh,
|
||||
# but only recompile the output if the sha1sum has changed.
|
||||
function
|
||||
{: \
|
||||
&& local a= b= \
|
||||
&& { [ ! -s ~/.sh.sha1 ] || read -r b _ < ~/.sh.sha1 ;} \
|
||||
&& (: \
|
||||
&& cd ~/sh \
|
||||
&& print -l '#!/usr/bin/env false' '[ -n "$preload" ] || exit 1' '' \
|
||||
| cat - $(grep -lF YES_ZSH -- *~*.bak(.)) \
|
||||
| tee ~/.sh \
|
||||
;) \
|
||||
| sha1sum - \
|
||||
| tee ~/.sh.sha1 \
|
||||
| read -r a _ \
|
||||
&& { [ "$a" = "$b" ] && touch ~/.sh.zwc || zrecompile -p ~/.sh ;} \
|
||||
;}
|
||||
|
||||
dummy() : ### @- return 0, ignoring arguments.
|
||||
preload=dummy
|
||||
. ~/.sh
|
||||
unset preload
|
||||
|
||||
dirprev() { ### @-
|
||||
### rotate and change to the previous directory in the directory stack
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
# FAKE_COMPAT
|
||||
|
||||
cd ~/sh && unset IFS || exit
|
||||
case "$0" in
|
||||
[ -z "${0##/*}" ] && sh=zsh || sh="$0" # zsh replaces $0, so hardcode it
|
||||
case "$sh" in
|
||||
(ash) SH=ASH;;
|
||||
(bash) SH=BASH;;
|
||||
(dash) SH=DASH;;
|
||||
|
@ -14,10 +15,10 @@ case "$0" in
|
|||
(osh) SH=OSH;;
|
||||
(posh) SH=POSH;;
|
||||
(yash) SH=YASH;;
|
||||
(zsh) SH=ZSH;;
|
||||
(zsh) SH=ZSH; set -o SH_WORD_SPLIT;;
|
||||
(*)
|
||||
printf >&2 %s\\n "unknown shell (\$0): $0"
|
||||
return 1
|
||||
exit 1
|
||||
esac
|
||||
|
||||
printf %s\\n '#!/usr/bin/env false' '[ -n "$preload" ] || exit 1' ''
|
||||
|
|
Loading…
Add table
Reference in a new issue