nix/home-manager/common/software/cli/bash.nix
2023-09-18 18:37:05 +09:00

117 lines
3.2 KiB
Nix

{ config, pkgs, ... }: {
# Configure BASH exports
# https://nix-community.github.io/home-manager/options.html
# https://github.com/justjanne/powerline-go
# https://nix-community.github.io/home-manager/options.html#opt-programs.powerline-go.enable
programs.powerline-go = {
enable = true;
# https://github.com/justjanne/powerline-go#customization
settings = {
hostname-only-if-ssh = true;
cwd-max-depth = 1;
condensed = true;
theme = "gruvbox";
};
modules = [
"venv"
"user"
"host"
"ssh"
"cwd"
"nix-shell"
"perms"
"git"
"docker"
"exit"
"root"
];
};
programs = {
bash = {
enable = true;
enableCompletion = true;
initExtra = ''
GPG_TTY=$(tty)
'';
sessionVariables = {
# Set the GTK Theme
# GTK_THEME = "Gruvbox-Dark-BL";
XDG_DATA_HOME = "$HOME/.local/share";
# Disable askpass for cli auth:
SSH_ASKPASS = "";
};
bashrcExtra = ''
sops-edit() {
nix-shell
nix-shell -p sops --run "sops $1"
}
sops-update() {
nix-shell
nix-shell -p sops --run "sops updatekeys $1"
}
nix-clean-all() {
sudo nix-env -u --always
sudo nix-collect-garbage -d
}
'';
shellAliases = {
# nVidia prime selector alias:
prime-select = "nvidia-offload";
# Don't use X to open emacs
emacs = "emacs -nw";
# docker
d = "docker";
dc = "docker-compose";
de = "docker exec -it";
# bash / system
ls = "exa";
cp = "rsync -avr";
ll = "exa -lah";
rm = "rm -i";
df = "duf";
# git
g = "git";
ga = "git add -A";
gb = "git branch";
gc = "git commit";
gca = "git commit -a";
gco = "git checkout";
gd = "git diff";
gp = "git pull --prune";
gpu = "git push origin HEAD";
gs = "git status -sb";
# time / date
tdate = "date +%Y.%m.%d..%H.%M";
ttime = "date +%H.%M";
ddate = "date +%Y.%m.%d";
dday = "date +%A";
# nixos-rebuild
ns = "nix-shell -p";
nr = "sudo nixos-rebuild";
nrs = "sudo nixos-rebuild --upgrade switch";
nrt = "sudo nixos-rebuild test";
nrb = "sudo nixos-rebuild build";
# Rebuild everything
rebuild-home = "git -C /etc/nixos/git pull && home-manager switch -b backup --flake /etc/nixos/git";
rebuild-host = "git -C /etc/nixos/git pull && sudo nixos-rebuild switch --flake /etc/nixos/git";
rebuild-all = "rebuild-home && rebuild-host";
# Build ISOs/SD Card Images
nixos-build-pi-img = "nix build /etc/nixos/git#nixosConfigurations.nixos-rpi4-img.config.system.build.sdImage";
# nixos-build-console = "nix build /etc/nixos/git#nixosConfigurations.nixos-iso-console.config.system.build.isoImage";
# nixos-build-desktop = "nix build /etc/nixos/git#nixosConfigurations.nixos-iso-desktop.config.system.build.isoImage";
};
};
};
}