1
0
Fork 0
mirror of https://github.com/notwa/rc synced 2024-05-07 13:53:23 -07:00

Compare commits

...

13 Commits

Author SHA1 Message Date
Connor Olding a9f8dd642c regenerate readme 2021-10-29 15:46:21 +02:00
Connor Olding a2ae5a212d rename ~/.-shrc to ~/.shrc
the reason for the hyphen is that i was originally concerned
about random shells executing the file when i didn't want them to.
back then, i was only targetting zsh and bash, and therefore
`~/.-shrc` was not yet suitable for any other shells.
nowadays, `~/.-shrc` is has better shell compatibility,
and i'm not actually aware of any shells that would execute
`~/.shrc` by default -- `$ENV` is typically required to be set.
2021-10-29 15:44:31 +02:00
Connor Olding 23e3e74387 regenerate readme 2021-10-29 15:14:36 +02:00
Connor Olding a7a62695f9 add a Colour command to load GUI colorschemes nicely 2021-10-29 15:07:29 +02:00
Connor Olding cf51cc62b0 add ~/.prep to do tasks like /etc/profile 2021-10-29 15:04:47 +02:00
Connor Olding 665ebfc9f7 use FAKE_COMPAT on document script 2021-10-29 15:03:02 +02:00
Connor Olding c501458371 experiment without search wraparound in tmux 2021-10-29 12:27:23 +02:00
Connor Olding 00064c6f89 ignore CVS directores in decently 2021-10-29 12:25:12 +02:00
Connor Olding 0fe48b0526 superficial indentation change 2021-10-29 12:24:44 +02:00
Connor Olding 74feaab252 add a couple aliases that i might rename later 2021-10-29 12:23:23 +02:00
Connor Olding cb7428f4cd allow tmux in terminals that don't use pseudo-ttys 2021-10-29 12:23:07 +02:00
Connor Olding a78187b435 add another script to dump colors in a different order 2021-10-22 18:27:21 +02:00
Connor Olding 2fb9bbe24f add some scripts that act on shell variables
these are kinda experimental.
2021-10-22 18:25:33 +02:00
16 changed files with 270 additions and 86 deletions

142
README.md
View File

