config/users/pbsds/home/profiles/shell.nix

145 lines
4.0 KiB
Nix

{ pkgs, lib, config, ... }:
{
# TODO: "bind -s 'set completion-ignore-case on'"
programs.bash.enable = true;
#programs.bash.enableCompletion = true;
programs.bash.shellOptions = [
# Append to history file rather than replacing it.
"histappend"
# check the window size after each command and, if
# necessary, update the values of LINES and COLUMNS.
"checkwinsize"
# Extended globbing.
"extglob"
"globstar"
# Warn if closing shell with running jobs.
"checkjobs"
];
programs.bash.initExtra = ''
bind 'set completion-ignore-case on'
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
export PS1='\[\033[01;32m\]\u@\h\[\033[01;37m\] \[\033[01;34m\]\W\[\033[33m\]$(parse_git_branch)\[\033[01;32m\]\$\[\033[00m\] '
# tldr
if command -v tldr >/dev/null; then
complete -F _command tldr
fi
destore() {
for dst in "$@"; do
test -L "$dst" || continue
# TODO: assert dst is in the store
src="$(realpath "$dst")"
if test -d "$src"; then
(set -x
rm -v "$dst"
cp -r --dereference --one-file-system "$src/" "$dst/"
chmod -R +rw "$dst"
)
elif test -f "$src"; then
(set -x
rm -v "$dst"
cp -v "$src" "$dst"
chmod -v +rw "$dst"
)
fi
done
}
'';
imports = [ ../modules/jump.nix ];
programs.jump.enableBash = true;
programs.nix-index.enable = true;
programs.nix-index-database.comma.enable = true; # via nix-index-database flake
#programs.command-not-found.enable = false; # mutex with nix-index
programs.fzf.enable = true; # TODO: does this conflict with system-wide setup?
programs.eza.enable = true;
programs.eza.enableAliases = lib.mkIf (lib.versionOlder config.home.version.release "24.05") true;
#programs.zoxide.enable = true;
#programs.zoxide.options = [ "--cmd cd --cmd dc" ];
programs.carapace.enable = true; # completions
# i can't type
home.shellAliases.sl = "eza";
#home.shellAliases.dc = "cd";
programs.direnv.enable = true;
programs.direnv.nix-direnv.enable = true;
programs.tealdeer.enable = true;
programs.tealdeer.settings.updates.auto_update = true;
# just use ncdu lol
home.shellAliases.dush = "du -shc * | sort -h";
home.shellAliases.dushd = "du -shc * .[!.]?* | sort -h";
home.shellAliases.open = "xdg-open";
home.shellAliases.diff = "diff -u --color"; # eyo
home.shellAliases.ip = "ip -br -color";
home.shellAliases.rssh = "ssh -l root";
home.shellAliases.sudo = "sudo ";
home.shellAliases.watch = "watch -c "; # parse colors
home.shellAliases.xargs = "xargs ";
home.shellAliases.vimv = "edir";
# Be conservative with files
# --preserver-root is for GNU versions, preventing changing perms on /
home.shellAliases.chown = "chown --preserve-root";
home.shellAliases.chmod = "chmod --preserve-root";
home.shellAliases.chgrp = "chgrp --preserve-root";
home.shellAliases.rm = "rm --preserve-root";
# prompt if deleting more than 3 files at a time
#home.shellAliases.rm = "rm -i";
#home.shellAliases.mv = "mv -i";
#home.shellAliases.cp = "cp -i";
home.shellAliases.kaomoji = "curl -s 'https://kaomoji.ru/en/' | htmlq tr td span --text | grep . | shuf | head -n1";
home.packages = lib.filter (x: x != null) (with pkgs; [
rsync
bind.dnsutils # dig
dogdns # dog
edir # better vimv
curl
wget
wakeonlan
#tldr
entr
axel aria aria2
xe # xargs alternative
sd # sed alternative
fd # find alternative
silver-searcher # 'ag'
ripgrep # 'rg'
comby
gron
jq
fx
yq # includes xmlq and tomlq
fq # binary jq
(pkgs.jnv or unstable.jnv or null)
htmlq
just # justfile
gum
sysz
du-dust # du alternative
duf # df alternative
ncdu # Disk usage analyzer with an ncurses interface
xplr # tui file explorer
aha (pkgs.colorized-logs or unstable.colorized-logs)
]);
}