move nnn configuration to its own file, fixes
This commit is contained in:
39
zsh/.zshrc
39
zsh/.zshrc
@@ -22,7 +22,7 @@ compinit
|
||||
autoload -U colors
|
||||
colors
|
||||
PROMPT="%{$fg_bold[yellow]%}%* %{$fg_bold[blue]%}%d %(?.$fg_bold[green]✓.$fg_bold[red]%?)
|
||||
%(3L.$fg_bold[red]%L .)%{%(?.$fg_bold[green].$fg_bold[red])%}%%%{$reset_color%} "
|
||||
%{%(3L.$fg_bold[red]%L .)%}%{%(?.$fg_bold[green].$fg_bold[red])%}%%%{$reset_color%} "
|
||||
|
||||
source $HOME/.config/.aliases
|
||||
source $HOME/.config/.aliases.local
|
||||
@@ -50,4 +50,41 @@ if [[ -f ~/.last_dir ]]; then
|
||||
cd $(cat ~/.last_dir)
|
||||
fi
|
||||
|
||||
# save path on quiting nnn (and alias it to 'n')
|
||||
function 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
|
||||
|
||||
nnn "$@"
|
||||
|
||||
if [ -f "$NNN_TMPFILE" ]; then
|
||||
. "$NNN_TMPFILE"
|
||||
rm -f "$NNN_TMPFILE" > /dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
# cd to $PWD of exited subshell in nnn
|
||||
function nnn_cd {
|
||||
if ! [ -z "$NNN_PIPE" ]; then
|
||||
printf "%s\0" "0c${PWD}" > "${NNN_PIPE}" !&
|
||||
fi
|
||||
}
|
||||
|
||||
trap nnn_cd EXIT
|
||||
|
||||
eval `keychain --eval --quiet --agents ssh,gpg id_rsa`
|
||||
|
||||
Reference in New Issue
Block a user