Scripts and Aliases for Your Linux

alexeev-prog1 pts0 comments

Scripts and aliases for your linux | alexeev-dev notes

Scripts and aliases for your linux

18 May, 2026

Every person who spends more than five minutes in a terminal runs into the same thing: the same long commands have to be typed over and over, and routine actions eat up time and attention. At first you put up with it, then you start optimizing.

A simple alias in .bashrc or .zshrc feels like a small revelation. The first working script saved in ~/.local/bin feels like a breakthrough. It’s not just about laziness — it’s about efficiency, about workflow optimization.

Over time, such "micro-optimizations" accumulate into an entire personal framework or a set of command-line utilities. It is no longer a couple of patches, but your own environment, honed for specific tasks. In this article, I want to showcase my collection of such scripts and aliases — not as an ideal standard, but as an example of a living approach. Perhaps some solutions will prove useful to you as well, and most importantly — they will inspire you to create something of your own, even more convenient.

Quite often in the Linux community, you can see a discussion on when aliases are useful and when executable scripts in a conventional ~/.local/bin/ directory are preferable. Aliases are compact and fast, and thanks to that, they can replace small command chains. However, they have drawbacks: for example, if you define them in the shell config, you have to reload the session. Therefore, sometimes it's more convenient to use scripts, since they can be written not only in bash but also in other programming languages available in the system. And, naturally, scripts offer a much wider scope for activity.

In this article, I’ll show both aliases and scripts that I use on a daily basis.

All scripts are available in my repository. You can share your own scripts in the comments or via a pull request.

❯ NixOS<br>Let's start with a set of aliases for NixOS:

alias rb="sudo nixos-rebuild switch --flake /home/alexeev/nixos/"<br>alias upd="nix flake update /home/alexeev/nixos/"<br>alias upg="sudo nixos-rebuild switch --upgrade --flake /home/alexeev/nixos/"<br>alias nixclean="sudo nix-collect-garbage -d"<br>alias hms="home-manager switch --flake /home/alexeev/nixos/"

alias conf="nvim ~/nixos/nixos/configuration.nix"<br>alias pkgs="nvim ~/nixos/nixos/packages.nix"

This allows for rebuilding, updating, cleaning the system, as well as quickly working with the configuration and packages in the system.

❯ Git<br>Aliases for git can be made both via the standard external approach:

alias gga="git add"<br>alias ggc="git commit"<br>alias ggcm="git commit -m"<br>alias ggs="git status"<br>alias ggl="git log"<br>alias gglo="git log --oneline"<br>alias ggd="git diff"<br>alias ggds="git diff --staged"<br>alias ggr="git restore"

As well as through configuring the ~/.gitconfig file:

[alias]<br>st = status -b<br>c = commit<br>co = checkout<br>br = branch<br>slog = log --pretty=format:"%C(auto)%h%C(auto)%d\\ %C(auto,reset)%s\\ \\ [%C(auto,blue)%an%C(auto,reset),\\ %C(auto,cyan)%ar%C(auto,reset)]"<br>glog = log --graph --pretty=format:"%C(auto,yellow)%h%C(auto)%d\\ %C(auto,reset)%s\\ \\ [%C(auto,blue)%an%C(auto,reset),\\ %C(auto,cyan)%ar%C(auto,reset)]"<br>wlog = log --pretty=format:"%C(auto,yellow)%h%C(auto)%d%C(auto,reset)\\ by\\ %C(auto,blue)%an%C(auto,reset),\\ %C(auto,cyan)%ar%C(auto,reset)%n\\ %s%n" --stat<br>gr = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all<br>wt = worktree

I use these aliases quite often for quick work with repositories, retrieving logs and graphs of branches and commits.

I also sometimes use this interesting script:

#!/usr/bin/env python3<br>import os<br>import re

class GitVersion:<br>def __init__(self):<br>self._default_version = "0.1.0"<br>os.chdir(os.path.dirname(os.path.realpath(__file__)))

@property<br>def tag(self):<br>stream = os.popen("git describe --match v[0-9]* --abbrev=0 --tags")<br>return stream.read().strip()

@property<br>def version(self):<br>version = f"{self.tag[1:]}.{self.build}"

if version == ".":<br>return self._default_version

return version

@property<br>def default_branch(self):<br>stream = os.popen("git config --get init.defaultBranch")<br>result = stream.read().strip()

if not result:<br>result = "main"

return result

@property<br>def build(self):<br>stream = os.popen(f"git rev-list {self.tag}.. --count")<br>return stream.read().strip()

@property<br>def branch(self):<br>stream = os.popen("git branch --show-current")<br>return stream.read().strip()

@property<br>def full(self):<br>return f"{self.version}-{self.branch}"

@property<br>def standard(self):<br>standard = f"{self.version}-{self.branch}"<br>if self.branch == self.default_branch or re.match("release/.*", self.branch):<br>standard = f"{self.version}"<br>return standard

@property<br>def commit(self):<br>stream = os.popen("git rev-parse HEAD")<br>return stream.read().strip()

@property<br>def commit_hash(self):<br>stream = os.popen("git rev-parse --short HEAD")<br>return...

self auto alias reset nixos stream

Related Articles