mirror of
https://github.com/jarun/nnn.git
synced 2024-11-24 11:51:27 +00:00
nerdicon/preview fixes
This commit is contained in:
parent
a1cb764943
commit
a5a1c7b82c
|
@ -19,27 +19,27 @@ icon_lookup() {
|
||||||
awk 'BEGIN {
|
awk 'BEGIN {
|
||||||
# Set your ANSI colorscheme below (https://en.wikipedia.org/wiki/ANSI_escape_code#Colors).
|
# Set your ANSI colorscheme below (https://en.wikipedia.org/wiki/ANSI_escape_code#Colors).
|
||||||
# Default uses standard nnn icon colors, 8 and 24-bit nord themes are commented out.
|
# Default uses standard nnn icon colors, 8 and 24-bit nord themes are commented out.
|
||||||
colordepth=8 #colordepth=8 #colordepth=24
|
colordepth=8 #colordepth=8 #colordepth=24
|
||||||
color_dirtxt=39 #color_dirtxt=111 #color_dirtxt="129;161;193"
|
color_dirtxt=39 #color_dirtxt=111 #color_dirtxt="129;161;193"
|
||||||
color_filetxt=15 #color_filetxt=111 #color_filetxt="129;161;193"
|
color_filetxt=15 #color_filetxt=111 #color_filetxt="129;161;193"
|
||||||
color_default=39 #color_default=111 #color_default="129;161;193"
|
color_default=39 #color_default=111 #color_default="129;161;193"
|
||||||
color_video=93 #color_video=110 #color_video="136;192;208"
|
color_video=93 #color_video=110 #color_video="136;192;208"
|
||||||
color_audio=220 #color_audio=150 #color_audio="163;190;140"
|
color_audio=220 #color_audio=150 #color_audio="163;190;140"
|
||||||
color_image=82 #color_image=150 #color_image="163;190;140"
|
color_image=82 #color_image=150 #color_image="163;190;140"
|
||||||
color_docs=202 #color_docs=173 #color_docs="208;135;112"
|
color_docs=202 #color_docs=173 #color_docs="208;135;112"
|
||||||
color_archive=209 #color_archive=179 #color_archive="235;203;139"
|
color_archive=209 #color_archive=179 #color_archive="235;203;139"
|
||||||
color_c=81 #color_c=150 #color_c="163;190;140"
|
color_c=81 #color_c=150 #color_c="163;190;140"
|
||||||
color_java=32 #color_java=139 #color_java="180;142;173"
|
color_java=32 #color_java=139 #color_java="180;142;173"
|
||||||
color_js=47 #color_js=109 #color_js="143;188;187"
|
color_js=47 #color_js=109 #color_js="143;188;187"
|
||||||
color_react=39 #color_react=111 #color_react="129;161;193"
|
color_react=39 #color_react=111 #color_react="129;161;193"
|
||||||
color_css=199 #color_css=110 #color_css="136;192;208"
|
color_css=199 #color_css=110 #color_css="136;192;208"
|
||||||
color_python=227 #color_python=68 #color_python="94;129;172"
|
color_python=227 #color_python=68 #color_python="94;129;172"
|
||||||
color_lua=19 #color_lua=167 #color_lua="191;97;106"
|
color_lua=19 #color_lua=167 #color_lua="191;97;106"
|
||||||
color_document=15 #color_document=173 #color_document="208;135;112"
|
color_document=15 #color_document=173 #color_document="208;135;112"
|
||||||
color_fsharp=31 #color_fsharp=179 #color_fsharp="180;142;173"
|
color_fsharp=31 #color_fsharp=179 #color_fsharp="180;142;173"
|
||||||
color_ruby=160 #color_ruby=150 #color_ruby="163;190;140"
|
color_ruby=160 #color_ruby=150 #color_ruby="163;190;140"
|
||||||
color_scala=196 #color_scala=139 #color_scala="143;188;187"
|
color_scala=196 #color_scala=139 #color_scala="143;188;187"
|
||||||
color_vim=28 #color_vim=109 #color_vim="143;188;187"
|
color_vim=28 #color_vim=109 #color_vim="143;188;187"
|
||||||
|
|
||||||
# icons[][1] contains icon and icons[][2] contains color
|
# icons[][1] contains icon and icons[][2] contains color
|
||||||
icons["directory"][1] = ""; icons["directory"][2] = color_default
|
icons["directory"][1] = ""; icons["directory"][2] = color_default
|
||||||
|
@ -68,7 +68,7 @@ color_vim=28 #color_vim=109 #color_vim="143;188;187"
|
||||||
icons["configure"][1] = ""; icons["configure"][2] = color_default
|
icons["configure"][1] = ""; icons["configure"][2] = color_default
|
||||||
icons["license"][1] = ""; icons["license"][2] = color_docs
|
icons["license"][1] = ""; icons["license"][2] = color_docs
|
||||||
icons["makefile"][1] = ""; icons["makefile"][2] = color_default
|
icons["makefile"][1] = ""; icons["makefile"][2] = color_default
|
||||||
icons["archive"][1] = "遲"; icons["archive"][2] = color_archive
|
icons["archive"][1] = ""; icons["archive"][2] = color_archive
|
||||||
icons["script"][1] = ""; icons["script"][2] = color_default
|
icons["script"][1] = ""; icons["script"][2] = color_default
|
||||||
icons["cplusplus"][1] = ""; icons["cplusplus"][2] = color_c
|
icons["cplusplus"][1] = ""; icons["cplusplus"][2] = color_c
|
||||||
icons["java"][1] = ""; icons["java"][2] = color_java
|
icons["java"][1] = ""; icons["java"][2] = color_java
|
||||||
|
@ -127,7 +127,7 @@ color_vim=28 #color_vim=109 #color_vim="143;188;187"
|
||||||
# d
|
# d
|
||||||
icons["db"][1] = icons["database"][1]; icons["db"][2] = icons["database"][2]
|
icons["db"][1] = icons["database"][1]; icons["db"][2] = icons["database"][2]
|
||||||
icons["deb"][1] = ""; icons["deb"][2] = color_archive
|
icons["deb"][1] = ""; icons["deb"][2] = color_archive
|
||||||
icons["diff"][1] = "繁"; icons["diff"][2] = color_default
|
icons["diff"][1] = ""; icons["diff"][2] = color_default
|
||||||
icons["dll"][1] = icons["script"][1]; icons["dll"][2] = icons["script"][2]
|
icons["dll"][1] = icons["script"][1]; icons["dll"][2] = icons["script"][2]
|
||||||
icons["doc"][1] = icons["worddoc"][1]; icons["doc"][2] = icons["worddoc"][2]
|
icons["doc"][1] = icons["worddoc"][1]; icons["doc"][2] = icons["worddoc"][2]
|
||||||
icons["docx"][1] = icons["worddoc"][1]; icons["docx"][2] = icons["worddoc"][2]
|
icons["docx"][1] = icons["worddoc"][1]; icons["docx"][2] = icons["worddoc"][2]
|
||||||
|
@ -200,7 +200,7 @@ color_vim=28 #color_vim=109 #color_vim="143;188;187"
|
||||||
icons["mp4"][1] = icons["videofile"][1]; icons["mp4"][2] = icons["videofile"][2]
|
icons["mp4"][1] = icons["videofile"][1]; icons["mp4"][2] = icons["videofile"][2]
|
||||||
icons["mpeg"][1] = icons["videofile"][1]; icons["mpeg"][2] = icons["videofile"][2]
|
icons["mpeg"][1] = icons["videofile"][1]; icons["mpeg"][2] = icons["videofile"][2]
|
||||||
icons["mpg"][1] = icons["videofile"][1]; icons["mpg"][2] = icons["videofile"][2]
|
icons["mpg"][1] = icons["videofile"][1]; icons["mpg"][2] = icons["videofile"][2]
|
||||||
icons["msi"][1] = "者"; icons["msi"][2] = color_default
|
icons["msi"][1] = ""; icons["msi"][2] = color_default
|
||||||
|
|
||||||
# n
|
# n
|
||||||
|
|
||||||
|
@ -212,7 +212,7 @@ color_vim=28 #color_vim=109 #color_vim="143;188;187"
|
||||||
|
|
||||||
# p
|
# p
|
||||||
icons["part"][1] = icons["download"][1]; icons["part"][2] = icons["download"][2]
|
icons["part"][1] = icons["download"][1]; icons["part"][2] = icons["download"][2]
|
||||||
icons["patch"][1] = "繁"; icons["patch"][2] = color_default
|
icons["patch"][1] = icons["diff"][1]; icons["patch"][2] = icons["diff"][2]
|
||||||
icons["pdf"][1] = ""; icons["pdf"][2] = color_docs
|
icons["pdf"][1] = ""; icons["pdf"][2] = color_docs
|
||||||
icons["php"][1] = ""; icons["php"][2] = color_default
|
icons["php"][1] = ""; icons["php"][2] = color_default
|
||||||
icons["png"][1] = icons["picturefile"][1]; icons["png"][2] = icons["picturefile"][2]
|
icons["png"][1] = icons["picturefile"][1]; icons["png"][2] = icons["picturefile"][2]
|
||||||
|
@ -297,6 +297,7 @@ color_vim=28 #color_vim=109 #color_vim="143;188;187"
|
||||||
escape="\033[38;2;"
|
escape="\033[38;2;"
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
bstr = ENVIRON["beforestr"]
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
# dont print cwd . and leading ./ from tree -f
|
# dont print cwd . and leading ./ from tree -f
|
||||||
|
@ -304,25 +305,26 @@ color_vim=28 #color_vim=109 #color_vim="143;188;187"
|
||||||
next
|
next
|
||||||
ent = ($0 ~/^\.\//) ? substr($0, 3, length($0) - 2) : $0
|
ent = ($0 ~/^\.\//) ? substr($0, 3, length($0) - 2) : $0
|
||||||
ext = $NF
|
ext = $NF
|
||||||
|
|
||||||
# Print icons, set color and bold directories by using ansi escape codes
|
# Print icons, set color and bold directories by using ansi escape codes
|
||||||
if (ext in icons)
|
if (ext in icons)
|
||||||
printcolor(icons[ext][1], icons[ext][2], color_filetxt, ent, "10")
|
printcolor(icons[ext][1], icons[ext][2], color_filetxt, ent, "10")
|
||||||
else
|
else
|
||||||
switch (substr(ent, length(ent), 1)) {
|
switch (substr(ent, length(ent), 1)) {
|
||||||
case "/":
|
case "/":
|
||||||
printcolor(icons["directory"][1], color_default, color_dirtxt, ent, "1")
|
printcolor(icons["directory"][1], color_default, color_dirtxt, substr(ent, 1, length(ent) - 1), "1")
|
||||||
break;
|
break;
|
||||||
case "*":
|
case "*":
|
||||||
printcolor(icons["exe"][1], color_default, color_filetxt, ent, "10")
|
printcolor(icons["exe"][1], color_default, color_filetxt, substr(ent, 1, length(ent) - 1), "10")
|
||||||
break;
|
break;
|
||||||
case "|":
|
case "|":
|
||||||
printcolor(icons["pipe"][1], color_default, color_filetxt, ent, "10")
|
printcolor(icons["pipe"][1], color_default, color_filetxt, substr(ent, 1, length(ent) - 1), "10")
|
||||||
break;
|
break;
|
||||||
case "=":
|
case "=":
|
||||||
printcolor(icons["socket"][1], color_default, color_filetxt, ent, "10")
|
printcolor(icons["socket"][1], color_default, color_filetxt, substr(ent, 1, length(ent) - 1), "10")
|
||||||
break;
|
break;
|
||||||
case ">":
|
case ">":
|
||||||
printcolor(icons["door"][1], color_default, color_filetxt, ent, "10")
|
printcolor(icons["door"][1], color_default, color_filetxt, substr(ent, 1, length(ent) - 1), "10")
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
printcolor(icons["file"][1], color_default, color_filetxt, ent, "10")
|
printcolor(icons["file"][1], color_default, color_filetxt, ent, "10")
|
||||||
|
@ -332,16 +334,16 @@ function printcolor(i, c, d, n, b) {
|
||||||
if (limit != "" && length(n) + 2 > limit)
|
if (limit != "" && length(n) + 2 > limit)
|
||||||
n = substr(n, 1, limit - 2)
|
n = substr(n, 1, limit - 2)
|
||||||
printf "\033[0m"
|
printf "\033[0m"
|
||||||
printf "%s%s;%sm%s %s%sm%s\n", escape, c, b, i, escape, d, n
|
printf "%s%s%s;%sm%s %s%sm%s\n", bstr, escape, c, b, i, escape, d, n
|
||||||
}'
|
}'
|
||||||
printf '\033[0m'
|
printf '\033[0m'
|
||||||
}
|
}
|
||||||
|
|
||||||
print_before() {
|
print_begin() {
|
||||||
printf '%s\n' "$1" | sed 's/\\n/\n/g'
|
printf '%s\n' "$1" | sed 's/\\n/\n/g'
|
||||||
}
|
}
|
||||||
|
|
||||||
print_after() {
|
print_end() {
|
||||||
printf '%s\n' "$1" | sed 's/\\n/\n/g'
|
printf '%s\n' "$1" | sed 's/\\n/\n/g'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -349,8 +351,7 @@ print_help() {
|
||||||
printf 'Icon Lookup\n
|
printf 'Icon Lookup\n
|
||||||
Usage:
|
Usage:
|
||||||
iconlookup [options]
|
iconlookup [options]
|
||||||
iconlookup -b [string]
|
iconlookup [-bBe] [string]
|
||||||
iconlookup -a [string]
|
|
||||||
iconlookup -l [number]
|
iconlookup -l [number]
|
||||||
iconlookup (-h | --help)
|
iconlookup (-h | --help)
|
||||||
|
|
||||||
|
@ -358,8 +359,9 @@ Usage:
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
-h --help -? Show this screen.
|
-h --help -? Show this screen.
|
||||||
-a --after Append string after output.
|
-b --before Prepend str before icon.
|
||||||
-b --before Prepend string before output.
|
-B --begin Prepend str before output.
|
||||||
|
-e --end Append str after output.
|
||||||
-l --limit Limit line length to [number] characters.'
|
-l --limit Limit line length to [number] characters.'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -368,23 +370,22 @@ while :; do
|
||||||
-h|-\?|--help)
|
-h|-\?|--help)
|
||||||
print_help
|
print_help
|
||||||
exit ;;
|
exit ;;
|
||||||
|
-B|--begin)
|
||||||
|
if [ -n "$2" ]; then
|
||||||
|
print_begin "$2"
|
||||||
|
fi
|
||||||
|
shift ;;
|
||||||
|
-e|--end)
|
||||||
|
if [ -n "$2" ]; then
|
||||||
|
end=1
|
||||||
|
endstr="$2"
|
||||||
|
fi
|
||||||
|
shift ;;
|
||||||
-b|--before)
|
-b|--before)
|
||||||
if [ -n "$2" ]; then
|
if [ -n "$2" ]; then
|
||||||
print_before "$2"
|
export beforestr="$2"
|
||||||
shift
|
fi
|
||||||
else
|
shift ;;
|
||||||
printf 'ERROR: "--before" requires a non-empty option argument.\n'
|
|
||||||
exit
|
|
||||||
fi ;;
|
|
||||||
-a|--after)
|
|
||||||
if [ -n "$2" ]; then
|
|
||||||
after=1
|
|
||||||
afterstring="$2"
|
|
||||||
shift
|
|
||||||
else
|
|
||||||
printf 'ERROR: "--after" requires a non-empty option argument.\n'
|
|
||||||
exit
|
|
||||||
fi ;;
|
|
||||||
-l|--limit)
|
-l|--limit)
|
||||||
if [ -n "$2" ]; then
|
if [ -n "$2" ]; then
|
||||||
export limit="$2"
|
export limit="$2"
|
||||||
|
@ -404,11 +405,12 @@ while :; do
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ ! -t 0 ]; then
|
if [ ! -t 0 ]; then
|
||||||
|
[ -n "$beforestr" ] && limit="$((limit - ${#beforestr}))"
|
||||||
icon_lookup
|
icon_lookup
|
||||||
else
|
else
|
||||||
printf 'ERROR: no data provided...\nExpecting a directory listing in stdin\n'
|
printf 'ERROR: no data provided...\nExpecting a directory listing in stdin\n'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "$after" ]; then
|
if [ -n "$end" ]; then
|
||||||
print_after "$afterstring"
|
print_end "$endstr"
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -169,7 +169,8 @@ preview_file() {
|
||||||
cd "$1" || return
|
cd "$1" || return
|
||||||
if exists tree; then
|
if exists tree; then
|
||||||
if [ "$ICONLOOKUP" -ne 0 ]; then
|
if [ "$ICONLOOKUP" -ne 0 ]; then
|
||||||
tree -L 1 --dirsfirst -F --noreport -i | head -n "$((lines - 3))" | "$(dirname "$0")"/.iconlookup -l "$cols" -b "\n"
|
[ "$SPLIT" = h ] && BSTR="\n"
|
||||||
|
tree -L 1 --dirsfirst -F --noreport -i | head -n "$((lines - 3))" | "$(dirname "$0")"/.iconlookup -l "$cols" -B "$BSTR" -b " "
|
||||||
else
|
else
|
||||||
fifo_pager tree -L 1 --dirsfirst -C -F --noreport -i
|
fifo_pager tree -L 1 --dirsfirst -C -F --noreport -i
|
||||||
fi;
|
fi;
|
||||||
|
@ -178,7 +179,7 @@ preview_file() {
|
||||||
else
|
else
|
||||||
fifo_pager ls --color=always
|
fifo_pager ls --color=always
|
||||||
fi
|
fi
|
||||||
elif [ "$encoding" = "binary" ]; then
|
elif [ "${encoding#*)}" = "binary" ]; then
|
||||||
if [ "${mimetype%%/*}" = "image" ]; then
|
if [ "${mimetype%%/*}" = "image" ]; then
|
||||||
if [ "${mimetype#*/}" = "gif" ] && exists convert; then
|
if [ "${mimetype#*/}" = "gif" ] && exists convert; then
|
||||||
generate_preview "$cols" "$lines" "$1" "gif"
|
generate_preview "$cols" "$lines" "$1" "gif"
|
||||||
|
@ -365,7 +366,7 @@ if [ "$TERMINAL" = "tmux" ]; then
|
||||||
# tmux splits are inverted
|
# tmux splits are inverted
|
||||||
if [ "$SPLIT" = "v" ]; then SPLIT="h"; else SPLIT="v"; fi
|
if [ "$SPLIT" = "v" ]; then SPLIT="h"; else SPLIT="v"; fi
|
||||||
|
|
||||||
tmux split-window -e "NNN_FIFO=$NNN_FIFO" -e "PREVIEW_MODE=1" -d"$SPLIT" "$0" "$1"
|
tmux split-window -e "NNN_FIFO=$NNN_FIFO" -e "PREVIEW_MODE=1" -e "SPLIT=$SPLIT" -d"$SPLIT" "$0" "$1"
|
||||||
elif [ "$TERMINAL" = "kitty" ]; then
|
elif [ "$TERMINAL" = "kitty" ]; then
|
||||||
# Setting the layout for the new window. It will be restored after the
|
# Setting the layout for the new window. It will be restored after the
|
||||||
# script ends.
|
# script ends.
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
#define ICON_CONFIGURE "\uf423"
|
#define ICON_CONFIGURE "\uf423"
|
||||||
#define ICON_LICENSE "\uf718"
|
#define ICON_LICENSE "\uf718"
|
||||||
#define ICON_MAKEFILE "\uf68c"
|
#define ICON_MAKEFILE "\uf68c"
|
||||||
#define ICON_ARCHIVE "\ufac3"
|
#define ICON_ARCHIVE "\uf53b"
|
||||||
#define ICON_SCRIPT "\ue795"
|
#define ICON_SCRIPT "\ue795"
|
||||||
#define ICON_CPLUSPLUS "\ue61d"
|
#define ICON_CPLUSPLUS "\ue61d"
|
||||||
#define ICON_JAVA "\ue738"
|
#define ICON_JAVA "\ue738"
|
||||||
|
@ -88,7 +88,7 @@
|
||||||
/* D */
|
/* D */
|
||||||
#define ICON_EXT_DB ICON_DATABASE
|
#define ICON_EXT_DB ICON_DATABASE
|
||||||
#define ICON_EXT_DEB "\ue77d"
|
#define ICON_EXT_DEB "\ue77d"
|
||||||
#define ICON_EXT_DIFF "\ufa59"
|
#define ICON_EXT_DIFF "\uf440"
|
||||||
#define ICON_EXT_DLL ICON_SCRIPT
|
#define ICON_EXT_DLL ICON_SCRIPT
|
||||||
#define ICON_EXT_DOC ICON_WORDDOC
|
#define ICON_EXT_DOC ICON_WORDDOC
|
||||||
#define ICON_EXT_DOCX ICON_WORDDOC
|
#define ICON_EXT_DOCX ICON_WORDDOC
|
||||||
|
@ -160,7 +160,7 @@
|
||||||
#define ICON_EXT_MP4 ICON_VIDEOFILE
|
#define ICON_EXT_MP4 ICON_VIDEOFILE
|
||||||
#define ICON_EXT_MPEG ICON_VIDEOFILE
|
#define ICON_EXT_MPEG ICON_VIDEOFILE
|
||||||
#define ICON_EXT_MPG ICON_VIDEOFILE
|
#define ICON_EXT_MPG ICON_VIDEOFILE
|
||||||
#define ICON_EXT_MSI "\ufab2"
|
#define ICON_EXT_MSI "\uf871"
|
||||||
|
|
||||||
/* N */
|
/* N */
|
||||||
|
|
||||||
|
@ -172,7 +172,7 @@
|
||||||
|
|
||||||
/* P */
|
/* P */
|
||||||
#define ICON_EXT_PART ICON_DOWNLOADS
|
#define ICON_EXT_PART ICON_DOWNLOADS
|
||||||
#define ICON_EXT_PATCH "\ufa59"
|
#define ICON_EXT_PATCH "\uf440"
|
||||||
#define ICON_EXT_PDF "\uf724"
|
#define ICON_EXT_PDF "\uf724"
|
||||||
#define ICON_EXT_PHP "\ue73d"
|
#define ICON_EXT_PHP "\ue73d"
|
||||||
#define ICON_EXT_PNG ICON_PICTUREFILE
|
#define ICON_EXT_PNG ICON_PICTUREFILE
|
||||||
|
|
Loading…
Reference in a new issue