1

Modules/Fish: Only enable nnn functions if nnn.enabled

This commit is contained in:
2025-06-23 17:00:48 +02:00
parent 17033a859e
commit 626ff32f03

View File

@ -46,44 +46,46 @@ in {
programs.fish = { programs.fish = {
enable = true; enable = true;
functions = { functions = lib.mergeAttrsList [
nnncd = { (lib.optionalAttrs config.modules.nnn.enable {
wraps = "nnn"; nnncd = {
description = "support nnn quit and change directory"; wraps = "nnn";
body = '' description = "support nnn quit and change directory";
# Block nesting of nnn in subshells body = ''
if test -n "$NNNLVL" -a "$NNNLVL" -ge 1 # Block nesting of nnn in subshells
echo "nnn is already running" if test -n "$NNNLVL" -a "$NNNLVL" -ge 1
return echo "nnn is already running"
end return
end
# The behaviour is set to cd on quit (nnn checks if NNN_TMPFILE is set) # The behaviour is set to cd on quit (nnn checks if NNN_TMPFILE is set)
# If NNN_TMPFILE is set to a custom path, it must be exported for nnn to # If NNN_TMPFILE is set to a custom path, it must be exported for nnn to
# see. To cd on quit only on ^G, remove the "-x" from both lines below, # see. To cd on quit only on ^G, remove the "-x" from both lines below,
# without changing the paths. # without changing the paths.
if test -n "$XDG_CONFIG_HOME" if test -n "$XDG_CONFIG_HOME"
set -x NNN_TMPFILE "$XDG_CONFIG_HOME/nnn/.lastd" set -x NNN_TMPFILE "$XDG_CONFIG_HOME/nnn/.lastd"
else else
set -x NNN_TMPFILE "$HOME/.config/nnn/.lastd" set -x NNN_TMPFILE "$HOME/.config/nnn/.lastd"
end end
# Unmask ^Q (, ^V etc.) (if required, see `stty -a`) to Quit nnn # Unmask ^Q (, ^V etc.) (if required, see `stty -a`) to Quit nnn
# stty start undef # stty start undef
# stty stop undef # stty stop undef
# stty lwrap undef # stty lwrap undef
# stty lnext undef # stty lnext undef
# The command function allows one to alias this function to `nnn` without # The command function allows one to alias this function to `nnn` without
# making an infinitely recursive alias # making an infinitely recursive alias
command nnn $argv command nnn $argv
if test -e $NNN_TMPFILE if test -e $NNN_TMPFILE
source $NNN_TMPFILE source $NNN_TMPFILE
rm $NNN_TMPFILE rm $NNN_TMPFILE
end end
''; '';
}; };
}; })
];
plugins = [ plugins = [
# Oh-my-fish plugins are stored in their own repositories, which # Oh-my-fish plugins are stored in their own repositories, which
@ -137,8 +139,6 @@ in {
blk = batify "lsblk -o NAME,LABEL,UUID,FSTYPE,SIZE,FSUSE%,MOUNTPOINT,MODEL"; blk = batify "lsblk -o NAME,LABEL,UUID,FSTYPE,SIZE,FSUSE%,MOUNTPOINT,MODEL";
grep = "grep --color=auto -E"; # grep with extended regex grep = "grep --color=auto -E"; # grep with extended regex
watch = "watch -d -c -n 0.5"; watch = "watch -d -c -n 0.5";
n = "nnncd -a"; # Doesn't work with abbrify because I have nnn.override?
np = "nnncd -a -P p";
ssh = "kitty +kitten ssh"; ssh = "kitty +kitten ssh";
# Systemd # Systemd
@ -148,16 +148,6 @@ in {
uniterrors = "journalctl -xb --unit="; uniterrors = "journalctl -xb --unit=";
useruniterrors = "journalctl -xb --user-unit="; useruniterrors = "journalctl -xb --user-unit=";
# NFS shares
msusenet = "sudo mount.nfs4 192.168.86.20:/mnt/WD\\ Blue\\ Stripe\\ 2T/Usenet /media/Stash-Usenet";
mspicture = "sudo mount.nfs4 192.168.86.20:/mnt/WD\\ Blue\\ Stripe\\ 2T/Picture /media/Stash-Picture";
msvideo = "sudo mount.nfs4 192.168.86.20:/mnt/WD\\ Blue\\ Stripe\\ 2T/Video /media/Stash-Video";
msclips = "sudo mount.nfs4 192.168.86.20:/mnt/WD\\ Blue\\ Stripe\\ 2T/Clips /media/Stash-Clips";
mmovie = "sudo mount.nfs4 192.168.86.20:/mnt/SG\\ Exos\\ Mirror\\ 18TB/Movie /media/Movie";
mshow = "sudo mount.nfs4 192.168.86.20:/mnt/SG\\ Exos\\ Mirror\\ 18TB/Show /media/Show";
mmusic = "sudo mount.nfs4 192.168.86.20:/mnt/SG\\ Exos\\ Mirror\\ 18TB/Music /media/Music";
musenet = "sudo mount.nfs4 192.168.86.20:/mnt/SG\\ Exos\\ Mirror\\ 18TB/Usenet /media/Usenet";
# Disassemble # Disassemble
disassemble = "objdump -d -S -M intel"; disassemble = "objdump -d -S -M intel";
} }
@ -198,6 +188,10 @@ in {
(abbrify pkgs.lazygit {lg = "lazygit";}) (abbrify pkgs.lazygit {lg = "lazygit";})
# Doesn't work with abbrify because I have nnn.override...
(lib.optionalAttrs config.modules.nnn.enable {n = "nnncd -a";})
(lib.optionalAttrs config.modules.nnn.enable {np = "nnncd -a -P p";})
(abbrify pkgs.ranger {r = "ranger --choosedir=$HOME/.rangerdir; set LASTDIR (cat $HOME/.rangerdir); cd $LASTDIR";}) (abbrify pkgs.ranger {r = "ranger --choosedir=$HOME/.rangerdir; set LASTDIR (cat $HOME/.rangerdir); cd $LASTDIR";})
(abbrify pkgs.rsync { (abbrify pkgs.rsync {