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

This commit is contained in:
2026-09-28 20:30:38 +02:00
parent b2bd384d0e
commit c6ab46f85c
13 changed files with 155 additions and 159 deletions
-57
View File
@@ -1,57 +0,0 @@
# shellcheck shell=bash
# vim: set ft=bash :
alias ..="cd .."
alias ls="ls --color=auto"
alias l="ls -1p"
alias ll="ls -lhp"
alias lt="ls -lhtp"
alias la="ls -lhap"
alias lta="ls -lhatp"
alias ldir="ls -dp" # list directories
alias grep="grep --color=auto"
alias rm="rm -I --preserve-root"
alias mv="mv -iv"
alias cp="cp -iv"
alias ln="ln -i"
alias mkdir="mkdir -pv"
alias chown="chown --preserve-root"
alias chmod="chmod --preserve-root"
alias chgrp="chgrp --preserve-root"
alias ip="ip --color"
alias ipa="ip -brief address"
alias ipl="ip -brief link"
alias ipr="ip route"
alias df="df -kTh"
alias fzfpac="pacman -Slq | fzf -m --preview 'pacman -Si {1}' | xargs -ro sudo pacman -S"
alias path='echo -e ${PATH//:/\\n}' # Pretty print path variables
# Programs
alias h="history"
alias o="xdg-open"
alias v="nvim"
alias vf="fzf --bind 'enter:become(nvim {})'"
alias g='git'
alias k="kubectl"
alias t='task'
alias tsh='tasksh'
alias z='zathura --fork'
alias f='fzf'
alias fm='pcmanfm &>/dev/null &'
alias mm='micromamba'
# Languages
alias r5="plt-r5rs --no-prim"
alias hs="ghci"
alias pl="swipl"
alias py="python"
alias r="R"
alias azerty="setxkbmap be"
alias qwerty="setxkbmap us"
alias cole="setxkbmap us -variant colemak"
-22
View File
@@ -1,22 +0,0 @@
# shellcheck shell=bash
# vim: set ft=bash :
get_branch_name() {
git symbolic-ref --quiet --short HEAD 2>/dev/null \
|| git rev-parse --short HEAD 2>/dev/null \
|| echo 'some branch'
}
get_git_info() {
git rev-parse --is-inside-work-tree &>/dev/null || return
echo -e "($(get_branch_name))"
}
if [[ $SSH_CONNECTION ]]; then
PS1='\[\033[01;31m\]\u@\h\[\033[00m\] $(get_git_info)\W❭\[$(tput sgr0)\] '
else
PS1='\u $(get_git_info)\W❭\[$(tput sgr0)\] '
fi
# Ellipsis when deep in directory
export PROMPT_DIRTRIM=2
export PS1
-33
View File
@@ -1,33 +0,0 @@
$include /etc/inputrc
set editing-mode vi
set keymap vi
set show-mode-in-prompt on
set vi-ins-mode-string "\1\e[1;32m\2■ \1\e[0m\2"
set vi-cmd-mode-string "\1\e[1;31m\2■ \1\e[0m\2"
set show-all-if-ambiguous on
set show-all-if-unmodified off
set completion-ignore-case on
set completion-map-case on
set completion-display-width 0
set page-completions off
set completion-query-items 128
set visible-stats on
set skip-completed-text on
set mark-symlinked-directories on
set colored-completion-prefix on
$if mode=vi
set keyseq-timeout 200
set keymap vi-command
"\e[A": history-search-backward
"\e[B": history-search-forward
j: history-search-forward
k: history-search-backward
set keymap vi-insert
"jj": vi-movement-mode
"\e[A": history-search-backward
"\e[B": history-search-forward
"\C-l": clear-screen
$endif
+31
View File
@@ -0,0 +1,31 @@
{
config,
lib,
pkgs,
...
}:
{
options.fzf.enable = lib.mkEnableOption "fzf";
config = lib.mkIf config.fzf.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'" ];
};
};
home.packages = with pkgs; [
ripgrep
bat
];
};
}
+46
View File
@@ -0,0 +1,46 @@
{ lib, config, ... }:
{
options.readline.enable = lib.mkEnableOption "readline";
config = lib.mkIf config.readline.enable {
programs.readline = {
enable = true;
includeSystemConfig = true;
variables = {
editing-mode = "vi";
keymap = "vi";
show-mode-in-prompt = true;
vi-ins-mode-string = ''"\1\e[1;32m\2■ \1\e[0m\2"'';
vi-cmd-mode-string = ''"\1\e[1;31m\2■ \1\e[0m\2"'';
show-all-if-ambiguous = true;
show-all-if-unmodified = false;
completion-ignore-case = true;
completion-map-case = true;
completion-display-width = 0;
page-completions = false;
completion-query-items = 128;
visible-stats = true;
skip-completed-text = true;
mark-symlinked-directories = true;
colored-completion-prefix = true;
};
extraConfig = ''
$if mode=vi
set keyseq-timeout 200
set keymap vi-command
"\e[A": history-search-backward
"\e[B": history-search-forward
j: history-search-forward
k: history-search-backward
set keymap vi-insert
"jj": vi-movement-mode
"\e[A": history-search-backward
"\e[B": history-search-forward
"\C-l": clear-screen
$endif
'';
};
};
}
+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";
}
@@ -1,8 +1,4 @@
# shellcheck shell=bash # shellcheck shell=bash
# vim: set ft=bash :
alias js="node"
alias ts="ts-node"
yarn() { yarn() {
if [[ -f "package-lock.json" ]]; then if [[ -f "package-lock.json" ]]; then
+7 -16
View File
@@ -37,7 +37,12 @@ in
programs.bash = { programs.bash = {
enable = true; enable = true;
enableCompletion = 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; historySize = 999999;
historyFileSize = -1; # unlimited historyFileSize = -1; # unlimited
historyControl = [ historyControl = [
@@ -52,29 +57,15 @@ in
"ls" "ls"
"cd" "cd"
]; ];
initExtra = '' initExtra = ''
for f in ${homeDirectory}/.bashrc.d/*; do for f in ${homeDirectory}/.bashrc.d/*; do
[ -f "$f" ] && source "$f" [ -f "$f" ] && source "$f"
done done
${lib.optionalString cfg.aliases.lang-js (builtins.readFile ./bash-js.bash)}
${lib.optionalString cfg.aliases.all "source ${homeDirectory}/.bash_aliases/all"}
${lib.optionalString cfg.aliases.lang-js "source ${homeDirectory}/.bash_aliases/lang-js"}
${cfg.extraInit} ${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"; home.sessionPath = lib.optional cfg.addBinToPath "${dotsPath}/.bin";
}; };
} }
+12 -2
View File
@@ -7,13 +7,23 @@
{ {
imports = [ imports = [
./bash.nix ./bash.nix
./utils.nix
./prompt.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 { config = lib.mkIf config.shell.enable {
fzf.enable = lib.mkDefault true;
readline.enable = lib.mkDefault true;
tmux.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 = { programs.starship = {
enable = true; enable = true;
settings = { settings = {
+2 -16
View File
@@ -1,26 +1,12 @@
{ {
config,
lib, lib,
config,
pkgs, pkgs,
... ...
}: }:
{ {
config = lib.mkIf config.shell.enable { config = lib.mkIf config.utils.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'" ];
};
};
home.packages = with pkgs; [ home.packages = with pkgs; [
ripgrep ripgrep
bat bat
+1 -4
View File
@@ -6,13 +6,10 @@
... ...
}: }:
let
cfg = config.tmux;
in
{ {
options.tmux.enable = lib.mkEnableOption "tmux"; options.tmux.enable = lib.mkEnableOption "tmux";
config = lib.mkIf cfg.enable { config = lib.mkIf config.tmux.enable {
home.packages = with pkgs; [ home.packages = with pkgs; [
tmuxp tmuxp
reptyr reptyr
+1 -4
View File
@@ -1,14 +1,11 @@
{ lib, config, ... }: { lib, config, ... }:
let
cfg = config.audio;
in
{ {
imports = [ ./audio-automation.nix ]; imports = [ ./audio-automation.nix ];
options.audio.enable = lib.mkEnableOption "audio"; options.audio.enable = lib.mkEnableOption "audio";
config = lib.mkIf cfg.enable { config = lib.mkIf config.audio.enable {
nixpkgs.allowedUnfree = [ nixpkgs.allowedUnfree = [
"spotify" "spotify"
"spotify-unwrapped" "spotify-unwrapped"