nixdots/home/programs/terminal/shell/zsh/aliases.nix

61 lines
2.1 KiB
Nix
Raw Normal View History

2024-03-24 11:58:34 +00:00
{ config, pkgs, lib, ... }:
2024-03-23 23:44:57 +00:00
let
2024-03-24 11:58:34 +00:00
inherit (lib.meta) getExe getExe';
2024-03-23 23:44:57 +00:00
in
{
2024-03-24 12:18:51 +00:00
programs.zsh.shellAliases = {
# I'm not the greatest typist
sl = "ls";
mdkir = "mkdir";
soruce = "source";
suod = "sudo";
sduo = "sudo";
2024-03-23 23:44:57 +00:00
2024-03-24 12:18:51 +00:00
# Directory changing
".." = "cd ..";
"..." = "cd ../../";
"...." = "cd ../../../";
"....." = "cd ../../../../";
".2" = "cd ../../";
".3" = "cd ../../../";
".4" = "cd ../../../../";
".5" = "cd ../../../../../";
2024-03-23 23:44:57 +00:00
2024-03-24 12:18:51 +00:00
# Files/Directories utilities
fcd = "cd $(find -type d | fzf)";
mkdir = "mkdir -p";
md = "mkdir";
fhere = "find . -name";
rr = "rm -r";
rf = "rm -f";
rrf = "rm -rf";
vimdiff = "nvim -d";
2024-03-23 23:44:57 +00:00
2024-03-24 12:18:51 +00:00
# Directory listing aliases
ls = "ls --color=auto";
l = "ls -lahX --classify";
ll = "ls -lahX --classify --group-directories-first";
ldir = "ls -lahX --classify | grep --color=never ^d";
dotall = "ls -lahXd .[a-z]*";
dotfiles = "dotall | grep -v ^d";
dotdirs = "dotall | grep --color=never ^d";
2024-03-24 11:58:34 +00:00
2024-03-24 12:18:51 +00:00
# File validation and manipulation
yamlcheck = "${getExe pkgs.python3} -c 'import sys, yaml as y; y.safe_load(open(sys.argv[1]))'"; # Validate YAML
jsoncheck = "${getExe pkgs.jq} "." >/dev/null <"; # Validate JSON
urlencode = "${getExe pkgs.python3} -c 'import sys, urllib.parse as ul; print(ul.quote_plus(sys.argv[1]));'"; # Encode strings as URLs (space->%20, etc.)
mergepdf = "${getExe pkgs.gnostscript} -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=_merged.pdf"; # Usage: `mergepdf input{1,2,3}.pdf``
encrypt = "${getExe pkgs.gnupg} -c --no-symkey-cache --cipher-algo AES256"; # Encrypt file with AES256 symetric encryption
2024-03-24 11:58:34 +00:00
2024-03-24 12:18:51 +00:00
# Get global IP address by querying opendns directly
# (much better than using some random "what is my ip" service)
# <https://unix.stackexchange.com/a/81699>
2024-03-25 21:46:28 +00:00
ip = "${getExe pkgs.dig} @resolver4.opendns.com myip.opendns.com +short";
ip4 = "${getExe pkgs.dig} @resolver4.opendns.com myip.opendns.com +short -4";
ip6 = "${getExe pkgs.dig} @resolver1.ipv6-sandbox.opendns.com AAAA myip.opendns.com +short -6";
2024-03-24 11:58:34 +00:00
2024-03-24 12:18:51 +00:00
# Expand aliases from sudo
sudo = "sudo ";
2024-03-23 23:44:57 +00:00
};
}