Scripts extracted from my dotfiles, see index
This includes:
- Pure utility/wrangling scripts like
lower
,upper
,chomp
,rcut
,tally
,unique
,average
; which help process outputs of other commands, which are commonly used by other shellscripts I put up on other repositories -- hence the reason to make this repo so they're easily installable - Some helper/conversion scripts like
to-png
,to-jpeg
,rotate-img
,tq
(jq
fortoml
) - Cross-Platform scripts that provide interaction with clipboard/prompting user for input/sending notifications on Mac/Linux/Termux
This does not install these and requires you to have these available (on your $PATH
) before installing this:
- GNU coreutils (or some compatible set of utilities) - e.g.,
cut
,uniq
,tr
- util-linux - e.g.,
shuf
,rev
,kill
find
grep
curl
wget
awk
sed
realpath
Optional/Recommended (some scripts here will fail if these aren't present)
Needed for installing/building core utils used in other scripts here:
python3
- https://www.python.org/downloads/go
- https://go.dev/doc/install (skips installs ifgo
not found)
To check for dependencies/path issues, run make
To install, run make install
:
git clone https://github.com/purarue/pura-utils
cd ./pura-utils
make # check for dependencies
make install
Or use bpkg
to automate the manual git clone
/cd
/make
:
bpkg install -g purarue/pura-utils
To setup go
to build packages, add something like this to your .zshrc
/.bashrc
:
# if not already set
export XDG_DATA_HOME="${HOME}/.local/share"
# Go (see 'go help install')
export GOPATH="${XDG_DATA_HOME}/go"
export GOBIN="${GOPATH}/bin"
# update $PATH
export PATH="\
${HOME}/.local/bin:\
${XDG_DATA_HOME}/go/bin:\
${PATH}"
On termux
, you need to install the termux-api
package (from F-Droid
)
Requires python 3.8+
/golang
to install:
make install
installs:
- a few
go
CLI tools - (See https://go.dev/doc/install for install instructions)newest
- print most recently modified file in directorychomp
- remove whitespace/empty lines from command outputon_machine
- detect what operating system/machine you're currently on
- The
./python-src
package, which includes helper functions, see python-src/README.md. Also installs required python libraries for any python scripts here
... and shellscripts:
havecmd
- command to check if commands are availabledir-size
- prints the total size of a directorysymlink
- a helper script to make a symlink since I always forget how tolastdown
/mvlast
- prints/moves the latest file in your downloads ($XDG_DOWNLOAD_DIR
or~/Downloads
) folderget-extension
,remove-extension
,replace-extension
- helpers to create output filename strings- Lots of date shorthands:
daystamp
,daystamp_
,epoch
,month
,weekday
,year
path
: prints your$PATH
, separated by newlines
json-compress
- compresses JSON (removes extra spaces/newlines), only writes to the file if size of data was changedtq
- converts a TOML file to JSON, usually piped to jq. e.g.,:tq <data.toml | jq '.conf'
to-png
/to-jpg
- converts an image to a png/jpgimg-download
- downloads an image from your clipboard to your tmpdir, moves it so that the extension is validshebang
- creates a script with the given shebang. If a known language, adds a basic templatehtml-head
: a script to generate<head>
tags for generated HTML, I often use this like:pandoc README.md | html-head -a css-dark-mode -a css-pre-wrap | remsync-html-from-stdin
to convert some local markdown file to a basic dark-mode webpage and publish it onto my website withremsync
lower
/upper
- converts all text from STDIN to lowercase/uppercaseprefix
/suffix
/surround
- prepends/adds a string to the beginning/end of each line from STDINcapitalize
- 'capitalizes' (first letter of) input, e.g. WORD -> Word; word -> Wordaverage
- finds the mean of numerical data piped from STDINrcut
-cut
, by indexing from the right insteadsort-by-last-col
- sorts text by last column of text; columns can vary in lengthunique
-uniq
, but doesn't require input to be sortedunique-ignore-case
-unique
, but ignores uppercase/lowercasetally
- shorthand forsort | uniq -c | sort -n
group-and-termgraph
- takes lines of data and groups/graphs it using termgraph. Sort of like a fancysort | uniq -c | sort -n
epochdisplay
- given one or more epoch timestamps (date +"%s"
) prints a readable date. If no args are given, reads from STDINepochguess
- reads anything from STDIN. convert any epoch timestamps that looks like a datetime to local-readable timestamps
These use on_machine
to run different commands based on what operating system you're on
openurl
/openurls
- URL openerclipcopy
/clippaste
- save to/read from clipboardinput-dialog
- prompts the user to enter some text with an OS-dialognotify
- sends a OS notification (notify-send
on linux/applescript
on mac)picker
- prompts user to pick from lines received from STDIN
gitopen
- opens the current git repository/branch in your browser- Helpers that return
0
if the condition is met, they're used like:in-gitdir && command_do_something
in-gitdir
- currently in a git directoryhas-git-remote
- has agit remote --verbose
git-has-changes
- files have changes or there are untracked filesgit-list-untracked-files
- prints files that are not tracked by gitgit-has-untracked-files
- exits with 0 if there are any untracked files
image-dimensions
- prints the width/height for images passed as argumentsgifme
- Creates a gif from a (section of a) video file. Lets you specify start/end times and an fps for the gif to run atlist-movies
/list-music
- lists any music/movies in the current directory recursively. any additional args are passed ontofd
, e.g, withmlength
list-music -X mlength -o sum
(find length of an album in current directory)list-movies -X mlength -d path -o min
(find shortest movie in current directory)list-movies -X mlength -d all | sort -n
(sort results by length)
ix
- terminal pastebin replacement -- anything piped to STDIN gets uploaded to http://ix.io and a link is copied to your clipboard