scripts
overview
A collection of personal scripts I use.
I use most of these scripts for convenience and to save on typing.
More recently I've been making an effort to learn PowerShell as I tend to use windows a fair bit too, so there are a few one-off scripts used for that too.
- nix/ - Scripts for POSIX (Unix, MacOS, Linux, etc) machines. Mostly written in
sh
andbash
. - win/ - Scripts for Windows. Using
PowerShell
- any/ - Scripts for multiple environments (mostly
Python
).
install
POSIX (Linux, Mac, BSD)
I've created an install script (bash).
usage: ./install [ARGUMENTS] [SCRIPT]
SCRIPTS
Optionally, you can specify a script to install.
Any specified scripts must be the filepath to the
script (not just the filename).
ARGUMENTS
-f, --force overwrites files when installing
-r, --reinstall re-install scripts already existing in
destination directory
-d, --dest [DEST] set the install destination
-a, --all install ALL the scripts ('y' to all prompts)
-l, --link 'ln' the script (not cp).
-h, --help print this dialog
Windows
I haven't got a script for Windows since there aren't enough scripts to justify the effort (yet).
What I usually do is just put the scripts in a directory and add it to the PATH
environment variable.
scripts
Powershell
- random - a script I use to select a random item in a directory.
- zipto7z - converts all .zip files in current directory to .7z.
- flac2mp3 - convert flac files to mp3 files using ffmpeg.
Python
- d2h - convert decimal numbers to hexadecimal.
- h2d - convert hexadecimal numbers to decimal.
- jiggle - move the mouse 1px every minute - keep the screen awake.
POSIX shell (and bash)
strings & numbers
Scripts related to string parsing/manipulation
- strindex - print the index (from 0..n) of the first character in substring $1 found in string $2.
- grepf - find all files in dir $1, that conatin string $2. I use this one a lot.
- randstr - generate a random string.
file management
- backup - cp input files $@ from
filename
tofilename.bak
(mv with-m
). - catrm -
rm -i
but with the option to cat the file. - flac2mp3 - converts .flac files $@ to .mp3. Requires ffmpeg.
- openurl - xdg-open all links found in files $@.
- mkdcp - make directory $1 and copy files into it ($2..$n).
- mkdmv - make directory $1 and move files into it ($2..$n)
- mkdnvim - make directory $1, touch file $2 and open file $2 in $EDITOR.
- mkdtouch - make a directory $1, touch files in it ($2..$n).
tooling
- pyserve - shorthand for
python3 -m http.server --directory $1
. - git-cfg - shorthand for calling
git config --local user.name $1 && git config --local user.email $2
.- You can also use it for setting global config using
-g
- You can also use it for setting global config using
- git-clone-bulk - clone a list of git repositories.
- git-pull-all - pull all remote git branches from the current upstream.
- git-pradd - git diff $@, for each prompt y/n whether to git add it
- git-init - initialize a git server repository (I use it for my own remote server)
- gobuild - build a go module in all available output formats, useful for releases.
- preview-md - convert a markdown file $1 to html, open if $2 == "-o" or "--open".
- Uses cmark by default, set conversion tool and default output destination in src.
- compress-pdf - compress a .pdf file ($1), requires ghostscript (gs).
- rled - invoke ed with a readline wrapper (for input history)
- gnome-shell-cycle-wallpaper - One I used to cycle the wallpaper on a GNOME desktop infrequently
misc
- shush - run $@ in the background and hide output.
- pomodoro - a pomodoro timer.
- while-true - clear the terminal, run $1 sleep ($2 || 1 sec), repeat forever (Ctrl+C to cancel).
- onfilech - stat a file ($1) every 10 seconds, if the output changes, run a command ($2...$n).
- awkcol - column with awk (at one point column wasn't available but awk was)
depreciated
This contains scripts that I once used but aren't required anymore (or I eventually realised were useless).
authors
- gearsix