diff options
Diffstat (limited to '%HOME%')
-rw-r--r-- | %HOME%/.bashrc | 23 | ||||
-rwxr-xr-x | %HOME%/.config/nnn/plugins/myfzcd | 46 | ||||
-rw-r--r-- | %HOME%/.profile | 15 |
3 files changed, 84 insertions, 0 deletions
diff --git a/%HOME%/.bashrc b/%HOME%/.bashrc index 164d7b1..8264895 100644 --- a/%HOME%/.bashrc +++ b/%HOME%/.bashrc @@ -114,3 +114,26 @@ ranger() { exit fi } + +# nnn + +# The selected paths. +alias ncp="cat ${NNN_SEL:-${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection} | tr '\0' '\n'" + +# Like quitcd.bash_zsh, but better. +n() { + [ -n "$NNNLVL" ] && [ "${NNNLVL:-0}" -ge 1 ] && exit + + export NNN_TMPFILE="${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.lastd" + + /usr/bin/nnn "$@" + + if [ -f "$NNN_TMPFILE" ]; then + . "$NNN_TMPFILE" + rm -f -- "$NNN_TMPFILE" > /dev/null + fi +} + +nnn() { + n "$@" +} diff --git a/%HOME%/.config/nnn/plugins/myfzcd b/%HOME%/.config/nnn/plugins/myfzcd new file mode 100755 index 0000000..36bfb24 --- /dev/null +++ b/%HOME%/.config/nnn/plugins/myfzcd @@ -0,0 +1,46 @@ +#!/usr/bin/env bash + +# Like the fzcd plugin, but better. + +set -o errexit -o pipefail + +if command -v fzf > /dev/null 2>&1; then + sel="$( fzf )" +else + exit 1 +fi + +nnn_cd() { + dir="$1" + + if [ -z "$NNN_PIPE" ]; then + echo "No pipe file found" >&2 + return + fi + + printf -- '%s' "0c$dir" > "$NNN_PIPE" +} + + +if [ -n "$sel" ]; then + if [ ! -d "$sel" ]; then + sel="$( dirname -- "$sel" )" + elif [ "$sel" = . ]; then + exit 0 + fi + + case "$sel" in + /*) + nnn_cd "$sel" + ;; + *) + sel="${sel#./}" + + if [ "$PWD" = "/" ]; then + nnn_cd "/$sel" + else + nnn_cd "$PWD/$sel" + fi + ;; + esac +fi diff --git a/%HOME%/.profile b/%HOME%/.profile index ccb1f92..acef9ed 100644 --- a/%HOME%/.profile +++ b/%HOME%/.profile @@ -103,3 +103,18 @@ command -v systemctl > /dev/null 2>&1 || spawn_ssh_agent # Rust-specific stuff: path_export "$HOME/.cargo/bin" + +# fzf + +# Search directories and hidden files by default. +export FZF_DEFAULT_COMMAND='find -L . -\( -fstype dev -o -fstype proc -\) -prune -o -print 2> /dev/null' + +command -v fd > /dev/null 2>&1 \ + && export FZF_DEFAULT_COMMAND='fd --follow --show-errors --hidden 2> /dev/null' + +# nnn +# -e Open text files in $EDITOR. +# -H Show hidden files. +# -o Only open on Enter, not on l. +export NNN_OPTS=eHo +export NNN_PLUG='f:myfzcd' |