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

200 lines
6.4 KiB
Nix
Raw Normal View History

2024-06-06 21:31:22 +02:00
{ pkgs, lib, config, ... }:
2023-03-04 00:09:57 +01:00
{
# 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"
];
2023-07-05 17:30:17 +02:00
programs.bash.initExtra = ''
2023-07-19 22:59:12 +02:00
bind 'set completion-ignore-case on'
2023-07-05 17:30:17 +02:00
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
2024-08-14 17:09:15 +02:00
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"
2024-08-16 21:05:52 +02:00
cp -r --dereference --one-file-system "$src/" "$dst/"
2024-08-14 17:09:15 +02:00
chmod -R +rw "$dst"
)
elif test -f "$src"; then
(set -x
rm -v "$dst"
cp -v "$src" "$dst"
chmod -v +rw "$dst"
)
fi
done
}
2024-10-19 04:05:19 +02:00
_choose_nix_systems() {
# x86_64-linux aarch64-linux aarch64-darwin x86_64-darwin i686-linux riscv64-linux x86_64-freebsd aarch64-freebsd i686-freebsd riscv64-freebsd
gum choose --no-limit --ordered --height 15 {linux,darwin,freebsd}-{x86_64,aarch64,i686,riscv64} \
| sed -E 's/^([^-]*)-([^-]*)$/\2-\1/'
}
mnix-build() {
# TODO: somehow store the out-links
2024-10-23 00:28:06 +02:00
_choose_nix_systems | xe -j0 -s 'nix-instantiate --system "$1" '"$(printf " %q" "$@")" | xargs nix-build --keep-going --no-out-link
2024-10-19 04:05:19 +02:00
}
mnom-build() {
# TODO: somehow store the out-links
2024-10-23 00:28:06 +02:00
_choose_nix_systems | xe -j0 -s 'nix-instantiate --system "$1" '"$(printf " %q" "$@")" | xargs nom-build --keep-going --no-out-link
2024-10-19 04:05:19 +02:00
}
mnixpkgs-review() {
# TODO: use /run/user/...
# mkdir -p /dev/shm/nixpkgs-review
# ln -sfn /dev/shm/nixpkgs-review $HOME/.cache/nixpkgs-review
nixpkgs-review --systems "$(_choose_nix_systems | xargs)" "$@"
}
2023-07-05 17:30:17 +02:00
'';
2023-03-04 00:09:57 +01:00
2023-03-04 01:48:55 +01:00
imports = [ ../modules/jump.nix ];
2024-02-11 05:00:48 +01:00
programs.jump.enableBash = true;
2023-03-04 01:48:55 +01:00
2024-02-18 22:14:40 +01:00
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
2024-10-20 02:52:38 +02:00
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" ];
};
2023-03-04 00:09:57 +01:00
2024-02-18 22:14:40 +01:00
programs.eza.enable = true;
2024-06-06 21:31:22 +02:00
programs.eza.enableAliases = lib.mkIf (lib.versionOlder config.home.version.release "24.05") true;
2024-02-18 22:14:40 +01:00
2024-04-20 00:37:07 +02:00
#programs.zoxide.enable = true;
#programs.zoxide.options = [ "--cmd cd --cmd dc" ];
2024-02-18 22:14:40 +01:00
2024-06-15 20:34:46 +02:00
programs.carapace.enable = true; # completions
2023-03-04 00:09:57 +01:00
# i can't type
2024-02-18 22:14:40 +01:00
home.shellAliases.sl = "eza";
#home.shellAliases.dc = "cd";
2023-03-04 00:09:57 +01:00
programs.direnv.enable = true;
2024-02-18 22:14:40 +01:00
programs.direnv.nix-direnv.enable = true;
2023-03-04 00:09:57 +01:00
programs.tealdeer.enable = true;
2024-02-18 22:14:40 +01:00
programs.tealdeer.settings.updates.auto_update = true;
2023-03-04 00:09:57 +01:00
# just use ncdu lol
home.shellAliases.dush = "du -shc * | sort -h";
home.shellAliases.dushd = "du -shc * .[!.]?* | sort -h";
2023-06-14 12:24:53 +02:00
home.shellAliases.open = "xdg-open";
2024-10-20 23:51:00 +02:00
home.shellAliases.grep = "grep --color";
2023-03-04 00:09:57 +01:00
home.shellAliases.diff = "diff -u --color"; # eyo
home.shellAliases.ip = "ip -br -color";
home.shellAliases.rssh = "ssh -l root";
2024-10-20 23:51:00 +02:00
home.shellAliases.sudo = "sudo "; # makes sudo support aliases
2023-03-04 00:09:57 +01:00
home.shellAliases.watch = "watch -c "; # parse colors
home.shellAliases.xargs = "xargs ";
2024-10-20 23:51:00 +02:00
# old -> new
2024-06-15 20:34:46 +02:00
home.shellAliases.vimv = "edir";
2024-02-18 22:14:40 +01:00
# Be conservative with files
2024-06-04 11:34:27 +02:00
# --preserver-root is for GNU versions, preventing changing perms on /
2024-02-18 22:14:40 +01:00
home.shellAliases.chown = "chown --preserve-root";
home.shellAliases.chmod = "chmod --preserve-root";
home.shellAliases.chgrp = "chgrp --preserve-root";
2024-06-04 11:34:27 +02:00
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";
2024-02-18 22:14:40 +01:00
2024-10-19 04:05:19 +02:00
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";
2024-09-13 18:12:35 +02:00
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";
2024-08-04 04:54:14 +02:00
home.shellAliases.kaomoji = "curl -s 'https://kaomoji.ru/en/' | htmlq tr td span --text | grep . | shuf | head -n1";
2024-03-23 19:33:09 +01:00
home.packages = lib.filter (x: x != null) (with pkgs; [
2023-03-04 00:09:57 +01:00
rsync
2023-07-05 13:34:19 +02:00
bind.dnsutils # dig
2023-11-10 22:55:32 +01:00
dogdns # dog
2024-06-15 20:34:46 +02:00
edir # better vimv
2023-03-04 00:09:57 +01:00
curl
wget
2024-07-31 01:57:47 +02:00
wakeonlan
2023-03-11 03:39:06 +01:00
2023-03-04 00:09:57 +01:00
#tldr
2024-08-20 03:23:38 +02:00
stress
2023-03-04 00:09:57 +01:00
entr
2023-06-24 14:48:53 +02:00
axel aria aria2
2023-03-04 00:09:57 +01:00
xe # xargs alternative
sd # sed alternative
fd # find alternative
2023-03-11 03:39:06 +01:00
silver-searcher # 'ag'
ripgrep # 'rg'
2023-10-14 18:40:32 +02:00
comby
2023-03-04 00:09:57 +01:00
gron
jq
2023-09-28 01:58:08 +02:00
fx
2023-03-11 03:39:06 +01:00
yq # includes xmlq and tomlq
fq # binary jq
2024-03-23 19:33:09 +01:00
(pkgs.jnv or unstable.jnv or null)
2023-03-04 00:09:57 +01:00
htmlq
2023-03-11 03:39:06 +01:00
just # justfile
2024-02-17 17:51:49 +01:00
gum
2023-03-04 00:09:57 +01:00
sysz
du-dust # du alternative
2024-02-18 22:14:40 +01:00
duf # df alternative
2023-03-04 00:09:57 +01:00
ncdu # Disk usage analyzer with an ncurses interface
xplr # tui file explorer
2024-02-18 22:14:40 +01:00
aha (pkgs.colorized-logs or unstable.colorized-logs)
2024-03-23 19:33:09 +01:00
]);
2023-03-04 00:09:57 +01:00
}