229 lines
7.5 KiB
Nix
229 lines
7.5 KiB
Nix
{ pkgs, lib, config, ... }:
|
|
|
|
let
|
|
|
|
# why not just use functions normally? ctrl-alt-e is why!
|
|
_tmpfn_name = "_tmpfn_ex4aiNgu"; # pwgen ftw
|
|
mkArgsAlias = alias: ''${_tmpfn_name}() { unset -f ${_tmpfn_name}; ${alias}; }; ${_tmpfn_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.historySize = 10000; # in ram
|
|
# programs.bash.historyFileSize = 100000; # on file
|
|
programs.bash.historyControl = [
|
|
"erasedups"
|
|
"ignoreboth"
|
|
];
|
|
programs.bash.historyIgnore = [ "ls" "file" "cat" "type" "exit" ];
|
|
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 file"; # respects .gitignore
|
|
fileWidgetCommand = "fd . | sort --ignore-case --general-numeric-sort"; # respects .gitignore
|
|
fileWidgetOptions = [
|
|
"--bind 'home:first'"
|
|
"--bind 'end:last'"
|
|
"--cycle"
|
|
|
|
# bat is installed in bat.nix
|
|
#"--preview 'head {}'"
|
|
# "--preview 'bat {}'"
|
|
# "--preview 'tail -n$LINES {} | bat --file-name {} --paging never --style plain'"
|
|
# "--preview 'bat {} --paging never --style plain' --preview-window follow"
|
|
"--preview 'if [[ -f {} ]]; then tail -n$LINES {} | bat --paging=never --style=plain --color=always --file-name {} ; elif [[ -e {}/.git ]]; then git -C {} status else file {} ; fi' --preview-window follow"
|
|
|
|
# https://github.com/junegunn/fzf/discussions/3363#discussioncomment-6419463
|
|
"--bind 'ctrl-a:reload:eval $FZF_DEFAULT_COMMAND --no-ignore'"
|
|
];
|
|
|
|
# ctrl-r
|
|
#historyWidgetOptions = [ "--sort" "--exact" ];
|
|
};
|
|
|
|
# TODO: slow when colors are enabled, use lsd instead?
|
|
# https://github.com/eza-community/eza/issues/922
|
|
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" ];
|
|
|
|
# # https://carapace-sh.github.io/carapace-bin/completers.html
|
|
# programs.carapace.enable = true; # completions
|
|
# programs.bash.sessionVariables.CARAPACE_EXCLUDES = "just"; # comma-separated
|
|
|
|
# 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 -d"\n" realpath --'';
|
|
home.shellAliases.rwhichcd = mkArgsAlias ''
|
|
local dir=$(which "$@" | xargs -d"\n" realpath -- | cut -d/ -f-4 | grep ^/nix/store/ | fzf --height=15 ||:)
|
|
if [[ -n "$dir" && -d "$dir" ]]; then
|
|
# history -s "$(printf "cd %q\n" "$dir")"
|
|
# history -a
|
|
cd "$dir"
|
|
fi
|
|
'';
|
|
|
|
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";
|
|
|
|
# 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.drg = lib.mkIf (config.programs.git.enable && config.programs.git.delta.enable) (
|
|
mkArgsAlias ''rg "$@" --json | delta''
|
|
);
|
|
|
|
# via nix-index-with-full-db
|
|
home.shellAliases.nlocate = "nix-locate --top-level --regex";
|
|
home.shellAliases.nlocateo = mkArgsAlias ''nix-locate --top-level --regex "$@" | tr -s ' ' | cut -d' ' -f4'';
|
|
|
|
home.shellAliases.kaomoji = "curl -s 'https://kaomoji.ru/en/' | htmlq tr td span --text | grep . | shuf | head -n1";
|
|
|
|
home.shellAliases.swgl = "env LIBGL_ALWAYS_SOFTWARE=true GALLIUM_DRIVER=llvmpipe __GLX_VENDOR_LIBRARY_NAME=mesa ";
|
|
|
|
home.packages = lib.filter (x: x != null) (with pkgs; [
|
|
rsync
|
|
bind.dnsutils # dig
|
|
# dogdns # dog, better dig
|
|
edir # better vimv
|
|
curl
|
|
wget
|
|
|
|
wakeonlan
|
|
|
|
#tldr
|
|
stress # brrr
|
|
entr # live reload
|
|
glances
|
|
# bottom
|
|
faketty
|
|
axel aria aria2 # brrr
|
|
xe # better xargs
|
|
sd # better sed
|
|
fd # better find
|
|
# silver-searcher # 'ag'
|
|
ripgrep # 'rg'
|
|
comby # ast-based rewrite
|
|
#fx # js tui viewer
|
|
gron # grep-able json
|
|
jq # json queries
|
|
yq # includes xq (xml) and tomlq
|
|
#fq # jq for binaries
|
|
xh # "friendly fast curl"
|
|
htmlq # html css queries
|
|
(pkgs.xan or null) # a jq for csv, zsv
|
|
# xee # xml xpath queries
|
|
pkgs.unstable.just # justfile
|
|
gum
|
|
mprocs
|
|
systemctl-tui
|
|
# sysz
|
|
duf # df alternative
|
|
#du-dust # better du
|
|
ncdu # du tui
|
|
hexyl # better hexdump
|
|
#xplr # tui file explorer
|
|
aha # ansi colors to html
|
|
(pkgs.colorized-logs or unstable.colorized-logs) # ansi2txt, pipetty
|
|
]);
|
|
|
|
home.file.".config/ncdu/config".text = ''
|
|
--one-file-system
|
|
--exclude-kernfs
|
|
--color dark
|
|
'';
|
|
|
|
}
|