This repository has been archived on 2026-04-20. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
AsaJS/modules/features/home/bash.nix
2026-04-10 21:15:43 +07:00

68 lines
No EOL
1.9 KiB
Nix

{ lib, osconfig, ... }: {
programs.bash = {
enable = true;
shellAliases = lib.attrsets.mergeAttrsList [
{
cls = "clear";
cleanup = "sudo nix-collect-garbage -d";
cls-log = "sudo journalctl --vacuum-time=1s";
logout = "pkill -KILL -u $USER";
nrs = "sudo nixos-rebuild switch --flake /etc/nixos#${osconfig.device.flake-name}";
flake-upgrade = "nix flake update";
}
{
spf = "superfile";
}
(lib.optionalAttrs osconfig.virtualisation.waydroid.enable {
wss = "waydroid session stop; exit;";
})
];
shellOptions = [
"histappend"
"checkwinsize"
"extglob"
"globstar"
"checkjobs"
"autocd"
];
initExtra = ''
function git-commit() {
git add .
git commit -m "$1"
}
function git-push() {
git-commit "$1"
git push origin HEAD
}
function git-pull() {
git fetch origin HEAD
git pull origin HEAD
}
function get-hash() {
nix hash to-sri --type sha256 $(nix-prefetch-url --unpack "$1")
}
'' +
lib.optionalString osconfig.device.programs.tmux.enable ''
allowed_terms=("xterm-kitty" "xterm-ghostty")
should_run_tmux=false
for term in "${"$" + "{allowed_terms[@]" + "}"}"; do
if [[ "$TERM" == "$term" ]]; then
should_run_tmux=true
break
fi
done
if [ -z "$TMUX" ] && [ "$should_run_tmux" = true ]; then
exec tmux
fi
'';
};
}