@ -190,7 +190,7 @@ defaults to clang, gcc, and msvc in that order.
# debug build # debug build
compile rd.c compile rd.c
compile debug rd.c compile debug rd.c
# debug build with warning/error flags defined in .-shrc # debug build with warning/error flags defined in ~/sh/arrays
# (requires .zshrc for global alias expansion) # (requires .zshrc for global alias expansion)
compile WHOA rd.c compile WHOA rd.c
# likewise for C++ # likewise for C++
@ -284,7 +284,7 @@ Filesystem Used Max Left Misc
find files in system directories that aren't associated with any pacman packages. find files in system directories that aren't associated with any pacman packages.
### [document](/sh/document#L150) ### [document](/sh/document#L146)
generate a markdown file out of docstrings in shell scripts. generate a markdown file out of docstrings in shell scripts.
@ -799,6 +799,14 @@ extract the contents of an archive file in one of many formats.
borrowed from [prezto.](https://github.com/sorin-ionescu/prezto) borrowed from [prezto.](https://github.com/sorin-ionescu/prezto)
### [v_lower](/sh/v_lower#L7)
transform the contents of a variable to lowercase.
### [v_upper](/sh/v_upper#L7)
transform the contents of a variable to uppercase.
### [wat](/sh/wat#L9) ### [wat](/sh/wat#L9)
wat — a better and recursive which/whence. for zsh only. wat — a better and recursive which/whence. for zsh only.
@ -830,272 +838,272 @@ $ xxp ~/rc/install | head -n2
## miscellaneous ## miscellaneous
### [dummy (zshrc)](/home/zshrc#L69) ### [dummy (zshrc)](/home/zshrc#L76)
return 0, ignoring arguments. return 0, ignoring arguments.
### [dirprev (zshrc)](/home/zshrc#L74) ### [dirprev (zshrc)](/home/zshrc#L81)
rotate and change to the previous directory in the directory stack rotate and change to the previous directory in the directory stack
without consuming the prompt. without consuming the prompt.
### [dirnext (zshrc)](/home/zshrc#L81) ### [dirnext (zshrc)](/home/zshrc#L88)
rotate and change to the next directory in the directory stack rotate and change to the next directory in the directory stack
without consuming the prompt. without consuming the prompt.
### [dirup (zshrc)](/home/zshrc#L88) ### [dirup (zshrc)](/home/zshrc#L95)
change to the parent directory of the current working directory change to the parent directory of the current working directory
without consuming the prompt. without consuming the prompt.
### [dirview (zshrc)](/home/zshrc#L95) ### [dirview (zshrc)](/home/zshrc#L102)
use a fuzzy finder to select a recent directory in the directory stack use a fuzzy finder to select a recent directory in the directory stack
and change to it without consuming the prompt. and change to it without consuming the prompt.
### [OMFG (zshrc)](/home/zshrc#L193) ### [OMFG (zshrc)](/home/zshrc#L200)
silence stdout. silence stdout.
### [STFU (zshrc)](/home/zshrc#L194) ### [STFU (zshrc)](/home/zshrc#L201)
silence stderr. silence stderr.
### [WHOA (zshrc)](/home/zshrc#L195) ### [WHOA (zshrc)](/home/zshrc#L202)
expand to several C/C++ flags to ease development. expand to several C/C++ flags to ease development.
### [WELP (zshrc)](/home/zshrc#L196) ### [WELP (zshrc)](/home/zshrc#L203)
expand to C++ flags to enable a C++-as-C facade. expand to C++ flags to enable a C++-as-C facade.
### [tw (zshrc)](/home/zshrc#L201) ### [tw (zshrc)](/home/zshrc#L208)
invoke `twitch` as a job with both stdout and stderr silenced. invoke `twitch` as a job with both stdout and stderr silenced.
### [reload (zshrc)](/home/zshrc#L245) ### [reload (zshrc)](/home/zshrc#L252)
reload zsh by wiping temp files, recompiling rc files, reload zsh by wiping temp files, recompiling rc files,
and replacing the current process with a new zsh process. and replacing the current process with a new zsh process.
### [dummy (bashrc)](/home/bashrc#L45) ### [dummy (bashrc)](/home/bashrc#L46)
return 0, ignoring arguments. return 0, ignoring arguments.
### [reload (bashrc)](/home/bashrc#L50) ### [reload (bashrc)](/home/bashrc#L51)
**TODO:** respect initctl like in `.zshrc`. **TODO:** respect initctl like in `.zshrc`.
### [ADDPATH (-shrc)](/home/-shrc#L20) ### [ADDPATH (shrc)](/home/shrc#L24)
append a directory to `$PATH` if it isn't already present. append a directory to `$PATH` if it isn't already present.
### [fils (-shrc)](/home/-shrc#L81) ### [fils (shrc)](/home/shrc#L85)
(GNU du) display human-friendly filesizes for the files in a directory. (GNU du) display human-friendly filesizes for the files in a directory.
### [lsa (-shrc)](/home/-shrc#L82) ### [lsa (shrc)](/home/shrc#L86)
(GNU ls) list files with directories and dotfiles ordered first. (GNU ls) list files with directories and dotfiles ordered first.
### [perlu (-shrc)](/home/-shrc#L83) ### [perlu (shrc)](/home/shrc#L87)
invoke perl expecting files with UTF-8 encoding. invoke perl expecting files with UTF-8 encoding.
### [rgn (-shrc)](/home/-shrc#L84) ### [rgn (shrc)](/home/shrc#L88)
invoke ripgrep without respecting `.gitignore` files. invoke ripgrep without respecting `.gitignore` files.
### [cms (-shrc)](/home/-shrc#L85) ### [cms (shrc)](/home/shrc#L89)
invoke cryptominisat5 with less noise. invoke cryptominisat5 with less noise.
### [curls (-shrc)](/home/-shrc#L86) ### [curls (shrc)](/home/shrc#L90)
invoke curl with less noise. invoke curl with less noise.
### [get (-shrc)](/home/-shrc#L91) ### [get (shrc)](/home/shrc#L95)
retrieve the most recent files from the default branch of a git repository, and not much else. retrieve the most recent files from the default branch of a git repository, and not much else.
### [gs (-shrc)](/home/-shrc#L92) ### [gs (shrc)](/home/shrc#L96)
invoke git's status subcommand. invoke git's status subcommand.
**TODO:** consider renaming because gs(1) already exists. **TODO:** consider renaming because gs(1) already exists.
### [gd (-shrc)](/home/-shrc#L94) ### [gd (shrc)](/home/shrc#L98)
invoke git's diff subcommand with fewer lines of context. invoke git's diff subcommand with fewer lines of context.
### [gds (-shrc)](/home/-shrc#L95) ### [gds (shrc)](/home/shrc#L99)
display difference stats from git. display difference stats from git.
### [gl (-shrc)](/home/-shrc#L96) ### [gl (shrc)](/home/shrc#L100)
invoke git's log subcommand with a single line per commit. invoke git's log subcommand with a single line per commit.
**TODO:** consider renaming because [gl(1)](https://github.com/gitless-vcs/gitless) already exists. **TODO:** consider renaming because [gl(1)](https://github.com/gitless-vcs/gitless) already exists.
### [glo (-shrc)](/home/-shrc#L98) ### [glo (shrc)](/home/shrc#L102)
navigate git's commit tree succinctly. navigate git's commit tree succinctly.
### [g1 (-shrc)](/home/-shrc#L99) ### [g1 (shrc)](/home/shrc#L103)
display the most recent git commit. display the most recent git commit.
### [gr (-shrc)](/home/-shrc#L100) ### [gr (shrc)](/home/shrc#L105)
display remote git repositories verbosely. display remote git repositories verbosely.
### [gb (-shrc)](/home/-shrc#L101) ### [gb (shrc)](/home/shrc#L106)
display the current git branch. display the current git branch.
**NOTE:** there also exists a gb(1) program provided by **NOTE:** there also exists a gb(1) program provided by
the *gb* package that i don't use. the *gb* package that i don't use.
### [gdp (-shrc)](/home/-shrc#L104) ### [gdp (shrc)](/home/shrc#L109)
invoke `gd` to diff a commit from its parent. the commit defaults to "HEAD". invoke `gd` to diff a commit from its parent. the commit defaults to "HEAD".
### [revend (-shrc)](/home/-shrc#L114) ### [revend (shrc)](/home/shrc#L120)
reverse the 4-byte endianness of a single file. *this is an in-place operation!* reverse the 4-byte endianness of a single file. *this is an in-place operation!*
### [clone (-shrc)](/home/-shrc#L115) ### [clone (shrc)](/home/shrc#L121)
invoke rsync suitably for creating virtually indistinguishable copies of files. invoke rsync suitably for creating virtually indistinguishable copies of files.
### [aligntabs (-shrc)](/home/-shrc#L116) ### [aligntabs (shrc)](/home/shrc#L122)
align tab-delimited fields in stdin. align tab-delimited fields in stdin.
### [crawla (-shrc)](/home/-shrc#L117) ### [crawla (shrc)](/home/shrc#L123)
play Dungeon Crawl: Stone Soup through ssh on the akrasiac server. play Dungeon Crawl: Stone Soup through ssh on the akrasiac server.
### [crawlz (-shrc)](/home/-shrc#L118) ### [crawlz (shrc)](/home/shrc#L124)
play Dungeon Crawl: Stone Soup through ssh on the develz server. play Dungeon Crawl: Stone Soup through ssh on the develz server.
### [eahead (-shrc)](/home/-shrc#L120) ### [eahead (shrc)](/home/shrc#L126)
deprecated name for [`ea head`.](#ea) deprecated name for [`ea head`.](#ea)
### [eaget (-shrc)](/home/-shrc#L121) ### [eaget (shrc)](/home/shrc#L127)
deprecated name for [`ea get`.](#ea) deprecated name for [`ea get`.](#ea)
### [eaput (-shrc)](/home/-shrc#L122) ### [eaput (shrc)](/home/shrc#L128)
deprecated name for [`ea put`.](#ea) deprecated name for [`ea put`.](#ea)
### [eamove (-shrc)](/home/-shrc#L123) ### [eamove (shrc)](/home/shrc#L129)
deprecated name for [`ea move`.](#ea) deprecated name for [`ea move`.](#ea)
### [eacopy (-shrc)](/home/-shrc#L124) ### [eacopy (shrc)](/home/shrc#L130)
deprecated name for [`ea copy`.](#ea) deprecated name for [`ea copy`.](#ea)
### [eadelete (-shrc)](/home/-shrc#L125) ### [eadelete (shrc)](/home/shrc#L131)
deprecated name for [`ea delete`.](#ea) deprecated name for [`ea delete`.](#ea)
### [eamv (-shrc)](/home/-shrc#L126) ### [eamv (shrc)](/home/shrc#L132)
invoke [`ea move`.](#ea) invoke [`ea move`.](#ea)
### [eacp (-shrc)](/home/-shrc#L127) ### [eacp (shrc)](/home/shrc#L133)
invoke [`ea copy`.](#ea) invoke [`ea copy`.](#ea)
### [earm (-shrc)](/home/-shrc#L128) ### [earm (shrc)](/home/shrc#L134)
invoke [`ea delete`.](#ea) invoke [`ea delete`.](#ea)
### [ll (-shrc)](/home/-shrc#L130) ### [ll (shrc)](/home/shrc#L136)
list files verbosely, fancily, ordered, but not recursively. list files verbosely, fancily, ordered, but not recursively.
### [diff (-shrc)](/home/-shrc#L139) ### [diff (shrc)](/home/shrc#L145)
use git's diff subcommand for general diffing. use git's diff subcommand for general diffing.
### [gc (-shrc)](/home/-shrc#L140) ### [gc (shrc)](/home/shrc#L146)
columnize text by using git's column subcommand. columnize text by using git's column subcommand.
**TODO:** consider renaming because gc(1) already exists. **TODO:** consider renaming because gc(1) already exists.
### [counts (-shrc)](/home/-shrc#L142) ### [counts (shrc)](/home/shrc#L148)
count files in the current directory, including files found recursively. count files in the current directory, including files found recursively.
### [exts (-shrc)](/home/-shrc#L143) ### [exts (shrc)](/home/shrc#L149)
count and sort file extensions in the current directory, including files found recursively. count and sort file extensions in the current directory, including files found recursively.
### [nocom (-shrc)](/home/-shrc#L144) ### [nocom (shrc)](/home/shrc#L150)
strip single-line C-like and shell-like comments. strip single-line C-like and shell-like comments.
### [jrep (-shrc)](/home/-shrc#L145) ### [jrep (shrc)](/home/shrc#L151)
extract strings comprised of basic ASCII or Japanese codepoints. extract strings comprised of basic ASCII or Japanese codepoints.
### [bomb (-shrc)](/home/-shrc#L146) ### [bomb (shrc)](/home/shrc#L152)
add a Byte-Order Mark to a file. add a Byte-Order Mark to a file.
### [cleanse (-shrc)](/home/-shrc#L147) ### [cleanse (shrc)](/home/shrc#L153)
strip unprintable and non-ASCII characters. strip unprintable and non-ASCII characters.
### [unwrap (-shrc)](/home/-shrc#L148) ### [unwrap (shrc)](/home/shrc#L154)
join paragraphs into one line each. join paragraphs into one line each.
### [double (-shrc)](/home/-shrc#L149) ### [double (shrc)](/home/shrc#L155)
print every line twice. <br/> print every line twice. print every line twice. <br/> print every line twice.
**NOTE:** there also exists a double(1) program provided by **NOTE:** there also exists a double(1) program provided by
the *plotutils* package that i don't use. the *plotutils* package that i don't use.
### [join2 (-shrc)](/home/-shrc#L152) ### [join2 (shrc)](/home/shrc#L158)
join every other line. join every other line.
### [katagana (-shrc)](/home/-shrc#L153) ### [katagana (shrc)](/home/shrc#L159)
convert katakana codepoints to their equivalent hiragana. convert katakana codepoints to their equivalent hiragana.
this is occasionally useful when translating [debug text from ancient games.](https://tcrf.net/) this is occasionally useful when translating [debug text from ancient games.](https://tcrf.net/)
### [picky (-shrc)](/home/-shrc#L155) ### [picky (shrc)](/home/shrc#L161)
list pacman packages that were manually installed and are not in some common package groups. list pacman packages that were manually installed and are not in some common package groups.
this list can be used to assist later reinstalls. this list can be used to assist later reinstalls.
### [unused (-shrc)](/home/-shrc#L158) ### [unused (shrc)](/home/shrc#L164)
list pacman packages that weren't installed explicitly and don't satisfy any dependencies. list pacman packages that weren't installed explicitly and don't satisfy any dependencies.
this list can be used to free up some disk space. this list can be used to free up some disk space.
### [makepkgf (-shrc)](/home/-shrc#L161) ### [makepkgf (shrc)](/home/shrc#L167)
make the freakin' package! make the freakin' package!
### [rakef (-shrc)](/home/-shrc#L162) ### [rakef (shrc)](/home/shrc#L168)
make the freakin' gem! make the freakin' gem!
### [pl (-shrc)](/home/-shrc#L164) ### [pl (shrc)](/home/shrc#L170)
print each argument on its own line. print each argument on its own line.
@ -1115,6 +1123,7 @@ print each argument on its own line.
| [bin](#bin) | zsh | ✔️ | ✔️ | ✔️ | ✔️ | | [bin](#bin) | zsh | ✔️ | ✔️ | ✔️ | ✔️ |
| [busiest](#busiest) | zsh | ✔️ | ⭕ | ⭕ | ⭕ | | [busiest](#busiest) | zsh | ✔️ | ⭕ | ⭕ | ⭕ |
| [colors](#colors) | bash | ✔️ | ✔️ | ⭕ | ⭕ | | [colors](#colors) | bash | ✔️ | ✔️ | ⭕ | ⭕ |
| [colors2](#colors2) | bash | ✔️ | ✔️ | ✔️ | ✔️ |
| [compile](#compile) | zsh | ✔️ | ⭕ | ⭕ | ⭕ | | [compile](#compile) | zsh | ✔️ | ⭕ | ⭕ | ⭕ |
| [confirm](#confirm) | *sh* | ✔️ | ✔️ | ✔️ | ✔️ | | [confirm](#confirm) | *sh* | ✔️ | ✔️ | ✔️ | ✔️ |
| [countdiff](#countdiff) | *sh* | ✔️ | ✔️ | ✔️ | ✔️ | | [countdiff](#countdiff) | *sh* | ✔️ | ✔️ | ✔️ | ✔️ |
@ -1124,7 +1133,7 @@ print each argument on its own line.
| [decently](#decently) | *sh* | ✔️ | ✔️ | ✔️ | ✔️ | | [decently](#decently) | *sh* | ✔️ | ✔️ | ✔️ | ✔️ |
| [dfu](#dfu) | *sh* | ✔️ | ✔️ | ✔️ | ✔️ | | [dfu](#dfu) | *sh* | ✔️ | ✔️ | ✔️ | ✔️ |
| [disowned](#disowned) | *sh* | ✔️ | ✔️ | ✔️ | ✔️ | | [disowned](#disowned) | *sh* | ✔️ | ✔️ | ✔️ | ✔️ |
| [document](#document) | dash | ⭕ | ⭕ | ✔️ | ✔️ | | [document](#document) | dash | ✔️ | ✔️ | ✔️ | ✔️ |
| [e](#e) | *sh* | ✔️ | ✔️ | ✔️ | ✔️ | | [e](#e) | *sh* | ✔️ | ✔️ | ✔️ | ✔️ |
| [ea](#ea) | *sh* | ✔️ | ✔️ | ✔️ | ✔️ | | [ea](#ea) | *sh* | ✔️ | ✔️ | ✔️ | ✔️ |
| [echo2](#echo2) | *sh* | ✔️ | ✔️ | ✔️ | ✔️ | | [echo2](#echo2) | *sh* | ✔️ | ✔️ | ✔️ | ✔️ |
@ -1175,6 +1184,9 @@ print each argument on its own line.
| [trash](#trash) | *sh* | ✔️ | ✔️ | ✔️ | ✔️ | | [trash](#trash) | *sh* | ✔️ | ✔️ | ✔️ | ✔️ |
| [trunc](#trunc) | *sh* | ✔️ | ✔️ | ✔️ | ✔️ | | [trunc](#trunc) | *sh* | ✔️ | ✔️ | ✔️ | ✔️ |
| [unarchive](#unarchive) | zsh | ✔️ | ⭕ | ⭕ | ⭕ | | [unarchive](#unarchive) | zsh | ✔️ | ⭕ | ⭕ | ⭕ |
| [v_domap](#v_domap) | *sh* | ✔️ | ✔️ | ✔️ | ✔️ |
| [v_lower](#v_lower) | *sh* | ✔️ | ✔️ | ✔️ | ✔️ |
| [v_upper](#v_upper) | *sh* | ✔️ | ✔️ | ✔️ | ✔️ |
| [wat](#wat) | zsh | ✔️ | ⭕ | ⭕ | ⭕ | | [wat](#wat) | zsh | ✔️ | ⭕ | ⭕ | ⭕ |
| [wipe](#wipe) | *sh* | ✔️ | ✔️ | ✔️ | ✔️ | | [wipe](#wipe) | *sh* | ✔️ | ✔️ | ✔️ | ✔️ |
| [xxp](#xxp) | *sh* | ✔️ | ✔️ | ✔️ | ✔️ | | [xxp](#xxp) | *sh* | ✔️ | ✔️ | ✔️ | ✔️ |

View File

@ -1,4 +1,5 @@
[ -z "$PS1" ] && return [ -z "$PS1" ] && return
. ~/.prep # handle boring stuff like /etc/profile and $PATH
HISTCONTROL=erasedups HISTCONTROL=erasedups
HISTSIZE=1000 HISTSIZE=1000
@ -28,7 +29,7 @@ ret_fail="$_title${Cfail}$_line1\n${Cfail}$_line2"
PROMPT_COMMAND='[ $? = 0 ] && PS1=${ret_succ} || PS1=${ret_fail}' PROMPT_COMMAND='[ $? = 0 ] && PS1=${ret_succ} || PS1=${ret_fail}'
. ~/.-shrc . ~/.shrc
# this doesn't work for all scripts at the moment, but # this doesn't work for all scripts at the moment, but
ADDPATH "$HOME/sh" ADDPATH "$HOME/sh"

52
home/prep Normal file
View File

@ -0,0 +1,52 @@
#!/usr/bin/env false
# for ash, dash, bash, and zsh.
if [ -r /etc/msystem ]; then
# avoid sourcing /etc/profile because forking cygwin processes is awful.
. /etc/msystem # this doesn't fork anything, thankfully.
# NOTE: never inherits parent process's PATH. does not add perl paths.
PATH="/usr/local/bin:/usr/bin:/bin"
PATH="$PATH:/c/Windows/System32:/c/Windows:/c/Windows/System32/Wbem"
PATH="$PATH:/c/Windows/System32/WindowsPowerShell/v1.0/"
MANPATH="/usr/local/man:/usr/share/man:/usr/man:/share/man"
INFOPATH="/usr/local/info:/usr/share/info:/usr/info:/share/info"
SYSCONFDIR="${SYSCONFDIR:-/etc}" # not exported for some reason?
CONFIG_SITE="/etc/config.site"
SHELL="/usr/bin/zsh"
if [ "$MSYSTEM" = MSYS ]; then
PATH="$PATH:/opt/bin"
PKG_CONFIG_PATH="/usr/lib/pkgconfig:/usr/share/pkgconfig:/lib/pkgconfig"
else
PATH="$MINGW_PREFIX/bin:$PATH"
PKG_CONFIG_PATH="$MINGW_PREFIX/lib/pkgconfig:$MINGW_PREFIX/share/pkgconfig"
export ACLOCAL_PATH="$MINGW_PREFIX/share/aclocal:/usr/share/aclocal"
MANPATH="$MINGW_PREFIX/local/man:$MINGW_PREFIX/share/man:$MANPATH"
fi
[ -n "${USER:=$USERNAME}" ] || USER="$(exec id -un)" # not much choice here
[ -n "${HOSTNAME:=$HOST}" ] || HOSTNAME="$(exec /usr/bin/hostname)"
LANG="en_US.UTF-8"
[ -s /etc/localtime ] && TZ=":/etc/localtime" || TZ="America/Vancouver"
TMP="/tmp"; TEMP="/tmp"
tmp="C:\\Users\\$USER\\AppData\\Local\\Temp"; temp="$tmp"
ORIGINAL_TMP="/c/Users/$USER/AppData/Local/Temp"; ORIGINAL_TEMP="$ORIGINAL_TMP"
export CONFIG_SITE HOSTNAME INFOPATH LANG MANPATH ORIGINAL_TEMP ORIGINAL_TMP PATH PKG_CONFIG_PATH SHELL TEMP TMP TZ USER temp tmp
elif [ -r /etc/profile ]; then
if [ -n "$ZSH_VERSION" ]; then
emulate sh -c "source /etc/profile"
else
. /etc/profile
fi
else # something's strange; set some sane defaults (from alpine)
export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
export CHARSET="UTF-8"
export LANG="C.UTF-8"
export LC_COLLATE="C"
fi

View File

@ -1,6 +1,10 @@
#!/usr/bin/env false #!/usr/bin/env false
# for ash, dash, bash, and zsh. # for ash, dash, bash, and zsh.
[ -n "$ZSH_VERSION" -o -n "$BASH_VERSION" ] && FANCY=1 || FANCY=0 [ -n "$ZSH_VERSION" -o -n "$BASH_VERSION" ] && FANCY=1 || FANCY=0
if [ "$FANCY" = 0 ]; then
. ~/.prep # handle boring stuff like /etc/profile and $PATH
fi
# {{{1 utilities # {{{1 utilities
@ -49,7 +53,7 @@ export EA_AUTH="auth"
export EA_DIR="t" export EA_DIR="t"
export EA_DOMAIN="https://eaguru.guru" export EA_DOMAIN="https://eaguru.guru"
export EDITOR=vim export EDITOR=vim
export ENV="$HOME/.-shrc" # for dash export ENV="$HOME/.shrc" # for dash and ash
export PAGER=less export PAGER=less
export PYTHONIOENCODING=utf-8 # damnit python! export PYTHONIOENCODING=utf-8 # damnit python!
export SSH_AUTH_SOCK=0 # more info: https://0x0.st/NUnw export SSH_AUTH_SOCK=0 # more info: https://0x0.st/NUnw
@ -66,7 +70,7 @@ fi
# enable colors {{{2 # enable colors {{{2
if [ "$FANCY" -eq 1 ]; then if [ "$FANCY" = 1 ]; then
# busybox is smart enough to ignore --color flags when unsupported. # busybox is smart enough to ignore --color flags when unsupported.
alias grep='grep --color=auto' alias grep='grep --color=auto'
alias ls='ls --color=auto' alias ls='ls --color=auto'
@ -97,6 +101,7 @@ alias gl='git log --oneline' ### @- invoke git's log subcommand with a single li
### **TODO:** consider renaming because [gl(1)](https://github.com/gitless-vcs/gitless) already exists. ### **TODO:** consider renaming because [gl(1)](https://github.com/gitless-vcs/gitless) already exists.
alias glo='git log --graph --decorate --pretty=oneline --abbrev-commit --all' ### @- navigate git's commit tree succinctly. alias glo='git log --graph --decorate --pretty=oneline --abbrev-commit --all' ### @- navigate git's commit tree succinctly.
alias g1='git log --pretty=oneline --abbrev-commit --color=always | head -1' ### @- display the most recent git commit. alias g1='git log --pretty=oneline --abbrev-commit --color=always | head -1' ### @- display the most recent git commit.
alias g11='git rev-parse --short HEAD'
alias gr='git remote -v' ### @- display remote git repositories verbosely. alias gr='git remote -v' ### @- display remote git repositories verbosely.
alias gb='git --no-pager branch' ### @- display the current git branch. alias gb='git --no-pager branch' ### @- display the current git branch.
### **NOTE:** there also exists a gb(1) program provided by ### **NOTE:** there also exists a gb(1) program provided by
@ -110,6 +115,7 @@ gdp() { ### @- invoke `gd` to diff a commit from its parent. the commit defaults
# being specific {{{2 # being specific {{{2
alias ash="PS1='$ ' busybox ash" alias ash="PS1='$ ' busybox ash"
alias cort='LC_ALL=C sort'
alias pip="maybesudo -H pip3" alias pip="maybesudo -H pip3"
alias revend='objcopy -I binary -O binary --reverse-bytes=4' ### @- reverse the 4-byte endianness of a single file. *this is an in-place operation!* alias revend='objcopy -I binary -O binary --reverse-bytes=4' ### @- reverse the 4-byte endianness of a single file. *this is an in-place operation!*
alias clone='maybesudo rsync -aHA --info=progress2 --no-i-r' ### @- invoke rsync suitably for creating virtually indistinguishable copies of files. alias clone='maybesudo rsync -aHA --info=progress2 --no-i-r' ### @- invoke rsync suitably for creating virtually indistinguishable copies of files.

View File

@ -26,6 +26,9 @@ set -g set-titles-string '#{host}: #{pane_title}'
setw -g window-status-format "#I:#{s/.*\\\\|\.exe//:pane_current_command}" setw -g window-status-format "#I:#{s/.*\\\\|\.exe//:pane_current_command}"
setw -g window-status-current-format "#I:#{s/.*\\\\|\.exe//:pane_current_command}" setw -g window-status-current-format "#I:#{s/.*\\\\|\.exe//:pane_current_command}"
# don't wrap around with searches
setw -g wrap-search off
# set the default terminal to tmux instead of pretending to be screen. # set the default terminal to tmux instead of pretending to be screen.
# NOTE: netbsd-curses requires a terminfo.cdb to be built with tmux support. # NOTE: netbsd-curses requires a terminfo.cdb to be built with tmux support.
# for my own convenience: # for my own convenience:

View File

@ -122,6 +122,20 @@ let $PATH .= ':'.$HOME.'/sh' " allow direct invocation of shell funcs
" fun {{{1 " fun {{{1
fu! Colour(name) " go nuts. go wild.
hi clear | syntax clear | syntax on " reset everything for sure (#4405)
if has('termguicolors')
if &term =~ "^tmux-256color"
let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
set termguicolors
endif
endif
exe "colo " . a:name
endf
command! -nargs=* Colour call Colour(<f-args>)
" lifted from BurntSushi: " lifted from BurntSushi:
fu! GlobalReplace() fu! GlobalReplace()
normal! gv"ry normal! gv"ry

View File

@ -1,4 +1,4 @@
[ -e /etc/profile ] && emulate sh -c "source /etc/profile" . ~/.prep # handle boring stuff like /etc/profile and $PATH
HISTFILE=~/.histfile HISTFILE=~/.histfile
HISTSIZE=99999 HISTSIZE=99999
@ -34,13 +34,20 @@ setopt path_dirs # Perform path search even on command names with
setopt rc_quotes # 'it''s okay' becomes "it's okay" setopt rc_quotes # 'it''s okay' becomes "it's okay"
unsetopt flow_control # Disable start/stop characters in shell editor. unsetopt flow_control # Disable start/stop characters in shell editor.
if [ "$SHLVL" -le 1 ] && [ "$TERM" = "${TERM#screen}" ] && [ "$TERM" = "${TERM#tmux}" ]; then function {
if (( $+commands[tmux] )); then if [ "$SHLVL" -le 1 ] \
&& [ "${TERM#screen}" = "$TERM" ] \
&& [ "${TERM#tmux}" = "$TERM" ] \
&& (( $+commands[tmux] ))
then
# create a new session called "what" or attach if it already exists # create a new session called "what" or attach if it already exists
LANG="en_US.UTF-8" TZ=":/etc/localtime" tmux new -A -s what && exit local env=(LANG="en_US.UTF-8" TZ=":/etc/localtime")
local cmd=(tmux new -A -s what)
[ "${TTY#/dev/cons}" = "$TTY" ] || cmd=(script -qfec "$cmd" /dev/null)
env $env $cmd && exit
printf '\e[91m\ntmux died (%i), continuing...\n\e[0m\n' $? printf '\e[91m\ntmux died (%i), continuing...\n\e[0m\n' $?
fi fi
fi }
autoload -U zmv autoload -U zmv
autoload -U zrecompile autoload -U zrecompile
@ -55,8 +62,8 @@ function {
# combine everything matching "YES_ZSH" in ~/sh/ into ~/.sh, # combine everything matching "YES_ZSH" in ~/sh/ into ~/.sh,
# but only recompile the output if the sha1sum has changed. # but only recompile the output if the sha1sum has changed.
[ -s ~/.sh.sha1 ] && read -r b _ < ~/.sh.sha1 [ -s ~/.sh.sha1 ] && read -r b _ < ~/.sh.sha1
( cd ~/sh \ ( cd ~/sh \
&& print -l '#!/usr/bin/env false' '[ -n "$preload" ] || exit 1' '' \ && print -l '#!/usr/bin/env false' '[ -n "$preload" ] || exit 1' '' \
| cat - $(grep -lF YES_ZSH -- *~*.bak(.)) \ | cat - $(grep -lF YES_ZSH -- *~*.bak(.)) \
| tee ~/.sh \ | tee ~/.sh \
) | sha1sum - \ ) | sha1sum - \
@ -188,7 +195,7 @@ else
hash -d py=~/Dropbox/py hash -d py=~/Dropbox/py
fi fi
. ~/.-shrc . ~/.shrc
alias -g OMFG="1>/dev/null" ### @ OMFG - silence stdout. alias -g OMFG="1>/dev/null" ### @ OMFG - silence stdout.
alias -g STFU="2>/dev/null" ### @ STFU - silence stderr. alias -g STFU="2>/dev/null" ### @ STFU - silence stderr.

View File

@ -130,7 +130,7 @@ cd "${HOME:?HOME variable empty or unset}" || die "failed to change directory"
backup_dir="$rc/backup-$(date -u '+%s')" backup_dir="$rc/backup-$(date -u '+%s')"
[ ! -d "$backup_dir" ] || die "backup directory already exists" [ ! -d "$backup_dir" ] || die "backup directory already exists"
for f in .bashrc .zshrc .-shrc .prezto-compinit .ls_colors \ for f in .shrc .bashrc .zshrc .prep .prezto-compinit .ls_colors \
.vimrc .inputrc .Xresources .screenrc .tmux.conf; do .vimrc .inputrc .Xresources .screenrc .tmux.conf; do
hardlink "$f" "$rc/home/${f#.}" hardlink "$f" "$rc/home/${f#.}"
done done

View File

@ -59,7 +59,7 @@ else
#( cd temp; HOME="$rc/temp" dash ./install ) #( cd temp; HOME="$rc/temp" dash ./install )
ln temp/home/zshrc temp/.zshrc || die 'failed to copy files' ln temp/home/zshrc temp/.zshrc || die 'failed to copy files'
ln temp/home/-shrc temp/.-shrc || die 'failed to copy files' ln temp/home/shrc temp/.shrc || die 'failed to copy files'
ln temp/home/bashrc temp/.bashrc || die 'failed to copy files' ln temp/home/bashrc temp/.bashrc || die 'failed to copy files'
# use new documentation-generating scripts on old shell scripts. # use new documentation-generating scripts on old shell scripts.

22
sh/colors2 Normal file
View File

@ -0,0 +1,22 @@
#!/usr/bin/env bash
# YES_ZSH
# YES_BASH
# YES_DASH
# YES_ASH
colors2() {
[ $# -eq 0 ] || { printf "%s\n" "$0: does not take arguments" >&2; return 1; }
for a in 0 60; do
for b in 0 60; do
for i in 30 31 33 32 36 34 35 37; do
for j in 40 41 43 42 46 44 45 47; do
printf ' \033[%s;%sm %03d \033[m' $((a+j)) $((b+i)) $((a+j))
done
printf '\n'
done
done
[ $a = 0 ] && printf '\n'
done
}
[ -n "${preload+-}" ] || colors2 "$@"

View File

@ -63,7 +63,7 @@ compile() { ### @-
### # debug build ### # debug build
### compile rd.c ### compile rd.c
### compile debug rd.c ### compile debug rd.c
### # debug build with warning/error flags defined in .-shrc ### # debug build with warning/error flags defined in ~/sh/arrays
### # (requires .zshrc for global alias expansion) ### # (requires .zshrc for global alias expansion)
### compile WHOA rd.c ### compile WHOA rd.c
### # likewise for C++ ### # likewise for C++

View File

@ -23,6 +23,8 @@ decently() ( ### @-
find "$dir" -type f "$@" \ find "$dir" -type f "$@" \
'!' \ '!' \
'(' -path '*/.git/*' \ '(' -path '*/.git/*' \
-or -path '*/CVS/*' \
-or -path '*/CVSROOT/*' \
-or -path '*/__pycache__/*' \ -or -path '*/__pycache__/*' \
-or -path '*/[Dd]esktop.ini' \ -or -path '*/[Dd]esktop.ini' \
-or -path '*/Thumbs.db' \ -or -path '*/Thumbs.db' \

View File

@ -1,9 +1,5 @@
#!/usr/bin/env dash #!/usr/bin/env dash
# NO_ZSH # FAKE_COMPAT
# NO_BASH
# YES_DASH
# YES_ASH
# okay, so this probably does run with zsh and bash, but why bother?
# NOTE: a lot of boilerplate code is pulled from the pure sh bible: # NOTE: a lot of boilerplate code is pulled from the pure sh bible:
# https://github.com/dylanaraps/pure-sh-bible # https://github.com/dylanaraps/pure-sh-bible
@ -112,7 +108,7 @@ document1() {
fi fi
# sanity check: # sanity check:
[ -d sh ] && [ -f .zshrc ] && [ -f .-shrc ] && [ -f .bashrc ] || return 3 [ -d sh ] && [ -f .zshrc ] && [ -f .shrc ] && [ -f .bashrc ] || return 3
# create new output file (with a tilde as not to overwrite just yet): # create new output file (with a tilde as not to overwrite just yet):
: > "$out" || return 4 : > "$out" || return 4
@ -144,7 +140,7 @@ document1() {
printf '\n## %s\n' 'miscellaneous' >> "$out" || return 5 printf '\n## %s\n' 'miscellaneous' >> "$out" || return 5
document2 .zshrc >> "$out" || return document2 .zshrc >> "$out" || return
document2 .bashrc >> "$out" || return document2 .bashrc >> "$out" || return
document2 .-shrc >> "$out" || return document2 .shrc >> "$out" || return
} }
document() { ### @- document() { ### @-

25
sh/v_domap Normal file
View File

@ -0,0 +1,25 @@
#!/usr/bin/env sh
# YES_ZSH
# YES_BASH
# YES_DASH
# YES_ASH
v_domap() {
argc $# -eq 1 "$0" || return
# TODO: sanity-check on characters of the variable name.
local _k_="$1" _v_= _new_= _next_= _i_= _o_=
eval "_v_=\"\$$_k_\""
while [ -n "$_v_" ]; do
_next_="${_v_#[! ]}"
[ "$_next_" != "$_v_" ] || _next_="${_v_# }"
_i_="${_v_%"$_next_"}"; _v_="$_next_"
map
_new_="$_new_$_o_"
#printf 'new: %s\n' "$_new_"
done
eval "$_k_=\"\$_new_\""
}
[ -n "${preload+-}" ] || . ~/sh/preload || exit 2
eval ${preload:-preload} argc
[ -n "${preload+-}" ] || v_domap "$@"

22
sh/v_lower Normal file
View File

@ -0,0 +1,22 @@
#!/usr/bin/env sh
# YES_ZSH
# YES_BASH
# YES_DASH
# YES_ASH
v_lower() { ### @- transform the contents of a variable to lowercase.
argc $# -eq 1 "$0" || return
map() {
case "$_i_" in
(A) _o_=a;; (B) _o_=b;; (C) _o_=c;; (D) _o_=d;; (E) _o_=e;; (F) _o_=f;; (G) _o_=g;;
(H) _o_=h;; (I) _o_=i;; (J) _o_=j;; (K) _o_=k;; (L) _o_=l;; (M) _o_=m;; (N) _o_=n;;
(O) _o_=o;; (P) _o_=p;; (Q) _o_=q;; (R) _o_=r;; (S) _o_=s;; (T) _o_=t;; (U) _o_=u;;
(V) _o_=v;; (W) _o_=w;; (X) _o_=x;; (Y) _o_=y;; (Z) _o_=z;; (*) _o_="$_i_";;
esac
}
v_domap "$1"
}
[ -n "${preload+-}" ] || . ~/sh/preload || exit 2
eval ${preload:-preload} argc v_domap
[ -n "${preload+-}" ] || v_lower "$@"

22
sh/v_upper Normal file
View File

@ -0,0 +1,22 @@
#!/usr/bin/env sh
# YES_ZSH
# YES_BASH
# YES_DASH
# YES_ASH
v_upper() { ### @- transform the contents of a variable to uppercase.
argc $# -eq 1 "$0" || return
map() {
case "$_i_" in
(a) _o_=A;; (b) _o_=B;; (c) _o_=C;; (d) _o_=D;; (e) _o_=E;; (f) _o_=F;; (g) _o_=G;;
(h) _o_=H;; (i) _o_=I;; (j) _o_=J;; (k) _o_=K;; (l) _o_=L;; (m) _o_=M;; (n) _o_=N;;
(o) _o_=O;; (p) _o_=P;; (q) _o_=Q;; (r) _o_=R;; (s) _o_=S;; (t) _o_=T;; (u) _o_=U;;
(v) _o_=V;; (w) _o_=W;; (x) _o_=X;; (y) _o_=Y;; (z) _o_=Z;; (*) _o_="$_i_";;
esac
}
v_domap "$1"
}
[ -n "${preload+-}" ] || . ~/sh/preload || exit 2
eval ${preload:-preload} argc v_domap
[ -n "${preload+-}" ] || v_upper "$@"