move nnn configuration to its own file, fixes

This commit is contained in:
Václav Uruba 2021-05-09 22:16:05 +02:00
parent ea0a655fa8
commit 86c249c53b
Signed by: uruba
GPG Key ID: 9D8E987C4B2E1E9C
6 changed files with 61 additions and 8 deletions

5
nnn/.config/.nnn.env Normal file
View File

@ -0,0 +1,5 @@
export NNN_OPTS='ds'
export NNN_COLORS='1235'
export NNN_TRASH=1
export NNN_FCOLORS='c1e2272e006033f7c6d6abc4'
export NNN_PLUG='s:start_shell'

View File

@ -0,0 +1,7 @@
#!/bin/zsh
# Description: Start an interactive zsh shell.
export nnn="$1"
zsh -i

View File

@ -1,6 +1,5 @@
alias sx="startx"
alias lss="ls -alh"
alias n="nnn"
# vim
alias v="nvim"

View File

@ -1,8 +1,3 @@
export EDITOR=vim
export NNN_OPTS='ds'
export NNN_COLORS='1235'
export NNN_TRASH=1
export _JAVA_AWT_WM_NONREPARENTING=1

View File

@ -6,5 +6,15 @@ path+=("$(go env GOPATH)/bin")
export PATH
source ~/.config/.env
source ~/.config/.env.system
# source system specific environment variables
if [[ -f ~/.config/.system.env ]]; then
echo ".system.env"
source ~/.config/.system.env
fi
# source nnn environment variables
if [[ -f ~/.config/.nnn.env ]]; then
echo ".nnn.env"
source ~/.config/.nnn.env
fi
source "$HOME/.cargo/env"

View File

@ -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`