Skip to content

Functions

General Functions

sudo_if_needed()

source

sudo_if_needed checks if the file requires superuser permissions and returns sudo if needed

Usage: sudo_if_needed <file>

die()

source

die echoes the first argument as an error message and exits the shell

Usage: die "Error: Something went wrong."

mkd()

source

Create a new directory and enter it

Usage: mkd <dirname>

targz()

source

Create a .tar.gz archive, using zopfli, pigz or gzip for compression

Usage: Usage: targz [--name custom_name] <path to file or directory>...

server()

source

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()

source

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()

source

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()

source

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()

source

echoerr echoes the first argument to stderr. Useful for printing errors.

Usage: echoerr "Error: Something went wrong."

dlc()

source

dlc deletes all lines that start with the specified comment symbol

Usage: dlc "<file>" "<comment_symbol>"

uuidf()

source

Converts all file names in the current directory to some UUID names leaving the extension intact

Usage: uuidf

snapc()

source

snapc cleans up old snap versions

Usage: sudo snapc

cp2()

source

Requirements

This function requires rsync - sudo apt install rsync.

cp2 copies file or directory to a location using rsync

Usage: cp2 <source> <destination>

debi()

source

debi installs a .deb file using apt install

Usage: debi <file.deb>

File and Directory Compression Functions

7zc()

source

Requirements

This function requires 7zzs, see https://www.7-zip.org/download.html

7zc creates a 7Zip archive using the LZMA algorithm

Usage: 7zc <directory> or 7zc <filename1> <filename2> <...> <filenameN> <archive_name>

7zx()

source

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

Usage: 7zx <filename>.7z

zstdc()

source

Requirements

This function requires zstd. Install it from sudo apt install zstd.

zstdc compresses a file or directory using zstd with tar

Usage: zstdc <file or directory>

zstdx()

source

Requirements

This function requires zstd. Install it from sudo apt install zstd.

zstdx extracts a zstd compressed tar file

Usage: zstdx <file.tar.zst>

gclone()

source

gclone clones a git repository and cd's into it

Usage: gclone <git_url>

gsubd()

source

gsubd removed the current Git submodule and its entry in .gitmodules

Usage: gsubd <submodule_path>

dot()

source

dot prints help for the dotfiles and can be used to run the dotfiles functions

Usage: dot or dot <command>

dotc()

source

dotc checks if all the requirments are met for the dotfiles to work

Usage: dotc

dotu()

source

dotu updates the dotfiles to the latest main branch

Usage: dotu

dotls()

source

dotls lists all the aliases and functions in the dotfiles and the shell

Usage: dotls