This is my personal collection of scripts.
They range in complexity and usefulness; some of them are little more than aliases, while others contain a lot more logic and functionality. They should all support a -h
or --help
argument to display a summary and basic help information (it should be considered a bug if any don’t). Some of the scripts have configuration options at the top of the file that you may need or want to change, but I strive for “sensible defaults” and attempt to auto-detect “the right thing” when possible.
Even though I wrote them primarily for myself, all of these scripts should still be usable (and hopefully useful) to others. I have made an effort to write clean code (with comments where warranted), to handle possible error conditions, and to give helpful output when they occur.
The scripts are mostly written in Fish (because Fish is great), but a few of them are written in other languages (because other languages are also great, and fun to play with). As long as you have the script’s requirements, it should work just as well for you. Please don’t hesitate to open an issue if you find any problems with them.
The scripts in this collection that I find most useful are marked with ⚡.
The full list of scripts follows. Each is listed with its requirements and a short description.
Utilities that may be handy for shell-related tasks.
fish
Ask the user a yes or no question and return true (0
) if yes, false (1
) otherwise.
fish, xclip (when on linux)
A convenient interface to the clipboard.
fish
Alias for c -
; copy standard input to the clipboard.
fish
Open a man page in Emacs.
fish, emacs
Emacs Web Wowser; open a URL in Emacs’ web browser, eww.
fish, git
Merge and sort git log summaries for multiple repos.
fish, python
Quickly spin up a basic HTTP server for a directory.
fish, qrencode
Generate and display a QR code for the specified text, or generate a QR code to connect to a wifi network.
fish, qr, c
Generate and display a QR code for the text in the clipboard.
python, romkan
Romanize Japanese text from arguments or stdin. May be helpful for learning Japanese pronunciation.
fish
Set the terminal window title.
fish, hsetroot, feh
Set the desktop background, either to a solid color, or to a specified image.
fish, espeak, say (when on macos) or flite
Speak text using a text-to-speech engine.
fish, scrot, slop, c
Take a screenshot of the whole screen, a window, or a(n interactively-selected) region. unlike scrot it doesn’t cause junk to show up near the edges of the screenshot.
fish
Abbreviate the path passed as an argument. Similar to fish’s built-in prompt_pwd
function.
fish
Make a .bak
backup copy of the specified file(s).
fish, trash-put (trash-cli)
“Delete” (trash) a file, also removing it from any TMSU database.
fish
List files that only exist in one of the two specified dirs. This script supports comparing directories over SSH, i.e.: dirdiff /path/to/dir host:/path/to/dir
fish
Print the first file from each directory in CWD. With an argument, print a random file from each directory instead of the first one.
raku
Filter a list of filenames, outputting only those whose extension denotes a specified “type” (i.e. audio, image, video, etc).
fish, find
Get a list of symlinks whose target does not exist. This is basically just an easier-to-remember alias for find -xtype l
.
fish, bfs or find
Find audio files.
fish, bfs or find
Find compressed files.
fish, bfs or find
Find directories.
fish, bfs or find
Find image files.
fish, bfs or find
Find media files (audio, images, video).
fish, bfs or find
Find files of a specified type. This is used by finda
, findc
, findd
, etc; it’s simpler to just use those scripts instead of this one directly.
fish, bfs or find
Find unsorted files (anything not found by finda
, findc
, findd
, etc).
fish, bfs or find
Find video files.
fish, bfs or find
Find visual files (images, video).
fish
Recursively fix permissions on a file or directory.
fish, bfs or find
Locate files by searching their names case-insensitively with ~bfs~ or find
.
fish
Look up in the directory hierarchy for a specified file. This can be used, for example, to check if we’re in a git repository, by locating .git
.
fish, bfs or find
List audio files.
fish, bfs or find
List compressed files.
fish, bfs or find
List directories.
fish, bfs or find
List image files.
fish, bfs or find
List files of an unknown “type”; everything not audio, compressed, directories, images, or video. See also: lsa
, lsc
, lsd
, lsi
, lsv
, lsvis
.
fish, bfs or find
List video files.
fish, bfs or find
List visual files (images, video).
fish
Get a list of recently-modified files in this directory and subdirectories, most recent first.
fish
Output a random file in the current directory. An argument can be provided to specify the number of subdirectories to look for a random file.
fish, tmsu
Move a file, then run tmsu repair
for the new name and location.
fish, tmsu
Trash or delete a file, then run tmsu repair
to remove it from the database.
fish, trash-put (trash-cli)
Ask the user to confirm trashing the specified file(s), then trash them.
fish, tmsu
Print all TMSU tags next to a count of their uses.
fish, notify-send (libnotify)
Check the battery and notify if it’s low. May be useful to set as a cron job.
fish
Check disk free; print a message if free space of any partitions are below a threshold. May be useful run from your shell init file.
fish, notify-send (libnotify)
Check current memory and swap usage and notify if it’s low. May be useful to set as a cron job.
fish, copyevent, xsel
Automatically apply edits when the clipboard is modified.
By default, the only edits this makes are to remove YouTube’s &pp=
tracking parameters from URLs, but it should be pretty easy to add your own.
fish, pacman, rg
Run ripgrep on all of the files (not directories) installed by a package.
fish, pacman
Ask to remove all system packages installed as dependencies that are no longer needed.
fish, xset
“Screen suspend”. Simply turns off your monitor(s).
fish, pactl (libpulse)
Change system volume. This might be a bit more convenient and intuitive than typing crap like amixer -c 2 set PCM +2%
.
fish, grep
Grep for processes that match the arguments. Similar to pgrep
but its output is meant to be readable by humans.
fish, grep
Get a list of all programs using sound devices.
fish
Run a program if it’s not already running.
fish, xephyr
Run a program in Xephyr, starting it if necessary.
fish, ffmpeg
“Audio to video”; generate a video from a sound file and an image. Useful, for example, if you want to upload music to YouTube or other sites that support videos but not audio.
fish, a2v, parallel
Run a2v on multiple audio files in parallel using GNU parallel. ~nice~s the processes to run with a lower priority, to not disturb other processes on your system.
fish, convert (imagemagick)
Automatically correct image rotation based on its metadata.
fish, convert (imagemagick)
Automatically trim blank edges of an image. Copies the original image to /tmp
first in case it crops incorrectly.
fish, jack_capture, convert-audio, c
Capture the audio output going to the speakers and record it to a file.
fish, convert (imagemagick)
Content-aware scale a video. See ImageMagick’s documentation for more information about what this does, but basically, it can be used to make a video look silly. Examples: one, two, three.
fish, ffmpeg
Convert a set of audio files into a specified audio format, preserving tags. Uses GNU Parallel to parallelize the jobs to convert as fast as possible, ~nice~ing the processes to run with a lower priority, to not disturb other processes on your system.
fish, mpc (mpd)
List tracks in mpd’s current playlist.
fish, mpv
Play media with mpv, joining its twitch chat via IRC (weechat) if it’s a twitch stream. Once the stream is stopped, exits the channel.
fish
Get a list of N random songs from your music directory.
fish, nsxiv
View images or directories of images with ~nsxiv~. passes the rest of the images in the directory as well.
fish, text-gui, lyrics
Open a window showing the lyrics of MPD’s current track.
fish, zenity
Move a file using a file selector gui. Accepts a list of files either as arguments or from stdin if -
is the first argument.
fish, zenity
Rename a file via a GUI popup.
python, tkinter (tcl/tk), tmsu
Edit the ~TMSU~ tags for the specified file(s) with a tab-completing gui. Shows the filename (or the common directory if tagging multiple) and the previous set of tags, and allows you to edit their tags, with tab-completion of tag names.
python, tkinter (tcl/tk)
Show arbitrary text in a simple GUI. May be useful in scripts bound to window manager shortcuts or the like. The text is editable, and keybindings can be specified with --action
arguments.
Scripts to interact with services on the (inter)net.
fish, dictd, xclip, text-gui
Define the specified or selected word, showing the result in a popup dialog.
fish, clyrics, ffprobe (ffmpeg)
Get the lyrics for the specified or currently-playing song.
fish, curl
Get your current IP address as seen from the public internet.
fish, dictd
Get synonyms for a word.
fish, translate-shell, xclip, text-gui
Translate the selected text, showing the result in text-gui
.