diff --git a/nnn/.config/.nnn.env b/nnn/.config/.nnn.env new file mode 100644 index 0000000..6246794 --- /dev/null +++ b/nnn/.config/.nnn.env @@ -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' diff --git a/nnn/.config/nnn/plugins/start_shell b/nnn/.config/nnn/plugins/start_shell new file mode 100755 index 0000000..aa7f137 --- /dev/null +++ b/nnn/.config/nnn/plugins/start_shell @@ -0,0 +1,7 @@ +#!/bin/zsh + +# Description: Start an interactive zsh shell. + +export nnn="$1" + +zsh -i diff --git a/zsh/.config/.aliases b/zsh/.config/.aliases index bc1d1af..74eb3eb 100644 --- a/zsh/.config/.aliases +++ b/zsh/.config/.aliases @@ -1,6 +1,5 @@ alias sx="startx" alias lss="ls -alh" -alias n="nnn" # vim alias v="nvim" diff --git a/zsh/.config/.env b/zsh/.config/.env index f11b159..5e838bc 100644 --- a/zsh/.config/.env +++ b/zsh/.config/.env @@ -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 - diff --git a/zsh/.zprofile b/zsh/.zprofile index a084100..9474a9b 100644 --- a/zsh/.zprofile +++ b/zsh/.zprofile @@ -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" diff --git a/zsh/.zshrc b/zsh/.zshrc index 1b00f87..d5f1e64 100644 --- a/zsh/.zshrc +++ b/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`