1
0
Fork 0
mirror of https://github.com/notwa/rc synced 2024-05-18 09:53:22 -07:00
rc/README.md

529 lines
11 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)_
2016-06-27 07:12:01 -07:00
## stuff defined in RC files
2016-06-27 06:02:53 -07:00
2016-06-27 07:02:58 -07:00
such as [.bashrc](/home/bashrc) and [.zshrc](/home/zshrc)
but mostly [-shrc](/home/-shrc) and [.streamcrap](/home/streamcrap)
2016-06-27 06:02:53 -07:00
2016-06-27 07:02:58 -07:00
### reload
exec's the current shell.
2018-02-21 01:42:28 -08:00
if it's `zsh`, it'll also recompile `.zshrc` so everything actually reloads.
2016-06-27 07:02:58 -07:00
### ADDPATH
adds a directory to `$PATH` if it isn't already there.
### ify
pipes a command through another command, so you can pass arguments at the end as usual.
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
```
### has
prints the result of `which` if the program is found, or shuts up and returns 1.
```
2017-03-04 23:12:45 -08:00
export CC="$(has clang || has clang-3.8 || has gcc)"
2016-06-27 07:02:58 -07:00
```
### revend
reverses the 4-byte endianness of a file. this is an in-place operation!
### exts
prints and sorts the most used file extensions in the CWD.
### freq
prints the most frequently used commands found in `~/.histfile`.
arguments are passed to `head`.
```
$ freq
2018-02-21 01:42:28 -08:00
2533 git
1600 tw
1572 twitch
1019 yt
994 wipe;
621 compile
616 ls
567 gd
522 ssh
521 less
2016-06-27 07:02:58 -07:00
```
2018-02-21 01:42:28 -08:00
**TODO:** fix `:` and extraneous semicolons showing up in results.
2016-06-27 07:02:58 -07:00
### nocom
strips lines that begin with a `#` character.
### jrep
extracts ascii and japanese unicode characters.
### bomb
adds a Byte Order Mark to a file.
### cleanse
extracts readable ascii characters.
### rot13
rot13 with rotated numbers as well.
### unwrap
unwraps text that was wrapped using double-newlines as spacing,
e.g. this readme file.
2017-03-06 02:39:48 -08:00
### double
prints every line twice.
prints every line twice.
2019-05-27 03:02:58 -07:00
### join2
joins every other line.
```
$ echo "hey\nyou\nout there\nwe bringing it live" | join2
hey you
out there we bringing it live
```
### katagana
converts katakana to hiragana.
2019-05-27 03:05:59 -07:00
useful for translating [debug text from ancient games.](https://tcrf.net/)
2019-05-27 03:02:58 -07:00
2016-06-27 07:02:58 -07:00
### picky + unused
2019-05-27 03:15:55 -07:00
attempts to find any non-standard packages that were installed
on an Arch Linux box so that you can make note
to install them later on a fresh installation.
2016-06-27 07:02:58 -07:00
`unused` will print unused packages instead.
### makepkgf + rakef
make the freakin' package!
### trash
given a number of bytes, outputs binary garbage from `/dev/random`.
2018-02-21 01:42:28 -08:00
### wipe
2019-05-27 02:23:13 -07:00
(zsh) clears the screen and scrollback and prints an ugly horizontal line,
2018-02-21 01:42:28 -08:00
so you know with absolute certainty that you're looking
2019-05-27 02:23:13 -07:00
at the top of your history, and that your terminal's scrollback
2018-02-21 01:42:28 -08:00
didn't cap out and eat text.
```
$ wipe; ./configure && make
[insert a bajillion lines you'd never be able to find the top of unless
you piped it to a file or less or wiped scrollback beforehand]
```
2019-05-27 02:23:13 -07:00
### yt
2016-06-27 07:02:58 -07:00
watches a youtube video through mpv with a bunch of audio filtering crap.
can be given a full URL or just a video ID.
remaining arguments are passed to mpv.
2019-05-27 02:23:13 -07:00
there exist several variants for various situations: `ytg`, `ytll`, `ai`, `asmr`.
2018-02-21 01:42:28 -08:00
### twitch
2016-06-27 07:02:58 -07:00
2018-02-21 01:42:28 -08:00
watches twitch streams through mpv with a bunch of audio filtering crap.
2016-06-27 07:02:58 -07:00
give it a username.
remaining arguments are passed to mpv.
2016-06-27 06:02:53 -07:00
## shell scripts
most (but not all) stuff that's written for bash will work in zsh too.
2017-03-04 23:12:45 -08:00
if it just says `(sh)` then it'll probably work on any shell,
but might depend on GNU awk.
2016-06-27 06:02:53 -07:00
2016-06-27 06:04:09 -07:00
### [arith](/sh/arith) + [hex](/sh/hex)
2016-06-27 06:02:53 -07:00
2016-06-27 06:04:09 -07:00
(zsh) does arithmetic using the shell.
2016-06-27 06:02:53 -07:00
```
2016-06-27 07:02:58 -07:00
$ noglob arith 10**(6/20.)
2016-06-27 06:02:53 -07:00
1.9952623149688795
2016-06-27 06:04:09 -07:00
$ hex 0x221EA8-0x212020
0000FE88
2016-06-27 06:02:53 -07:00
```
### [aur](/sh/aur)
(bash) downloads, edits, makes, and installs packages from the [AUR.](//aur.archlinux.org)
2016-06-27 06:21:17 -07:00
it's a little broken.
2016-06-27 06:02:53 -07:00
```
$ aur -eyoI cmdpack-uips applyppf
```
2018-02-21 01:42:28 -08:00
### [autosync](/sh/autosync)
(zsh) combines inotifywait and rsync.
sometimes nicer than ssh-ing into a server and running vim remotely.
2016-06-27 06:02:53 -07:00
### [cdbusiest](/sh/cdbusiest) + [dbusiest](/sh/dbusiest)
(zsh) cd to the directory with the most files in it (recursive).
dbusiest just outputs file counts without changing the directory.
useful for finding the biggest stinkers when archiving.
```
$ cd
$ cdbusiest
197195 src
$ pwd
/home/notwa/src
```
### [colors](/sh/colors)
(bash) print out all the foreground and background terminal color combinations.
a 76-character script!
### [compandy](/sh/compandy)
(zsh) a dumb thing to generate compand arguments for ffmpeg audio filters.
2018-02-21 01:42:28 -08:00
kinda pointless now that acompressor is wildly supported.
### [compile](/sh/compile)
(zsh) a huge mess for compiling single-file C and C++ programs.
supports gcc and clang on \*nix,
and mingw64 gcc, msvc clang, and regular msvc on Windows.
2018-02-21 01:51:32 -08:00
tested on x86\_64 and on ARMv7 as well.
2019-05-27 02:23:13 -07:00
does not support MacOS, maybe someday…
2018-02-21 01:42:28 -08:00
defaults to gnu11 and gnu++1z as C and C++ standards respectively.
2018-02-21 01:52:53 -08:00
defaults to clang, gcc, and msvc in that order.
2018-02-21 01:42:28 -08:00
`compile` attempts to guess the most sane switches for any program,
so that compilation may reduce to:
```sh
# debug build
compile rd.c
2018-02-21 01:52:53 -08:00
compile debug rd.c
2018-02-21 01:42:28 -08:00
# debug build with warning/error flags defined in .-shrc
# (requires .zshrc for global alias expansion)
compile WHOA rd.c
# likewise for C++
compile WHOA WELP rd.cc
compile WHOA WELP rd.cpp
# "derelease" build (release build with debug information)
compile derelease WHOA rd.c
# release build (with symbols stripped)
compile release WHOA rd.c
# hardened build (only useful on *nix)
compile hardened WHOA rd.c
# specifying compiler
compile gcc WHOA rd.c
compile msvc WHOA rd.c
compile release clang WHOA rd.c
# compile and execute (FIXME: writing to /tmp is a security concern)
compile derelease rd.c && /tmp/rd
```
also contains a helper function that dumps the commands required to
install a recent version of clang on an ubuntu machine.
2016-06-27 06:02:53 -07:00
### [confirm](/sh/confirm)
(bash/zsh) displays a simple yes/no prompt and returns 0 or 1 respectively.
2016-06-27 06:21:17 -07:00
```
$ confirm && echo yay || echo nay
Continue? [y/N] y
yay
$ confirm && echo yay || echo nay
Continue? [y/N] n
nay
```
2016-06-27 06:02:53 -07:00
### [days](/sh/days)
(bash) compute days since a date.
```
$ days 'January 1 1970'
2017-03-04 23:12:45 -08:00
17229
2016-06-27 06:02:53 -07:00
```
### [dfu](/sh/dfu)
2019-05-27 02:23:13 -07:00
(sh) pretty-print `df` in GiB.
2016-06-27 06:02:53 -07:00
```
$ dfu
2018-02-21 01:42:28 -08:00
Filesystem Used Max Left Misc
/dev 0.00 0.45 0.45 0.00
/ 12.13 13.75 1.62 0.75
/boot 0.02 0.10 0.07 0.00
/media/chibi 1275.73 1304.45 28.72 69.88
2016-06-27 06:02:53 -07:00
```
2019-05-27 02:35:07 -07:00
### [disf](/sh/disf)
disassembles a single function from an unstripped executable.
not robust.
2016-06-27 06:02:53 -07:00
### [e](/sh/e)
2017-03-04 23:12:45 -08:00
(zsh) wraps around $EDITOR to run as root if necessary.
still needs some work to detect root-owned directories.
2016-06-27 06:02:53 -07:00
```
$ e /etc/sudoers
[sudo] password for notwa:
```
### [is\_empty](/sh/is_empty)
(bash) returns 0 if the directory given by $1 is empty.
### [isup](/sh/isup)
(zsh) returns 0 if a website returns a 2xx HTTP code.
```
$ isup google.com && echo yay || echo nay
yay
$ isup fdhafdslkjgfjs.com && echo yay || echo nay
nay
```
### [lsarchive](/sh/lsarchive) + [unarchive](/sh/unarchive)
(zsh) guess what these do. written by Sorin Ionescu.
includes autocomplete files.
### [lsz](/sh/lsz)
(zsh) a needlessly fancy alternative to `ls`.
2016-06-27 06:21:17 -07:00
2016-06-27 06:02:53 -07:00
based on lsf or something, which might be [a gist somewhere.](//gist.github.com/notwa)
2016-06-27 06:21:17 -07:00
you can find [similar, more mature projects on github.](//github.com/trapd00r/ls--)
2016-06-27 06:02:53 -07:00
### [minutemaid](/sh/minutemaid)
(zsh) returns 0 if the current minute is divisible by a number.
2016-06-27 06:21:17 -07:00
2016-06-27 06:02:53 -07:00
note that a minute is relative to the seconds since the epoch,
not the minute of the hour.
```
# crontab usage:
* * * * * minutemaid 9 cd repo && git pull # runs every nine minutes
```
### [monitor](/sh/monitor)
2018-02-21 01:42:28 -08:00
(zsh) literally just `watch` reimplemented as a shell script. kinda nice though.
2016-06-27 06:02:53 -07:00
### [now](/sh/now)
(bash) returns the local date-time in a sortable format.
will take a date or a file as an argument too.
```
$ now
2019-05-27_35083906
$ now ~/sh/monitor
2017-03-14_82387259
2016-06-27 06:02:53 -07:00
$ now '@1234567890'
2009-02-13_84690000
2016-06-27 06:02:53 -07:00
```
### [pacbm](/sh/pacbm)
(zsh) lists installed pacman packages by their filesize, and the sum, ascending.
requires `expac`.
```
$ pacbm | head -n -1 | tail -2
2018-02-21 01:42:28 -08:00
204.78M clang
235.44M linux-firmware
2016-06-27 06:02:53 -07:00
```
### [pacman-list-disowned](/sh/pacman-list-disowned)
(zsh?) lists disowned pacman files. this might take a while.
written by Benjamin Boudreau and Sorin Ionescu.
### [pause](/sh/pause)
2016-06-27 06:21:17 -07:00
(bash/zsh) pause; the companion script of `confirm`.
2016-06-27 06:02:53 -07:00
```
$ pause
Press any key to continue
$
```
### [pre](/sh/pre)
(bash/zsh) dumps all the #defines that `$CC $CPPFLAGS $CFLAGS $LDFLAGS` would result in.
2016-06-27 06:02:53 -07:00
```
$ pre | shuf | head -10
#define __NO_MATH_INLINES 1
#define __FLT_MIN_10_EXP__ (-37)
#define __INT_LEAST32_TYPE__ int
#define __FLT_MIN_EXP__ (-125)
#define __LDBL_MIN_EXP__ (-16381)
#define __UINT8_C_SUFFIX__
#define __WINT_UNSIGNED__ 1
#define __INT_LEAST16_FMTd__ "hd"
#define __UINT_FAST32_MAX__ 4294967295U
#define __SSE__ 1
```
### [psbm](/sh/psbm)
(sh) lists processes by their memory usage, and the sum, ascending.
```
2016-06-27 06:21:17 -07:00
$ psbm | head -n -1 | tail -2
2017-03-04 23:12:45 -08:00
185.08M 1163 chromium
199.95M 1060 chromium
2016-06-27 06:02:53 -07:00
```
### [randir](/sh/randir)
(sh) outputs a random directory in the working directory.
```
$ randir
./sh
```
2018-02-21 01:42:28 -08:00
### [rs](/sh/rs)
2018-02-21 01:51:32 -08:00
(zsh) record screen. does not record audio.
2018-02-21 01:42:28 -08:00
2019-05-27 02:23:13 -07:00
currently only works on Windows (gdigrab).
i'm sure there's something equivalent for Linux.
2018-02-21 01:42:28 -08:00
2016-06-27 06:02:53 -07:00
### [sc](/sh/sc)
2017-03-04 23:12:45 -08:00
(bash) uploads given files to a webserver and returns a direct link for sharing.
2016-06-27 06:02:53 -07:00
you'll want to tweak this if you use it yourself.
has some extra logic for screenshots created by `scropt`.
### [scramble](/sh/sc)
(bash) scrambles text in a predictable way using regex.
(bhas) sacbremls ttex in a pdrceailtbe way unsig reegx.
### [screeny](/sh/screeny) + [unscreen](/sh/unscreen)
(zsh) sets up and detaches a screen for running daemons as other users, etc.
will close any existing screens of the same name using its companion script, unscreen.
e.g. run znc as user znc in a screen called znc: `screeny znc znc znc -f`. znc!
2018-02-21 01:42:28 -08:00
<!--(you should really just use tmux though)-->
2016-06-27 06:02:53 -07:00
### [scropt](/sh/scropt)
2016-06-27 07:02:58 -07:00
(bash) runs `scrot` through `optipng` and saves to `~/play/$(now).png`.
2016-06-27 06:02:53 -07:00
```
$ ~/sh/sc $(~/sh/scropt -s -d0.5)
```
### [similar](/sh/similar)
2017-03-04 23:12:45 -08:00
(sh) sorts stdin and highlights similarities between adjacent lines.
2016-06-27 06:02:53 -07:00
### [slit](/sh/slit) + [slitt](/sh/slitt)
2016-06-27 06:02:53 -07:00
2016-06-27 06:21:17 -07:00
(zsh) views specific columns of text.
2016-06-27 06:02:53 -07:00
via [pretzo.](https://github.com/sorin-ionescu/prezto/)
```
2016-06-27 06:21:17 -07:00
$ df | slit 1 5
2016-06-27 06:02:53 -07:00
Filesystem Use%
dev 0%
run 1%
/dev/sda6 30%
tmpfs 3%
tmpfs 0%
tmpfs 1%
tmpfs 1%
```
`slitt` is exactly the same, but it works with tabs instead of spaces.
2016-06-27 06:02:53 -07:00
### [sram](/sh/sram)
(zsh) converts between a couple saveram formats for N64 emulators.
### [sv](/sh/sv)
2017-02-09 22:59:53 -08:00
(bash) collects the lastmost value of every key.
takes the field separator as an argument.
```
echo "this=that\nthem=those\nthis=cat" | sv =
this=cat
them=those
```
2016-06-27 06:02:53 -07:00
2018-02-21 01:42:28 -08:00
### [tpad](/sh/tpad)
2018-02-21 01:51:32 -08:00
(bash) adds a 1px transparent border around an image
so that twitter doesn't mangle it into a jpg.
2019-05-27 02:23:13 -07:00
sadly, this trick doesn't work anymore.
2018-02-21 01:42:28 -08:00
2016-06-27 06:02:53 -07:00
### [trunc](/sh/trunc)
(bash) truncates text to fit within your terminal using the unicode character `…`.
```
$ echo $COLUMNS
64
$ unwrap /usr/share/licenses/common/GPL3/license.txt | trunc | head
GNU GENERAL PUBLIC LICENSE …
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.
Preamble
The GNU General Public License is a free, copyleft license fo…
The licenses for most software and other practical works are …
2018-02-21 01:51:32 -08:00
$ echo 'this is just an example; these scripts are (mostly) unlicensed.'
2016-06-27 06:02:53 -07:00
```