Skip to content

Commit

Permalink
home-manager/nnn: replace n() with quitcd
Browse files Browse the repository at this point in the history
  • Loading branch information
thiagokokada committed Nov 8, 2023
1 parent 28ad4a3 commit da90140
Showing 1 changed file with 4 additions and 28 deletions.
32 changes: 4 additions & 28 deletions home-manager/cli/nnn.nix
Original file line number Diff line number Diff line change
Expand Up @@ -53,34 +53,10 @@ in
};
};

programs.zsh.initExtra = ''
n()
{
# Block nesting of nnn in subshells
if [ -n $NNNLVL ] && [ "''${NNNLVL:-0}" -ge 1 ]; then
echo "nnn is already running"
return
fi
# The default behaviour is to cd on quit (nnn checks if NNN_TMPFILE is set)
# To cd on quit only on ^G, remove the "export" as in:
# NNN_TMPFILE="''${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.lastd"
# NOTE: NNN_TMPFILE is fixed, should not be modified
export NNN_TMPFILE="''${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.lastd"
# Unmask ^Q (, ^V etc.) (if required, see `stty -a`) to Quit nnn
# stty start undef
# stty stop undef
# stty lwrap undef
# stty lnext undef
${config.programs.nnn.finalPackage}/bin/nnn -a "$@"
if [ -f "$NNN_TMPFILE" ]; then
. "$NNN_TMPFILE"
rm -f "$NNN_TMPFILE" > /dev/null
fi
}
programs.zsh.initExtra = /* bash */ ''
# Export NNN_TMPFILE to quit on cd always
export NNN_TMPFILE="${config.xdg.configHome}/nnn/.lastd"
. ${config.programs.nnn.finalPackage}/share/quitcd/quitcd.bash_sh_zsh
'';
};
}

0 comments on commit da90140

Please sign in to comment.