12 KiB
obligatory personal dotfiles repository
(plus some little shell scripts)
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
NOTE: everything below this line is overwritten and regenerated by sh/document
.
shell functions
arith
perform arithmetic using the shell and display the result.
aur
download, edit, make, and install packages from the AUR. it's a little broken.
autosync
combine inotifywait
and rsync
.
this is sometimes nicer than ssh
-ing into a server and running vim
remotely.
cdbusiest
cd to the directory with the most files in it, counted recursively.
colors
print out all the foreground and background terminal color combinations. excluding boilerplate, this script is a mere a 76-characters long!
compandy
generate compand arguments for ffmpeg audio filters. this is kinda pointless now that acompressor is wildly supported.
__setup_clang_ubuntu (sh/compile)
compile
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.
confirm
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
days
compute days since a given date.
$ days 'January 1 1970'
18838
dbusiest
display the directory with the most files in it, counted recursively.
dfu
pretty-print df
in GiB.
TODO: restore examples.
disf
disassemble a single function from an unstripped executable, unreliably.
e
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:
has
print the result of which
if the program is found, else simply return 1.
export CC="$(has clang || has clang-3.8 || has gcc)"
hex
perform arithmetic using the shell and display the result as an unsigned 32-bit integer in hexadecimal.
ify
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
is_empty
return 0 if the directory given by argument is empty.
isup
return 0 if a given website returns a 2xx HTTP code.
minutemaid
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
monitor
this is watch
loosely reimplemented as a shell script.
noccom
strip C-like comments; both multi-line and single-line.
now
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
pacbm
list installed pacman packages by their filesize, and the sum, ascending. requires expac
.
$ pacbm | head -n -1 | tail -2
204.78M clang
235.44M linux-firmware
pause
pause — the companion script of confirm
.
$ pause
Press any key to continue
$
pre
dump all the #define
s that $CC $CPPFLAGS $CFLAGS $LDFLAGS
would result in.
TODO: restore examples.
randir
display a random directory in the current working directory.
$ randir
./sh
rs
record screen. does not record audio. currently only works on Windows (gdigrab). i'm sure there's something equivalent for Linux.
sc
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
.
scramble
scrambles text in a predictable way using regex.
sacbremls ttex in a pdrceailtbe way unsig reegx.
screeny
i don't use this anymore~
scropt
run scrot
through optipng
and save the result to ~/play/$(now).png
.
$ ~/sh/sc $(~/sh/scropt -s -d0.5)
slit
view specific columns of text.
slitt
view specific columns of text.
this version of slit
uses tabs for its field separators.
sram
convert between a couple saveram formats for N64 emulators.
mpv_watch (sh/streamcrap)
watch something in mpv with a bunch of extra audio filtering crap.
mpv_stream (sh/streamcrap)
watch a stream in mpv with a bunch of extra audio filtering crap.
twitch (sh/streamcrap)
watch a twitch stream in mpv with a bunch of extra audio filtering crap.
yt (sh/streamcrap)
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.
ytg (sh/streamcrap)
watch a youtube video. like yt
, but with a preference for different formats.
ytll (sh/streamcrap)
watch a stream on youtube in mpv, etcetera etcetera. this is the low latency version that does not support seeking.
ytgll (sh/streamcrap)
watch a stream on youtube in mpv. like ytll
, but with a preference for different formats.
sv
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.
tpad
add a 1px transparent border around an image to prevent twitter from mangling it into a jpg. sadly, this trick doesn't work anymore.
trunc
truncate text to fit within your terminal using the unicode character …
.
unscreen
i don't use this anymore~
wipe
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
dirprev (zshrc)
rotate and change to the previous directory in the directory stack without consuming the prompt.
dirnext (zshrc)
rotate and change to the next directory in the directory stack without consuming the prompt.
dirup (zshrc)
change to the parent directory of the current working directory without consuming the prompt.
dirview (zshrc)
use a fuzzy finder to select a recent directory in the directory stack and change to it without consuming the prompt.
OMFG (zshrc)
silence stdout.
STFU (zshrc)
silence stderr.
WHOA (zshrc)
expand to several C/C++ flags to ease development.
WELP (zshrc)
expand to C++ flags to enable a C++-as-C facade.
pl (zshrc)
print each argument on its own line.
tw (zshrc)
invoke twitch
as a job with both stdout and stderr silenced.
reload (zshrc)
reload zsh by wiping temp files, recompiling rc files, and replacing the current process with a new zsh process.
reload (bashrc)
TODO: respect initctl like in .zshrc
.
has (-shrc)
hardcoded here for convenience.
ADDPATH (-shrc)
append a directory to $PATH
if it isn't already present.
fils (-shrc)
(GNU du) display human-friendly filesizes for the files in a directory.
lsa (-shrc)
(GNU ls) list files with directories and dotfiles ordered first.
perlu (-shrc)
invoke perl expecting files with UTF-8 encoding.
rgn (-shrc)
invoke ripgrep without respecting .gitignore
files.
cms (-shrc)
invoke cryptominisat5 with less noise.
curls (-shrc)
invoke curl with less noise.
get (-shrc)
retrieve the most recent files from the default branch of a git repository, and not much else.
gs (-shrc)
invoke git's status subcommand.
gd (-shrc)
invoke git's diff subcommand with fewer lines of context.
gds (-shrc)
display difference stats from git.
gl (-shrc)
invoke git's log subcommand with a single line per commit.
glo (-shrc)
navigate git's commit tree succinctly.
g1 (-shrc)
display the most recent git commit.
gr (-shrc)
display remote git repositories verbosely.
gb (-shrc)
display the current git branch.
revend (-shrc)
reverse the 4-byte endianness of a single file. this is an in-place operation!
clone (-shrc)
invoke rsync suitably for creating virtually indistinguishable copies of files.
aligntabs (-shrc)
align tab-delimited fields in stdin.
crawla (-shrc)
play Dungeon Crawl: Stone Soup through ssh on the akrasiac server.
crawlz (-shrc)
play Dungeon Crawl: Stone Soup through ssh on the develz server.
ll (-shrc)
list files verbosely, fancily, ordered, but not recursively.
diff (-shrc)
use git's diff subcommand for general diffing.
gc (-shrc)
columnize text by using git's column subcommand.
counts (-shrc)
count files in the current directory, including files found recursively.
exts (-shrc)
count and sort file extensions in the current directory, including files found recursively.
nocom (-shrc)
strip single-line C-like and shell-like comments.
sortip (-shrc)
sort numerically by IPv4 segments.
jrep (-shrc)
extract strings comprised of basic ASCII or Japanese codepoints.
bomb (-shrc)
add a Byte-Order Mark to a file.
cleanse (-shrc)
strip unprintable and non-ASCII characters.
rot13 (-shrc)
rot13 with numbers rotated as well.
unwrap (-shrc)
join paragraphs into one line each.
double (-shrc)
print every line twice.
print every line twice.
join2 (-shrc)
join every other line.
katagana (-shrc)
convert katakana codepoints to their equivalent hiragana. useful for translating debug text from ancient games.
picky (-shrc)
TODO
unused (-shrc)
TODO
makepkgf (-shrc)
make the freakin' package!
rakef (-shrc)
make the freakin' gem!
eashare (-shrc)
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.