{ pkgs, lib, ... }: with lib; { programs.bash = { enable = mkDefault true; enableCompletion = mkDefault true; shellAliases = { afk = "xset s activate dpms force off"; black-on-white = "echo -e '\\033]11;black\\007\\033]10;white\\007'"; c = "bat"; cl = "clear"; dust = "dust --bars-on-right --full-paths"; emacs = "emacsclient --create-frame"; grep = "grep --color"; j = "sudo journalctl -u"; jb = "sudo journalctl -b"; ju = "sudo journalctl --user -u"; l = "ls -alh"; ll = "ls -al"; ls = "ls --color=tty"; md-toc = "grep '^#\\+' --color"; mem = "ps -e -orss=,user=,args= | sort -b -k1,1n"; mem-top = "smem --sort rss --autosize"; mpl = "mplayer"; n = "sudo networkctl"; nf = "sudo nft list ruleset | less"; nix-du-svg = "nix-du | dot -Tsvg >nix-du.svg"; nixos-clean = "sudo nix-collect-garbage -d"; nixos-history = "sudo nix-env --list-generations --profile /nix/var/nix/profiles/system"; nixos-rollback = "sudo nixos-rebuild switch --rollback"; nt = "sudo networkctl status"; pass-gen = "tr -d -C A-Za-z0-9_- /dev/null | while IFS=: read -r file x size x do pid=''${file#/proc/} pid=''${pid%/smaps} size=''${size% kB} size=''${size##* } if test "$pid" = "$lastpid" then swap=$(( swap + size )) else if test "$swap" -gt 0 then printf "%u pid=%u cmd=%s\n" "$swap" "$lastpid" "$(tr '\000' ' ' /dev/null || sudo zfs mount -l "$d" done ) } # Recursively unmount dataset, # unloading their keys. zfs-unmount () { sudo zfs unmount -u "$@"; } # Create bookmarks for all the snapshots of the given datasets. # Bookmarks are only useful on source datasets # But syncoid --create-bookmark only creates # a bookmark for the latest snapshot, # possibly leaving the *_daily or *_monthly snapshots without a bookmark. zfs-fix-bookmarks () { local d local - set -x for d in "$@"; do for s in $(zfs list -Hrpt snapshot -o name "$d"); do zfs bookmark "$s" "''${s//@/#}" done done } # Restore the inheritance of encryptionroot, # usually broken by zfs send --raw. # Note that it needs to decrypt the datasets. zfs-fix-encryptionroot () { local d zfs load-key "$1" for d in $(zfs list -rHo name "$1" | tail -n +2); do echo >&2 "$d" test "$(zfs get -Ho value encryptionroot $d)" = "$1" || zfs change-key -li "$d" done } # Recursively remove all the snapshots of given datasets zfs-destroy-snapshots () { local d for d in "$@"; do zfs list -t snapshot -rHo name "$d" | xargs --no-run-if-empty -L1 zfs destroy done } ''; profileExtra = '' ''; }; #programs.broot.enableBashIntegration = true; programs.readline = { enable = mkDefault true; includeSystemConfig = true; bindings = { # Up/Down "\\e[A" = "history-search-backward"; "\\e[B" = "history-search-forward"; "\\eOA" = "history-search-backward"; "\\eOB" = "history-search-forward"; # Ctrl-Left/Ctrl-Right "\\e[1;5C" = "forward-word"; "\\e[1;5D" = "backward-word"; "\\e[5C" = "forward-word"; "\\e[5D" = "backward-word"; "\\e\\e[C" = "forward-word"; "\\e\\e[D" = "backward-word"; # Home/End "\\e[1~" = "beginning-of-line"; "\\e[4~" = "end-of-line"; # Delete/Insert "\\e[3~" = "delete-char"; "\\e[2~" = "quoted-insert"; # For non RH/Debian xterm, can't hurt for RH/Debian xterm "\\eOF" = "end-of-line"; "\\eOH" = "beginning-of-line"; # For freebsd console "\\e[F" = "end-of-line"; "\\e[H" = "beginning-of-line"; # $if term=rxvt "\\e[7~" = "beginning-of-line"; "\\e[8~" = "end-of-line"; "\\eOc" = "forward-word"; "\\eOd" = "backward-word"; # $endif }; variables = { # Be 8 bit clean. input-meta = mkDefault true; output-meta = mkDefault true; colored-completion-prefix = mkDefault true; colored-stats = mkDefault true; # Note that this may cause completion text blink in some terminals (e.g. xterm). echo-control-characters = mkDefault true; mark-symlinked-directories = mkDefault true; menu-complete-display-prefix = mkDefault true; show-all-if-ambiguous = mkDefault true; show-all-if-unmodified = mkDefault true; visible-stats = mkDefault false; # Append char to indicate type enable-bracketed-paste = mkDefault true; }; }; }