mirror of
https://github.com/jarun/nnn.git
synced 2024-11-04 18:33:12 +00:00
28 lines
588 B
Bash
Executable file
28 lines
588 B
Bash
Executable file
#!/usr/bin/env sh
|
|
|
|
# Description: Fuzzy find a file in directory subtree with fzy
|
|
# Opens in $VISUAL or $EDITOR if text
|
|
# Opens other type of files with xdg-open
|
|
#
|
|
# Requires: fzf/fzy, xdg-open
|
|
#
|
|
# Shell: POSIX compliant
|
|
# Author: Arun Prakash Jana
|
|
|
|
if which fzf >/dev/null 2>&1; then
|
|
fuzzy=fzf
|
|
elif which fzy >/dev/null 2>&1; then
|
|
fuzzy=fzy
|
|
else
|
|
exit 1
|
|
fi
|
|
|
|
entry="$(find . -type f 2>/dev/null | "$fuzzy")"
|
|
|
|
case "$(file -biL "$entry")" in
|
|
*text*)
|
|
"${VISUAL:-$EDITOR}" "$entry" ;;
|
|
*)
|
|
xdg-open "$entry" >/dev/null 2>&1 ;;
|
|
esac
|