Functions
General Functions
sudo_if_needed
sudo_if_needed checks if the file requires superuser permissions and returns sudo if needed
Usage: sudo_if_needed <file>
die
die echoes the first argument as an error message and exits the shell
Usage: die "Error: Something went wrong."
mkd
Create a new directory and enter it
Usage: mkd <dirname>
targz
Create a .tar.gz archive, using zopfli, pigz or gzip for compression
Usage: Usage: targz [--name custom_name] <path to file or directory>...
server
Requirements
This function requires Python 3.10 or higher.
Optional Requirements
You can also use Caddy serve, install it from https://caddyserver.com/docs/install
If a caddy server is installed then that is preferred over Python.
Start an HTTP server from a directory, optionally specifying the port
Usage: server [path] [port]
o
Normalize open across Linux, macOS, and Windows. This is needed to make the o function (see below) cross-platform. o with no arguments opens the current directory, otherwise opens the given location
Usage: o, o ., o ~/, o ./myproject, etc.
tre
Requirements
This function requires tree - sudo apt install tree.
tre is a shorthand for tree with hidden files and color enabled, ignoring the .git directory, listing directories first. The output gets piped into less with options to preserve color and line numbers, unless the output is small enough for one screen.
Usage: tre <directory>
ginit
Requirements
This function requires git - sudo apt install git.
ginit initailises a git repository and makes an initial commit
Usage: ginit or ginit "Initial commit"
echoerr
echoerr echoes the first argument to stderr. Useful for printing errors.
Usage: echoerr "Error: Something went wrong."
dlc
dlc deletes all lines that start with the specified comment symbol
Usage: dlc "<file>" "<comment_symbol>"
uuidf
Converts all file names in the current directory to some UUID names leaving the extension intact
Usage: uuidf
snapc
snapc cleans up old snap versions
Usage: sudo snapc
debi
debi installs a .deb file using apt install
Usage: debi <file.deb>
lsu
lsu lists all USB devices connected to the system
Usage: lsu
wrap_text
wrap_text wraps text to a specified width and indentation
Usage: wrap_text "<text>" [width] [indent]
File and Directory Compression Functions
sd
Requirements
This function requires shred - sudo apt install coreutils.
sd securely deletes one or more files or directories by overwriting them before deletion
Usage: sd <file or directory> [file2] [file3] ... [-f] [-n <passes>]
Options:
-f, --force Force deletion without confirmation prompt-n, --passes <num> Number of overwrite passes (default: 5)
7zc
Requirements
This function requires 7zzs, see https://www.7-zip.org/download.html
7zc creates a 7Zip archive using the LZMA2 algorithm
Usage: 7zc <directory> [-p] [-s <size>] or 7zc <file1> <file2> ... <archive_name> [-p] [-s <size>]
Options:
-p Prompt for password to encrypt the archive-s <size> Split archive into parts of specified size. Supports b (bytes)/k (kilobytes)/m (megabytes)/g (gigabytes) units (e.g., -s 500m, -s 1g, -s 2048k). Defaults to MB if no unit specified.
7zx
Requirements
This function requires 7zzs, see https://www.7-zip.org/download.html
7zx extracts a 7Zip archive to a directory with the same name as the archive. Supported formats: zip, rar, 7z, tar, tar.gz, tgz, tar.bz2, tbz2, tar.xz, txz, gz, bz2, xz For multi-part archives (e.g., archive.7z.001, archive.7z.002), extract the first part and 7-Zip will automatically use all parts.
Usage: 7zx <filename>.7z or 7zx <filename>.7z.001 (for multi-part archives)
zc
Requirements
This function requires zstd. Install it from sudo apt install zstd or download it from GitHub Release.
zc compresses a file or directory using zstd with tar
Usage: zc <file or directory>
zx
Requirements
This function requires zstd. Install it from sudo apt install zstd or download it from GitHub Release.
zx extracts a zstd compressed tar file
Usage: zx <file.tar.zst>
Git Related Functions
gclone
gclone clones a git repository and cd's into it
Usage: gclone <git_url>
gsubd
gsubd removed the current Git submodule and its entry in .gitmodules
Usage: gsubd <submodule_path>
gclean
gclean removes all untracked files, including ignored files and directories
Usage: gclean
gcl
gcl Generates a changelog from the commit history
Usage: gcl
Dotfiles Related Functions
dot
dot prints help for the dotfiles and can be used to run the dotfiles functions
Usage: dot or dot <command>
dotu
dotu updates the dotfiles to the latest main branch
Usage: dotu
dotls
dotls lists all the aliases and functions in the dotfiles with their descriptions
Usage: dotls