From 6e826f2603b89c0e33aa8b340e35663062211f0d Mon Sep 17 00:00:00 2001 From: Luxferre Date: Wed, 4 Mar 2026 11:25:39 +0200 Subject: [PATCH] init upload --- README.md | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ core | 21 +++++++++++++++++++++ custom | 1 + dev | 6 ++++++ main | 44 ++++++++++++++++++++++++++++++++++++++++++++ media | 9 +++++++++ net | 13 +++++++++++++ sys | 18 ++++++++++++++++++ 8 files changed, 163 insertions(+) create mode 100644 README.md create mode 100644 core create mode 100644 custom create mode 100644 dev create mode 100644 main create mode 100644 media create mode 100644 net create mode 100644 sys diff --git a/README.md b/README.md new file mode 100644 index 0000000..a85a81b --- /dev/null +++ b/README.md @@ -0,0 +1,51 @@ +# Servalias: a shell alias system friendly for your paws + +## What is it? + +Servalias is a curated, forever free, modular shell alias collection for Unix-like operating systems, designed to make routine tasks much easier. + +All the aliases provided in this repo are designed to be POSIX-compatible. + +## Installation + +First, clone the repo and remove the cruft: + +``` +git clone https://codeberg.org/luxferre/servalias.git ~/.aliases && rm -rf ~/.aliases/.git ~/.aliases/README.md +``` + +Then, append the following line to your shell's RC file (for Bash, it's usually `.bashrc`): + +``` +[ -f ~/.aliases/main ] && . ~/.aliases/main +``` + +## Modules + +By default, Servalias is shipped with the following modules: + +* `main`: the entry point that contains the alias management framework, **do not touch unless absolutely necessary**; +* `core`: the core commands that can be reused within any other module; +* `sys`: OS-specific stuff that's supposed to be modified according to your distribution (the included alias set is for Void Linux); +* `net`: aliases related to any networking activity; +* `dev`: aliases related to any development or DevOps activity; +* `media`: multimedia-related aliases; +* `custom`: aliases created automatically via other commands, like `savealias` (see below). + +Every module can be edited with the `aliases-[modulename]` command (e.g. `aliases-net`). These commands use the `$EDITOR` environment variable to open corresponding files, defaulting to `vim` if such a variable isn't set. + +## Custom aliases + +Once Servalias is plugged into your shell, you can do all sorts of tricks with custom alias definitions. + +Scenario 1: you need to define an alias that uses positional parameters within your command. The standard `alias` would require some sort of function wrapping to achieve this. For this purpose, the `defalias` macro exists here. You just write `defalias myname '...all sorts of crazy stuff...'` and you'll see the alias being saved properly with all the wrappers applied. + +Scenario 2: you have come up with a really long command line that you have tested and want to turn into an alias right away. To do this without additional copy-pasting, use the `toalias [name]` macro. It will take the most recent line in your command history and turn it into a ready-to-use alias. + +Scenario 3: you have created a new alias (with the usual `alias` command or with Servalias macros like `defalias` or `toalias`) and really liked it, but now you want to save it to reuse in future shell sessions. Again, to avoid any copy-pasting, the `savealias [name]` command allows you to save any live alias of your choice into the `custom` module which will be reloaded alongside the others on the next session. + +By the way, in case you prefer editing the files manually and not via `aliases-[modulename]` commands, you can apply your changes after saving the files with `reload-aliases` command. + +## Credits + +Created by Luxferre in 2026, released into public domain with no warranties. diff --git a/core b/core new file mode 100644 index 0000000..54ddcbd --- /dev/null +++ b/core @@ -0,0 +1,21 @@ +# core aliases + +# paginate any command output, but only in case it's necessary +alias pg='less -RXF' + +# ultimate ls +defalias l 'ls -lahF --time-style=long-iso --color=always $* | less -RXF' + +alias rootsh='sudo $SHELL' +alias doas=sudo + +# ed maxout (requires rlwrap) +alias ee='rlwrap ed -p:' +alias eer='doas rlwrap ed -p:' +defalias edr 'ssh "$1" rlwrap ed -p: "$2"' + +# one-line notetaking (in twtxt format) +alias n='echo -e "$(date -Im)\t$*" >> ~/n' + +# rot13 masking +defalias r13 'echo "$*" | tr "A-Za-z" "N-ZA-Mn-za-m"' diff --git a/custom b/custom new file mode 100644 index 0000000..cc8d4e7 --- /dev/null +++ b/custom @@ -0,0 +1 @@ +# saved aliases will go here diff --git a/dev b/dev new file mode 100644 index 0000000..858e616 --- /dev/null +++ b/dev @@ -0,0 +1,6 @@ +# Development and DevOps-related aliases + +# Git aliases +alias gcm='git commit -a -m' +alias gp='git push origin' +alias gpm='git push origin master' diff --git a/main b/main new file mode 100644 index 0000000..0cd2d9f --- /dev/null +++ b/main @@ -0,0 +1,44 @@ +# Servalias: shell-independent alias collection by Luxferre +# This is the core file to be included from the outside world +# (source as . $HOME/.aliases/main) + +. $HOME/.profile + +# set modules (order matters) +ALIAS_MODULES='core sys net dev media custom' + +# detect the current alias file path, hardcode it for non-bash +ALIASES_MAIN="$BASH_SOURCE" +[ -z "$ALIASES_MAIN" ] && ALIASES_MAIN="$HOME/.aliases/main" + +# set some editor +[ -z "$EDITOR" ] && EDITOR=vim + +# get the alias directory +ALIASDIR="$(dirname "$ALIASES_MAIN")" + +# these are the bedrock commands for alias manipulation + +# live-reload all aliases from this collection +alias reload-aliases=". $ALIASES_MAIN" + +# edit this file and then live-reload all aliases +alias aliases-main="$EDITOR $ALIASES_MAIN && reload-aliases" + +# get the most recent command run on this shell +alias lastcmd='history | tail -q -n 2 | head -q -n 1 | sed "s/^[[:space:]]*[0-9]*[[:space:]]*//"' + +# define complex, function-like command aliases that can handle positional parameters anywhere +alias defalias='___(){ __="$1";shift;alias $__="_$__(){ $*; };_$__"; };___' + +# convert the last run command into an alias +defalias toalias 'defalias "$1" "$(lastcmd)";alias "$1"' + +# save any live alias into the custom alias file +defalias savealias "[ -n \"\$1\" ] && echo \"alias \$(alias \$1 | sed 's/^alias //')\" >> ${ALIASDIR}/custom" + +# load the alias modules +for mod in $ALIAS_MODULES; do + alias aliases-${mod}="$EDITOR ${ALIASDIR}/$mod && reload-aliases" + . ${ALIASDIR}/$mod +done diff --git a/media b/media new file mode 100644 index 0000000..77b2758 --- /dev/null +++ b/media @@ -0,0 +1,9 @@ +# Multimedia-related aliases + +# pngcrush +alias pngc='pngcrush -ow' + +# music grabber +alias musgrab='yt-dlp -t mp3' +alias radio='mpv --vid=no --sid=no --ytdl-format=bestaudio/best' +alias stream='mpv --ytdl-format="bestvideo[height<=?768][vcodec!=vp9]+bestaudio/best"' diff --git a/net b/net new file mode 100644 index 0000000..f410b0e --- /dev/null +++ b/net @@ -0,0 +1,13 @@ +# network activity related aliases + +# itty-bitty-siting +defalias ibs 'cat $* | lzma -9 | base64 -w0 | xargs -0 printf "https://itty.bitty.site/#/%s\n"' + +# some Tor-related aliases + +# reset tor circuit for torified programs (requires control port 9051) +alias tornew='echo -e "AUTHENTICATE \"\"\r\nsignal NEWNYM\r\nQUIT" | nc 127.0.0.1 9051' +# most efficient downloads via Tor (torify + aria2) +alias toraria='torsocks aria2c --async-dns=false -x 16 -j 16' + +alias websrv='python3 -m http.server' diff --git a/sys b/sys new file mode 100644 index 0000000..830e5ca --- /dev/null +++ b/sys @@ -0,0 +1,18 @@ +# OS-specific aliases (may change according to your distro) + +# Flatpak-specific +alias flatinst='sudo flatpak install flathub' +alias flatunseal='sudo flatpak override --filesystem=host' +alias flatrun='flatpak run' +alias flatupd='sudo flatpak update -y' + +# Void-specific +alias pkgadd='sudo xbps-install -Sy' +alias pkgdel='sudo xbps-remove -oy' +alias pkgsearch='xbps-query -Rs' +alias xbpsup='sudo xbps-install -u xbps' +alias sysup='sudo xbps-install -Suy && sudo vkpurge rm all' +alias sysclean='sudo vkpurge rm all && sudo xbps-remove -OOoy' + +# restore my layout +alias mykb='setxkbmap -option "grp:caps_toggle,grp_led:scroll,terminate:ctrl_alt_bksp" -layout "us,ua,ru" -variant "altgr-weur,phonetic,phonetic"'