refactor(shell): nixify remaining shell config
check / lint (push) Successful in 14s

This commit is contained in:
2026-09-28 20:43:36 +02:00
parent b2bd384d0e
commit 093a60a261
20 changed files with 155 additions and 293 deletions
+54
View File
@@ -0,0 +1,54 @@
{
".." = "cd ..";
ls = "ls --color=auto";
l = "ls -1p";
ll = "ls -lhp";
lt = "ls -lhtp";
la = "ls -lhap";
lta = "ls -lhatp";
ldir = "ls -dp"; # list directories
grep = "grep --color=auto";
rm = "rm -I --preserve-root";
mv = "mv -iv";
cp = "cp -iv";
ln = "ln -i";
mkdir = "mkdir -pv";
chown = "chown --preserve-root";
chmod = "chmod --preserve-root";
chgrp = "chgrp --preserve-root";
ip = "ip --color";
ipa = "ip -brief address";
ipl = "ip -brief link";
ipr = "ip route";
df = "df -kTh";
fzfpac = "pacman -Slq | fzf -m --preview 'pacman -Si {1}' | xargs -ro sudo pacman -S";
path = ''echo -e ''${PATH//:/\\n}''; # Pretty print path variables
# Programs
h = "history";
o = "xdg-open";
v = "nvim";
vf = "fzf --bind 'enter:become(nvim {})'";
g = "git";
k = "kubectl";
t = "task";
tsh = "tasksh";
z = "zathura --fork";
f = "fzf";
fm = "pcmanfm &>/dev/null &";
mm = "micromamba";
# Languages
r5 = "plt-r5rs --no-prim";
hs = "ghci";
pl = "swipl";
py = "python";
r = "R";
azerty = "setxkbmap be";
qwerty = "setxkbmap us";
cole = "setxkbmap us -variant colemak";
}
+31
View File
@@ -0,0 +1,31 @@
# shellcheck shell=bash
yarn() {
if [[ -f "package-lock.json" ]]; then
echo "WARNING: package-lock.json exists"
read -p "Are you sure you want to run yarn? [y/N] " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
command yarn "$@"
else
echo "Aborted"
fi
else
command yarn "$@"
fi
}
npm() {
if [[ -f "yarn.lock" ]]; then
echo "WARNING: yarn.lock exists"
read -p "Are you sure you want to run npm? [y/N] " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
command npm "$@"
else
echo "Aborted"
fi
else
command npm "$@"
fi
}
+7 -16
View File
@@ -37,7 +37,12 @@ in
programs.bash = {
enable = true;
enableCompletion = true;
shellAliases =
lib.optionalAttrs cfg.aliases.all (import ./bash-aliases.nix)
// lib.optionalAttrs cfg.aliases.lang-js {
js = "node";
ts = "ts-node";
};
historySize = 999999;
historyFileSize = -1; # unlimited
historyControl = [
@@ -52,29 +57,15 @@ in
"ls"
"cd"
];
initExtra = ''
for f in ${homeDirectory}/.bashrc.d/*; do
[ -f "$f" ] && source "$f"
done
${lib.optionalString cfg.aliases.all "source ${homeDirectory}/.bash_aliases/all"}
${lib.optionalString cfg.aliases.lang-js "source ${homeDirectory}/.bash_aliases/lang-js"}
${lib.optionalString cfg.aliases.lang-js (builtins.readFile ./bash-js.bash)}
${cfg.extraInit}
'';
};
home.file = {
".inputrc".source = dotsPath + "/.inputrc";
".bashrc.d/prompt".source = dotsPath + "/.bashrc.d/prompt";
}
// lib.optionalAttrs cfg.aliases.all {
".bash_aliases/all".source = dotsPath + "/.bash_aliases/all";
}
// lib.optionalAttrs cfg.aliases.lang-js {
".bash_aliases/lang-js".source = dotsPath + "/.bash_aliases/lang-js";
};
home.sessionPath = lib.optional cfg.addBinToPath "${dotsPath}/.bin";
};
}
+12 -2
View File
@@ -7,13 +7,23 @@
{
imports = [
./bash.nix
./utils.nix
./prompt.nix
./utils.nix
];
options.shell.enable = lib.mkEnableOption "shell";
options = {
shell.enable = lib.mkEnableOption "shell";
prompt.enable = lib.mkEnableOption "shell prompt" // {
default = config.shell.enable;
};
utils.enable = lib.mkEnableOption "shell utilities" // {
default = config.shell.enable;
};
};
config = lib.mkIf config.shell.enable {
fzf.enable = lib.mkDefault true;
readline.enable = lib.mkDefault true;
tmux.enable = lib.mkDefault true;
};
}
+1 -1
View File
@@ -5,7 +5,7 @@
}:
{
config = lib.mkIf config.shell.enable {
config = lib.mkIf config.prompt.enable {
programs.starship = {
enable = true;
settings = {
+2 -16
View File
@@ -1,26 +1,12 @@
{
config,
lib,
config,
pkgs,
...
}:
{
config = lib.mkIf config.shell.enable {
programs.fzf = {
enable = true;
enableBashIntegration = lib.mkDefault true;
defaultCommand = "rg --files";
defaultOptions = [
"--pointer='❭'"
"--height 10%"
];
fileWidget = {
command = "rg --files";
options = [ "--preview 'bat {} | head -500'" ];
};
};
config = lib.mkIf config.utils.enable {
home.packages = with pkgs; [
ripgrep
bat