Files
config/users/pbsds/home/profiles/shell.nix
2025-03-13 21:14:22 +01:00

209 lines
7.2 KiB
Nix

{ pkgs, lib, config, ... }:
let
_tmp_func_name = "_tmp_func_Oaw5aifeeniezeiquonaipheNahthae9caik4Rai"; # pwgen ftw
mkArgsAlias = alias: ''${_tmp_func_name}() { ${alias}; unset -f ${_tmp_func_name}; }; ${_tmp_func_name}'';
in
{
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 = ''
# tldr
if command -v tldr >/dev/null; then
complete -F _command tldr
fi
'';
# ~/.inputrc
programs.readline = {
enable = true;
bindings = {
"\\e[Z" = "menu-complete"; # shift+tab
};
variables = {
# https://man.archlinux.org/man/core/readline/readline.3.en#Variables
completion-ignore-case = true;
blink-matching-paren = true; # briefly move cursor to opening parenthesis when a closing parenthesis is inserted
colored-completion-prefix = true; # color common prefix of possible completions ($LS_COLORS)
colored-stats = true; # displays completions with different colors to indicate file type ($LS_COLORS)
enable-bracketed-paste = true;
#match-hidden-files = true;
#show-all-if-ambiguous = true;
mark-symlinked-directories = true; # completed names which are symbolic links to directories have a slash appended
};
};
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?
# alt-c
changeDirWidgetCommand = "fd --type d"; # respects .gitignore
changeDirWidgetOptions = [ "--preview 'tree -C {} | head -200'" ];
# ctrl-t
fileWidgetCommand = "fd --type f"; # respects .gitignore
fileWidgetOptions = [
#"--preview 'head {}'"
# https://github.com/junegunn/fzf/discussions/3363#discussioncomment-6419463
"--bind 'ctrl-a:reload:eval $FZF_DEFAULT_COMMAND --no-ignore'"
];
# ctrl-r
#historyWidgetOptions = [ "--sort" "--exact" ];
};
programs.eza.enable = true;
programs.eza.enableAliases = lib.mkIf (lib.versionOlder config.home.version.release "24.05") true;
programs.eza.enableBashIntegration = true;
programs.eza.enableZshIntegration = true;
#programs.eza.icons = "auto"; # --icons=auto
programs.eza.extraOptions = [ "--group" "--group-directories-first" ];
#programs.zoxide.enable = true;
#programs.zoxide.options = [ "--cmd cd --cmd dc" ];
programs.carapace.enable = true; # completions
# i can't type
home.shellAliases.sl = "ls";
#home.shellAliases.dc = "cd";
home.shellAliases.cdtmp = ''cd "$(mktemp -d)"'';
programs.direnv.enable = true;
programs.direnv.nix-direnv.enable = true;
programs.tealdeer.enable = true;
programs.tealdeer.settings.updates.auto_update = true;
# old alias, just learn to use ncdu lol
home.shellAliases.dush = "du -shc * | sort -h";
home.shellAliases.dushd = "du -shc * .[!.]?* | sort -h";
home.shellAliases.open = "xdg-open";
home.shellAliases.rwhich = mkArgsAlias ''which "$@" | xargs realpath --'';
home.shellAliases.grep = "grep --color";
home.shellAliases.diff = "diff -u --color"; # eyo
home.shellAliases.ip = "ip -br -color";
home.shellAliases.watch = "watch -c "; # colors
home.shellAliases.sudo = "sudo "; # support aliases
home.shellAliases.xargs = "xargs "; # support aliases
# old -> new
home.shellAliases.vimv = "edir";
#home.shellAliases.atom = "pulsar";
# 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.fda = "fd --no-ignore --hidden";
home.shellAliases.afd = "fd --no-ignore --hidden";
home.shellAliases.inom = mkArgsAlias ''nom "$@" --system i686-linux -j0'';
home.shellAliases.inix = mkArgsAlias ''nix "$@" --system i686-linux -j0'';
home.shellAliases.rnom = mkArgsAlias ''nom "$@" --system riscv64-linux -j0'';
home.shellAliases.rnix = mkArgsAlias ''nix "$@" --system riscv64-linux -j0'';
home.shellAliases.fnom = mkArgsAlias ''nom "$@" --system x86_64-freebsd -j0'';
home.shellAliases.fnix = mkArgsAlias ''nix "$@" --system x86_64-freebsd -j0'';
home.shellAliases.anom = mkArgsAlias ''nom "$@" --system aarch64-linux -j0'';
home.shellAliases.anix = mkArgsAlias ''nix "$@" --system aarch64-linux -j0'';
home.shellAliases.dnom = mkArgsAlias ''nom "$@" --system x86_64-darwin -j0'';
home.shellAliases.dnix = mkArgsAlias ''nix "$@" --system x86_64-darwin -j0'';
home.shellAliases.danom = mkArgsAlias ''nom "$@" --system aarch64-darwin -j0'';
home.shellAliases.danix = mkArgsAlias ''nix "$@" --system aarch64-darwin -j0'';
home.shellAliases.inom-build = "nom-build --system i686-linux -j0";
home.shellAliases.inix-build = "nix-build --system i686-linux -j0";
home.shellAliases.rnom-build = "nom-build --system riscv64-linux -j0";
home.shellAliases.rnix-build = "nix-build --system riscv64-linux -j0";
home.shellAliases.fnom-build = "nom-build --system x86_64-freebsd -j0";
home.shellAliases.fnix-build = "nix-build --system x86_64-freebsd -j0";
home.shellAliases.anom-build = "nom-build --system aarch64-linux -j0";
home.shellAliases.anix-build = "nix-build --system aarch64-linux -j0";
home.shellAliases.dnom-build = "nom-build --system x86_64-darwin -j0";
home.shellAliases.dnix-build = "nix-build --system x86_64-darwin -j0";
home.shellAliases.danom-build = "nom-build --system aarch64-darwin -j0";
home.shellAliases.danix-build = "nix-build --system aarch64-darwin -j0";
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
stress
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)
xh
htmlq
mprocs
just # justfile
gum
sysz systemctl-tui
#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) # ansi2txt, pipetty
]);
home.file.".config/ncdu/config".text = ''
--one-file-system
--exclude-kernfs
--color dark
'';
}