1
0
Fork 0
mirror of https://github.com/notwa/rc synced 2024-11-05 06:29:02 -08:00
rc/README.md

655 lines
14 KiB
Markdown
Raw Normal View History

2013-06-28 05:51:52 -07:00
## obligatory personal dotfiles repository
2013-06-28 05:22:14 -07:00
_(plus some little shell scripts)_
2019-06-03 09:33:02 -07:00
quick install for random boxes:
```
cd && curl -L https://github.com/notwa/rc/archive/master.tar.gz | tar zx && mv rc-master rc && rc/install
```
2021-08-01 00:35:56 -07:00
**NOTE:** everything below this line is overwritten and automatically [regenerated.](/regenerate)
2016-06-27 06:02:53 -07:00
<!-- DOCUMENT -->
2021-07-30 17:59:30 -07:00
## shell functions
2021-08-01 00:38:05 -07:00
### [argc](/sh/argc#L7)
```sh
# usage:
myfunc() {
2021-08-01 02:14:30 -07:00
# use one of the following:
argc -eq N "$0" "$@" || return
argc -le N "$0" "$@" || return
argc -ge N "$0" "$@" || return
# where N is an integer between 0 and 9.
2021-08-01 00:38:05 -07:00
}
```
2021-07-30 18:08:59 -07:00
### [arith](/sh/arith#L9)
2021-07-30 17:59:30 -07:00
perform arithmetic using the shell and display the result.
2021-07-30 18:08:59 -07:00
### [aur](/sh/aur#L7)
2021-07-30 17:59:30 -07:00
download, edit, make, and install packages from the
[AUR.](https://aur.archlinux.org/)
it's a little broken.
2021-07-30 18:08:59 -07:00
### [autosync](/sh/autosync#L8)
2021-07-30 17:59:30 -07:00
combine `inotifywait` and `rsync`.
this is sometimes nicer than `ssh`-ing into a server and running `vim` remotely.
2021-08-01 00:38:05 -07:00
### [bak](/sh/bak#L6)
### [baknow](/sh/baknow#L4)
### [baks](/sh/baks#L11)
### [bin](/sh/bin#L6)
2021-07-30 18:08:59 -07:00
### [cdbusiest](/sh/cdbusiest#L4)
2021-07-30 17:59:30 -07:00
cd to the directory with the most files in it, counted recursively.
2021-07-30 18:08:59 -07:00
### [colors](/sh/colors#L6)
2021-07-30 17:59:30 -07:00
print out all the foreground and background terminal color combinations.
excluding boilerplate, this script is a mere a 76-characters long!
2021-07-30 18:08:59 -07:00
### [compandy](/sh/compandy#L5)
2021-07-30 17:59:30 -07:00
generate compand arguments for ffmpeg audio filters.
this is kinda pointless now that acompressor is wildly supported.
2021-07-30 18:08:59 -07:00
### [__setup_clang_ubuntu (sh/compile)](/sh/compile#L7)
2021-07-30 17:59:30 -07:00
2021-07-30 18:08:59 -07:00
### [compile](/sh/compile#L29)
2021-07-30 17:59:30 -07:00
compile single-file C and C++ programs, messily.
supports gcc and clang on \*nix, and mingw64 gcc, msvc clang,
and regular msvc on Windows. tested on x86\_64 and on ARMv7 as well.
does not support MacOS, maybe someday…
defaults to gnu11 and gnu++1z as C and C++ standards respectively.
defaults to clang, gcc, and msvc in that order.
`compile` attempts to guess the most sane switches for any program, so that compilation may reduce to:
**TODO:** restore examples.
2021-07-30 18:08:59 -07:00
### [confirm](/sh/confirm#L6)
2021-07-30 17:59:30 -07:00
display a simple yes-or-no prompt and return 0-or-1 respectively.
```
$ confirm && echo yay || echo nay
Continue? [y/N] y
yay
$ confirm && echo yay || echo nay
Continue? [y/N] n
nay
```
2021-08-01 00:38:05 -07:00
### [countdiff](/sh/countdiff#L6)
### [cutv](/sh/cutv#L6)
2021-07-30 18:08:59 -07:00
### [days](/sh/days#L6)
2021-07-30 17:59:30 -07:00
2021-08-01 00:38:05 -07:00
compute the number of days since a given date.
2021-07-30 17:59:30 -07:00
```
$ days 'January 1 1970'
18838
```
2021-07-30 18:08:59 -07:00
### [dbusiest](/sh/dbusiest#L6)
2021-07-30 17:59:30 -07:00
display the directory with the most files in it, counted recursively.
2021-07-30 18:08:59 -07:00
### [dfu](/sh/dfu#L6)
2021-07-30 17:59:30 -07:00
pretty-print `df` in GiB.
**TODO:** restore examples.
2021-07-30 18:08:59 -07:00
### [disf](/sh/disf#L9)
2021-07-30 17:59:30 -07:00
disassemble a single function from an unstripped executable, unreliably.
2021-08-01 00:38:05 -07:00
### [document](/sh/document#L135)
generate a markdown file out of docstrings in shell scripts.
**TODO:** describe. i have a rough outline written in my scrap file.
2021-07-30 18:08:59 -07:00
### [e](/sh/e#L6)
2021-07-30 17:59:30 -07:00
wrap around `$EDITOR` to run it as root if necessary.
this still needs some work to detect root-owned directories.
```
$ e /etc/sudoers
[sudo] password for notwa:
```
2021-08-01 00:38:05 -07:00
### [eahead (sh/ea)](/sh/ea#L11)
### [eaget (sh/ea)](/sh/ea#L15)
### [eaput (sh/ea)](/sh/ea#L19)
### [eamove (sh/ea)](/sh/ea#L23)
### [eacopy (sh/ea)](/sh/ea#L29)
### [eadelete (sh/ea)](/sh/ea#L35)
### [eamv (sh/ea)](/sh/ea#L39)
### [eacp (sh/ea)](/sh/ea#L40)
### [earm (sh/ea)](/sh/ea#L41)
### [echo2](/sh/echo2#L6)
### [explore](/sh/explore#L6)
### [ff](/sh/ff#L6)
### [ghmd](/sh/ghmd#L9)
2021-07-30 18:08:59 -07:00
### [has](/sh/has#L6)
2021-07-30 17:59:30 -07:00
print the result of `which` if the program is found, else simply return 1.
`export CC="$(has clang || has clang-3.8 || has gcc)"`
2021-07-30 18:08:59 -07:00
### [hex](/sh/hex#L9)
2021-07-30 17:59:30 -07:00
perform arithmetic using the shell and display the result as an unsigned 32-bit integer in hexadecimal.
2021-07-30 18:08:59 -07:00
### [ify](/sh/ify#L6)
2021-07-30 17:59:30 -07:00
pipe one command through another, so you can still pass arguments to the former.
this is mainly useful for aliases. 99% of the time you'll use this with `less`.
```
$ alias ll="ify less ls -ACX --group-directories-first --color=force"
$ ll /etc
```
2021-07-30 18:08:59 -07:00
### [is_empty](/sh/is_empty#L6)
2021-07-30 17:59:30 -07:00
return 0 if the directory given by argument is empty.
2021-07-30 18:08:59 -07:00
### [isup](/sh/isup#L8)
2021-07-30 17:59:30 -07:00
return 0 if a given website returns a 2xx HTTP code.
2021-08-01 00:38:05 -07:00
### [maybesudo_ (sh/maybesudo)](/sh/maybesudo#L6)
2021-07-30 18:08:59 -07:00
### [minutemaid](/sh/minutemaid#L6)
2021-07-30 17:59:30 -07:00
return 0 if the current minute is divisible by a number.
note that a minute is relative to the seconds since the epoch, not the minute of the hour.
```
# crontab usage:
* * * * * minutemaid 9 ~/work/do_my_bidding # runs every nine minutes
```
2021-07-30 18:08:59 -07:00
### [monitor](/sh/monitor#L4)
2021-07-30 17:59:30 -07:00
this is `watch` loosely reimplemented as a shell script.
2021-07-30 18:08:59 -07:00
### [noccom](/sh/noccom#L10)
2021-07-30 17:59:30 -07:00
strip C-like comments; both multi-line and single-line.
2021-08-01 00:38:05 -07:00
### [note](/sh/note#L6)
2021-07-30 18:08:59 -07:00
### [now](/sh/now#L8)
2021-07-30 17:59:30 -07:00
print a date-time (UTC) in a sortable format.
this takes a date or file as an argument,
else it defaults to the current time.
```
$ now
2019-05-27_35083906
$ now ~/sh/monitor
2017-03-14_82387259
$ now '@1234567890'
2009-02-13_84690000
```
2021-07-30 18:08:59 -07:00
### [pacbm](/sh/pacbm#L6)
2021-07-30 17:59:30 -07:00
list installed pacman packages by their filesize, and the sum, ascending. requires `expac`.
```
$ pacbm | head -n -1 | tail -2
2021-08-01 02:14:30 -07:00
204.78M clang
235.44M linux-firmware
2021-07-30 17:59:30 -07:00
```
2021-07-30 18:08:59 -07:00
### [pause](/sh/pause#L6)
2021-07-30 17:59:30 -07:00
pause — the companion script of `confirm`.
```
$ pause
Press any key to continue
$
```
2021-08-01 00:38:05 -07:00
### [pegg](/sh/pegg#L8)
### [pippy](/sh/pippy#L7)
2021-07-30 18:08:59 -07:00
### [pre](/sh/pre#L6)
2021-07-30 17:59:30 -07:00
dump all the `#define`s that `$CC $CPPFLAGS $CFLAGS $LDFLAGS` would result in.
**TODO:** restore examples.
2021-08-01 00:38:05 -07:00
### [psbm](/sh/psbm#L6)
2021-07-30 18:08:59 -07:00
### [randir](/sh/randir#L6)
2021-07-30 17:59:30 -07:00
display a random directory in the current working directory.
```
$ randir
./sh
```
2021-08-01 00:38:05 -07:00
### [refresh](/sh/refresh#L6)
2021-07-30 18:08:59 -07:00
### [rs](/sh/rs#L4)
2021-07-30 17:59:30 -07:00
record screen. does not record audio.
currently only works on Windows (gdigrab).
i'm sure there's something equivalent for Linux.
2021-07-30 18:08:59 -07:00
### [sc](/sh/sc#L40)
2021-07-30 17:59:30 -07:00
upload given files to a webserver and return a direct link for sharing them.
you'll want to tweak this if you use it yourself.
this contains some extra logic for screenshots created by `scropt`.
2021-07-30 18:08:59 -07:00
### [scramble](/sh/scramble#L6)
2021-07-30 17:59:30 -07:00
scrambles text in a predictable way using regex.
sacbremls ttex in a pdrceailtbe way unsig reegx.
2021-07-30 18:08:59 -07:00
### [screeny](/sh/screeny#L4)
2021-07-30 17:59:30 -07:00
i don't use this anymore~
2021-07-30 18:08:59 -07:00
### [scropt](/sh/scropt#L8)
2021-07-30 17:59:30 -07:00
run `scrot` through `optipng` and save the result to `~/play/$(now).png`.
`$ ~/sh/sc $(~/sh/scropt -s -d0.5)`
2021-08-01 00:38:05 -07:00
### [similar](/sh/similar#L6)
2021-07-30 18:08:59 -07:00
### [slit](/sh/slit#L6)
2021-07-30 17:59:30 -07:00
view specific columns of text.
2021-07-30 18:08:59 -07:00
### [slitt](/sh/slitt#L6)
2021-07-30 17:59:30 -07:00
view specific columns of text.
this version of `slit` uses tabs for its field separators.
2021-07-30 18:08:59 -07:00
### [sram](/sh/sram#L4)
2021-07-30 17:59:30 -07:00
convert between a couple saveram formats for N64 emulators.
2021-08-01 00:38:05 -07:00
### [stfu](/sh/stfu#L7)
### [mpvs (sh/streamcrap)](/sh/streamcrap#L6)
invoke mpv with some extra flags suited for streamed sources.
### [mpv_watch (sh/streamcrap)](/sh/streamcrap#L66)
2021-07-30 17:59:30 -07:00
watch something in mpv with a bunch of extra audio filtering crap.
2021-08-01 00:38:05 -07:00
### [mpv_stream (sh/streamcrap)](/sh/streamcrap#L78)
2021-07-30 17:59:30 -07:00
watch a stream in mpv with a bunch of extra audio filtering crap.
2021-08-01 00:38:05 -07:00
### [twitch (sh/streamcrap)](/sh/streamcrap#L87)
2021-07-30 17:59:30 -07:00
watch a twitch stream in mpv with a bunch of extra audio filtering crap.
2021-08-01 00:38:05 -07:00
### [yt (sh/streamcrap)](/sh/streamcrap#L94)
2021-07-30 17:59:30 -07:00
watch a youtube video in mpv with a bunch of extra audio filtering crap.
this can be given a full URL or just a video ID.
remaining arguments are passed to mpv.
there exist several variants for more specific use cases.
2021-08-01 00:38:05 -07:00
### [ytg (sh/streamcrap)](/sh/streamcrap#L106)
2021-07-30 17:59:30 -07:00
watch a youtube video. like `yt`, but with a preference for different formats.
2021-08-01 00:38:05 -07:00
### [ytll (sh/streamcrap)](/sh/streamcrap#L113)
2021-07-30 17:59:30 -07:00
watch a stream on youtube in mpv, etcetera etcetera.
this is the low latency version that does not support seeking.
2021-08-01 00:38:05 -07:00
### [ytgll (sh/streamcrap)](/sh/streamcrap#L120)
2021-07-30 17:59:30 -07:00
watch a stream on youtube in mpv. like `ytll`, but with a preference for different formats.
2021-08-01 00:38:05 -07:00
### [sum](/sh/sum#L6)
2021-07-30 18:08:59 -07:00
### [sv](/sh/sv#L6)
2021-07-30 17:59:30 -07:00
collect the lastmost value of every key.
the field separator can be given as its sole argument.
```
echo "this=that\nthem=those\nthis=cat" | sv =
this=cat
them=those
```
**TODO:** add multi-file grep example.
2021-07-30 18:08:59 -07:00
### [tpad](/sh/tpad#L6)
2021-07-30 17:59:30 -07:00
add a 1px transparent border around an image to prevent twitter from mangling it into a jpg.
sadly, this trick doesn't work anymore.
2021-08-01 00:38:05 -07:00
### [trash](/sh/trash#L6)
2021-07-30 18:08:59 -07:00
### [trunc](/sh/trunc#L6)
2021-07-30 17:59:30 -07:00
truncate text to fit within your terminal using the unicode character `…`.
2021-07-30 18:08:59 -07:00
### [unscreen](/sh/unscreen#L6)
2021-07-30 17:59:30 -07:00
i don't use this anymore~
2021-08-01 00:38:05 -07:00
### [wat](/sh/wat#L8)
2021-07-30 18:08:59 -07:00
### [wipe](/sh/wipe#L6)
2021-07-30 17:59:30 -07:00
clear the screen and its scrollback, then print a high-contrast horizontal line.
using this, you'll know with absolute certainty that you're looking at the top of your history,
and that your terminal's scrollback didn't cap out and eat text.
**TODO:** rename because wipe(1) already exists.
## miscellaneous
2021-08-01 02:14:30 -07:00
### [dirprev (zshrc)](/home/zshrc#L70)
2021-07-30 17:59:30 -07:00
rotate and change to the previous directory in the directory stack
without consuming the prompt.
2021-08-01 02:14:30 -07:00
### [dirnext (zshrc)](/home/zshrc#L77)
2021-07-30 17:59:30 -07:00
rotate and change to the next directory in the directory stack
without consuming the prompt.
2021-08-01 02:14:30 -07:00
### [dirup (zshrc)](/home/zshrc#L84)
2021-07-30 17:59:30 -07:00
change to the parent directory of the current working directory
without consuming the prompt.
2021-08-01 02:14:30 -07:00
### [dirview (zshrc)](/home/zshrc#L91)
2021-07-30 17:59:30 -07:00
use a fuzzy finder to select a recent directory in the directory stack
and change to it without consuming the prompt.
2021-08-01 02:14:30 -07:00
### [OMFG (zshrc)](/home/zshrc#L165)
2021-07-30 17:59:30 -07:00
silence stdout.
2021-08-01 02:14:30 -07:00
### [STFU (zshrc)](/home/zshrc#L166)
2021-07-30 17:59:30 -07:00
silence stderr.
2021-08-01 02:14:30 -07:00
### [WHOA (zshrc)](/home/zshrc#L167)
2021-07-30 17:59:30 -07:00
expand to several C/C++ flags to ease development.
2021-08-01 02:14:30 -07:00
### [WELP (zshrc)](/home/zshrc#L168)
2021-07-30 17:59:30 -07:00
expand to C++ flags to enable a C++-as-C facade.
2021-08-01 02:14:30 -07:00
### [pl (zshrc)](/home/zshrc#L172)
2021-07-30 17:59:30 -07:00
print each argument on its own line.
2021-08-01 02:14:30 -07:00
### [tw (zshrc)](/home/zshrc#L175)
2021-07-30 17:59:30 -07:00
invoke `twitch` as a job with both stdout and stderr silenced.
2021-08-01 02:14:30 -07:00
### [reload (zshrc)](/home/zshrc#L219)
2021-07-30 17:59:30 -07:00
reload zsh by wiping temp files, recompiling rc files,
and replacing the current process with a new zsh process.
### [reload (bashrc)](/home/bashrc#L49)
**TODO:** respect initctl like in `.zshrc`.
### [has (-shrc)](/home/-shrc#L8)
hardcoded here for convenience.
### [ADDPATH (-shrc)](/home/-shrc#L24)
append a directory to `$PATH` if it isn't already present.
### [fils (-shrc)](/home/-shrc#L113)
(GNU du) display human-friendly filesizes for the files in a directory.
### [lsa (-shrc)](/home/-shrc#L114)
(GNU ls) list files with directories and dotfiles ordered first.
### [perlu (-shrc)](/home/-shrc#L115)
invoke perl expecting files with UTF-8 encoding.
### [rgn (-shrc)](/home/-shrc#L116)
invoke ripgrep without respecting `.gitignore` files.
### [cms (-shrc)](/home/-shrc#L117)
invoke cryptominisat5 with less noise.
### [curls (-shrc)](/home/-shrc#L118)
invoke curl with less noise.
### [get (-shrc)](/home/-shrc#L122)
retrieve the most recent files from the default branch of a git repository, and not much else.
### [gs (-shrc)](/home/-shrc#L123)
invoke git's status subcommand.
### [gd (-shrc)](/home/-shrc#L124)
invoke git's diff subcommand with fewer lines of context.
### [gds (-shrc)](/home/-shrc#L125)
display difference stats from git.
### [gl (-shrc)](/home/-shrc#L126)
invoke git's log subcommand with a single line per commit.
### [glo (-shrc)](/home/-shrc#L127)
navigate git's commit tree succinctly.
### [g1 (-shrc)](/home/-shrc#L128)
display the most recent git commit.
### [gr (-shrc)](/home/-shrc#L129)
display remote git repositories verbosely.
### [gb (-shrc)](/home/-shrc#L130)
display the current git branch.
2021-08-01 00:38:05 -07:00
### [revend (-shrc)](/home/-shrc#L137)
2021-07-30 17:59:30 -07:00
reverse the 4-byte endianness of a single file. *this is an in-place operation!*
2021-08-01 00:38:05 -07:00
### [clone (-shrc)](/home/-shrc#L139)
2021-07-30 17:59:30 -07:00
invoke rsync suitably for creating virtually indistinguishable copies of files.
2021-08-01 00:38:05 -07:00
### [aligntabs (-shrc)](/home/-shrc#L140)
2021-07-30 17:59:30 -07:00
align tab-delimited fields in stdin.
2021-08-01 00:38:05 -07:00
### [crawla (-shrc)](/home/-shrc#L141)
2021-07-30 17:59:30 -07:00
play Dungeon Crawl: Stone Soup through ssh on the akrasiac server.
2021-08-01 00:38:05 -07:00
### [crawlz (-shrc)](/home/-shrc#L142)
2021-07-30 17:59:30 -07:00
play Dungeon Crawl: Stone Soup through ssh on the develz server.
2021-08-01 00:38:05 -07:00
### [ll (-shrc)](/home/-shrc#L145)
2021-07-30 17:59:30 -07:00
list files verbosely, fancily, ordered, but not recursively.
2021-08-01 00:38:05 -07:00
### [diff (-shrc)](/home/-shrc#L153)
2021-07-30 17:59:30 -07:00
use git's diff subcommand for general diffing.
2021-08-01 00:38:05 -07:00
### [gc (-shrc)](/home/-shrc#L154)
2021-07-30 17:59:30 -07:00
columnize text by using git's column subcommand.
2021-08-01 00:38:05 -07:00
### [counts (-shrc)](/home/-shrc#L155)
2021-07-30 17:59:30 -07:00
count files in the current directory, including files found recursively.
2021-08-01 00:38:05 -07:00
### [exts (-shrc)](/home/-shrc#L156)
2021-07-30 17:59:30 -07:00
count and sort file extensions in the current directory, including files found recursively.
2021-08-01 00:38:05 -07:00
### [nocom (-shrc)](/home/-shrc#L157)
2021-07-30 17:59:30 -07:00
strip single-line C-like and shell-like comments.
2021-08-01 00:38:05 -07:00
### [sortip (-shrc)](/home/-shrc#L158)
2021-07-30 17:59:30 -07:00
sort numerically by IPv4 segments.
2021-08-01 00:38:05 -07:00
### [jrep (-shrc)](/home/-shrc#L159)
2021-07-30 17:59:30 -07:00
extract strings comprised of basic ASCII or Japanese codepoints.
2021-08-01 00:38:05 -07:00
### [bomb (-shrc)](/home/-shrc#L160)
2021-07-30 17:59:30 -07:00
add a Byte-Order Mark to a file.
2021-08-01 00:38:05 -07:00
### [cleanse (-shrc)](/home/-shrc#L161)
2021-07-30 17:59:30 -07:00
strip unprintable and non-ASCII characters.
2021-08-01 00:38:05 -07:00
### [rot13 (-shrc)](/home/-shrc#L162)
2021-07-30 17:59:30 -07:00
rot13 with numbers rotated as well.
2021-08-01 00:38:05 -07:00
### [unwrap (-shrc)](/home/-shrc#L163)
2021-07-30 17:59:30 -07:00
join paragraphs into one line each.
2021-08-01 00:38:05 -07:00
### [double (-shrc)](/home/-shrc#L164)
2021-07-30 17:59:30 -07:00
print every line twice. <br/> print every line twice.
2021-08-01 00:38:05 -07:00
### [join2 (-shrc)](/home/-shrc#L165)
2021-07-30 17:59:30 -07:00
join every other line.
2021-08-01 00:38:05 -07:00
### [katagana (-shrc)](/home/-shrc#L166)
2021-07-30 17:59:30 -07:00
convert katakana codepoints to their equivalent hiragana.
useful for translating [debug text from ancient games.](https://tcrf.net/)
2021-08-01 00:38:05 -07:00
### [picky (-shrc)](/home/-shrc#L168)
2021-07-30 17:59:30 -07:00
TODO
2021-08-01 00:38:05 -07:00
### [unused (-shrc)](/home/-shrc#L169)
2021-07-30 17:59:30 -07:00
TODO
2021-08-01 00:38:05 -07:00
### [makepkgf (-shrc)](/home/-shrc#L170)
2021-07-30 17:59:30 -07:00
make the freakin' package!
2021-08-01 00:38:05 -07:00
### [rakef (-shrc)](/home/-shrc#L171)
2021-07-30 17:59:30 -07:00
make the freakin' gem!
2021-08-01 00:38:05 -07:00
### [eashare (-shrc)](/home/-shrc#L173)
2021-07-30 17:59:30 -07:00
upload a file and copy its URL to the clipboard.
**NOTE:** this only works on MSYS2 for now.
**NOTE:** i lied, this doesn't work at all.