nnn: update settings for v4.1

Also WMs: clean up application rules
This commit is contained in:
Hoang Nguyen 2021-06-02 08:58:01 +03:00
parent 3d0e045de2
commit 30ed001766
No known key found for this signature in database
GPG Key ID: 813CF484F4993419
16 changed files with 242 additions and 160 deletions

View File

@ -54,14 +54,9 @@ bspc config presel_feedback_color "#d8dee9"
# bspc config presel_feedback_color "#abb2bf" # bspc config presel_feedback_color "#abb2bf"
# Program rules # Program rules
bspc rule -a "Gimp-2.10" state=floating follow=on
bspc rule -a "Gimp" state=floating follow=on
bspc rule -a "Thunderbird" desktop='^3' follow=on bspc rule -a "Thunderbird" desktop='^3' follow=on
bspc rule -a "Inkscape" state=floating follow=on
bspc rule -a "krita" state=floating follow=on
bspc rule -a "mpv" desktop='^6' state=tiled follow=on bspc rule -a "mpv" desktop='^6' state=tiled follow=on
bspc rule -a "Zathura" desktop='^4' follow=on bspc rule -a "Zathura" desktop='^4' follow=on
bspc rule -a "Element" desktop='^7' follow=on bspc rule -a "Element" desktop='^7' follow=on
bspc rule -a "TelegramDesktop" desktop='^7' follow=on
bspc rule -a "Emacs" state=tiled bspc rule -a "Emacs" state=tiled
bspc rule -a "Komikku" state=floating follow=on bspc rule -a "Komikku" state=floating follow=on

View File

@ -1,7 +1,7 @@
#!/usr/bin/env sh #!/usr/bin/env sh
# Description: Allows for creation of multiple files/directories at the same time. # Description: Allows for creation of multiple files/dirs simultaneously
# Plugin opens a temp file where each entry is to be written on a separate line # Creates a tmp file to write each entry in a separate line
# #
# Note: Only relative paths are supported. Absolute paths are ignored # Note: Only relative paths are supported. Absolute paths are ignored
# Leading and trailing whitespace in path names is also ignored # Leading and trailing whitespace in path names is also ignored

View File

@ -1,22 +1,99 @@
#!/usr/bin/env sh #!/usr/bin/env sh
# Description: Run fzf and go to the directory of the file selected # Description: Fuzzy search multiple locations read-in from a path-list file
# (or $PWD) and open the selected file's dir in a smart context.
# Dependencies: fzf, fd (only for multi-location search)
#
# Details: Paths in list file should be newline-separated absolute paths.
# Paths can be file paths; the script will scan the parent dirs.
#
# The path-list file precedence is:
# - "$1" (the hovered file) if it exists, is plain-text and the
# first line points to an existing file
# - "$LIST" if set below
# - "$2" (the current directory) [mimics plugin fzcd behaviour]
#
# The path-list file can be generated easily:
# - pick the (file)paths in picker mode to path-list file
# - OR, edit selection in nnn and save as path-list file
#
# The plugin clears nnn selection as the user can be tempted to delete
# duplicate files after finding copies and remove selection by mistake.
# #
# Shell: POSIX compliant # Shell: POSIX compliant
# Author: Anna Arad # Author: Anna Arad, Arun Prakash Jana
IFS="$(printf '\n\r')"
. "$(dirname "$0")"/.nnn-plugin-helper . "$(dirname "$0")"/.nnn-plugin-helper
if [ "$(cmd_exists fzf)" -eq "0" ]; then CTX=+
sel=$(fd --type d --follow --hidden --exclude .git | fzf --preview 'exa -1a --sort=type --color always --icons {} 2>/dev/null') LIST="$LIST"
else
if ! type fzf >/dev/null 2>&1; then
printf "fzf missing"
read -r _
exit 1 exit 1
fi fi
if [ -n "$sel" ]; then if [ -n "$1" ] && [ "$(file -b --mime-type "$1")" = 'text/plain' ] && [ -e "$(head -1 "$1")" ]; then
# Check if selected path returned by fzf command is absolute LIST="$1"
case $sel in elif ! [ -s "$LIST" ]; then
/*) nnn_cd "$sel" ;; # Clear selection
*) nnn_cd "$PWD/$sel" ;; if [ -p "$NNN_PIPE" ]; then
esac printf "-" >"$NNN_PIPE"
fi
sel=$(fzf)
# Show only the file and parent dir
# sel=$(fzf --delimiter / --with-nth=-2,-1 --tiebreak=begin --info=hidden)
LIST=''
fi
if [ -n "$LIST" ]; then
if type fd >/dev/null 2>&1; then
tmpfile=$(mktemp /tmp/abc-script.XXXXXX)
while IFS= read -r path; do
if [ -d "$path" ]; then
printf "%s\n" "$path" >> "$tmpfile"
elif [ -f "$path" ]; then
printf "%s\n" "$(dirname "$path")" >> "$tmpfile"
fi
done < "$LIST"
# Clear selection
if [ -p "$NNN_PIPE" ]; then
printf "-" >"$NNN_PIPE"
fi
sel=$(xargs -d '\n' -a "$tmpfile" fd -H . | fzf --delimiter / --tiebreak=begin --info=hidden)
rm "$tmpfile"
else
printf "fd missing"
read -r _
exit 1
fi
fi
if [ -n "$sel" ]; then
if [ "$sel" = "." ] || { ! [ -d "$sel" ] && ! [ -f "$sel" ]; }; then
exit 0
fi
# Check if the selected path returned by fzf command is absolute
case $sel in
/*) nnn_cd "$sel" "$CTX" ;;
*)
# Remove "./" prefix if it exists
sel="${sel#./}"
if [ "$PWD" = "/" ]; then
nnn_cd "/$sel" "$CTX"
else
nnn_cd "$PWD/$sel" "$CTX"
fi;;
esac
fi fi

View File

@ -1,30 +1,57 @@
#!/usr/bin/env sh #!/usr/bin/env sh
# Description: Fuzzy find a file in directory subtree # Description: Regular mode:
# Opens in $VISUAL or $EDITOR if text # Fuzzy find a file in directory subtree.
# Opens other type of files with xdg-open # Opens in $VISUAL or $EDITOR if text.
# Opens other type of files with xdg-open.
# Work only with a single file selected.
#
# Picker mode:
# If picker mode output file is passed, it
# will be overwritten with any picked files.
# Leaves untouched if no file is picked.
# Works with single/multiple files selected.
# #
# Dependencies: fd/find, fzf/skim, xdg-open # Dependencies: fd/find, fzf/skim, xdg-open
# #
# Shell: POSIX compliant # Shell: POSIX compliant
# Author: Arun Prakash Jana # Author: Arun Prakash Jana
if which fzf >/dev/null 2>&1; then . "$(dirname "$0")"/.nnn-plugin-helper
if type fzf >/dev/null 2>&1; then
cmd="$FZF_DEFAULT_COMMAND" cmd="$FZF_DEFAULT_COMMAND"
if which fd >/dev/null 2>&1; then if type fd >/dev/null 2>&1; then
[ -z "$cmd" ] && cmd="fd -t f 2>/dev/null" [ -z "$cmd" ] && cmd="fd -t f 2>/dev/null"
else else
[ -z "$cmd" ] && cmd="find . -type f 2>/dev/null" [ -z "$cmd" ] && cmd="find . -type f 2>/dev/null"
fi fi
entry="$(eval "$cmd" | fzf --delimiter / --nth=-1 --tiebreak=begin --info=hidden)" entry="$(eval "$cmd" | fzf -m --delimiter / --nth=-1 --tiebreak=begin --info=hidden)"
# To show only the file name # To show only the file name
# entry=$(find . -type f 2>/dev/null | fzf --delimiter / --with-nth=-1 --tiebreak=begin --info=hidden) # entry=$(find . -type f 2>/dev/null | fzf --delimiter / --with-nth=-1 --tiebreak=begin --info=hidden)
elif which sk >/dev/null 2>&1; then elif type sk >/dev/null 2>&1; then
entry=$(find . -type f 2>/dev/null | sk) entry=$(find . -type f 2>/dev/null | sk)
else else
exit 1 exit 1
fi fi
# Check for picker mode
if [ "$3" ]; then
if [ "$entry" ]; then
if [ "-" = "$3" ]; then
printf "%s\n" "$entry"
else
printf "%s\n" "$entry" > "$3"
fi
# Tell `nnn` to clear its internal selection
printf "%s" "0p" > "$NNN_PIPE"
fi
exit 0
fi
# Open the file (works for a single file only)
case "$(file -biL "$entry")" in case "$(file -biL "$entry")" in
*text*) *text*)
"${VISUAL:-$EDITOR}" "$entry" ;; "${VISUAL:-$EDITOR}" "$entry" ;;

View File

@ -7,7 +7,7 @@
. "$(dirname "$0")"/.nnn-plugin-helper . "$(dirname "$0")"/.nnn-plugin-helper
if which fzf >/dev/null 2>&1; then if type fzf >/dev/null 2>&1; then
fuzzy="fzf --no-multi" fuzzy="fzf --no-multi"
else else
exit 1 exit 1

View File

@ -1,8 +1,10 @@
#!/usr/bin/env sh #!/usr/bin/env sh
# Description: Decrypts selected files using gpg. The contents of the decrypted file are stored in a file with extension .dec # Description: Decrypts selected files using gpg. The contents of the
# decrypted file are stored in a file with extension .dec
# #
# Note: If an appropriate private key cannot be found gpg silently prints a message in the background and no files are written. # Note: If an appropriate private key cannot be found gpg silently
# prints a message in the background and no files are written.
# #
# Shell: POSIX compliant # Shell: POSIX compliant
# Author: KlzXS # Author: KlzXS

View File

@ -1,9 +1,11 @@
#!/usr/bin/env sh #!/usr/bin/env sh
# Description: Encrypts selected files using gpg. Can encrypt either asymmetrically (key) or symmetrically (passphrase). # Description: Encrypts selected files using gpg. Can encrypt
# If asymmetric encryption is chosen a key can be chosen from the list of capable public keys using fzf. # asymmetrically (key) or symmetrically (passphrase).
# If asymmetric encryption is chosen a key can be
# chosen from the list of capable public keys using fzf.
# #
# Note: symmetric encryption only works for a single (current) file as per gpg limitations # Note: Symmetric encryption only works for a single (current) file as per gpg limitations
# #
# Shell: POSIX compliant # Shell: POSIX compliant
# Author: KlzXS # Author: KlzXS

View File

@ -1,13 +1,14 @@
#!/usr/bin/env sh #!/usr/bin/env sh
# Description: View a file in hex # Description: View a file in hex
#
# Dependencies: hx (https://github.com/krpors/hx)/xxd and $PAGER # Dependencies: hx (https://github.com/krpors/hx)/xxd and $PAGER
# #
# Shell: POSIX compliant # Shell: POSIX compliant
# Author: Arun Prakash Jana # Author: Arun Prakash Jana
if ! [ -z "$1" ]; then if [ -n "$1" ]; then
if which hx >/dev/null 2>&1; then if type hx >/dev/null 2>&1; then
hx "$1" hx "$1"
else else
xxd "$1" | $PAGER xxd "$1" | $PAGER

View File

@ -4,19 +4,21 @@
# If the device is not mounted, it will be mounted. # If the device is not mounted, it will be mounted.
# If the device is mounted, it will be unmounted and powered down. # If the device is mounted, it will be unmounted and powered down.
# #
# Runs `lsblk` if 'l' is entered, exits on 'Return`. # Dependencies: lsblk, pmount
# #
# Note: # Usage: Runs `lsblk` on 'l', exits on 'Return`.
# - The script uses Linux-specific lsblk to list block devices. Alternatives: #
# Notes:
# - The script uses Linux-specific lsblk to list block devices. Alternatives:
# macOS: "diskutil list" # macOS: "diskutil list"
# BSD: "geom disk list" # BSD: "geom disk list"
# - The script uses udisksctl (from udisks2) to pwoer down devices. This is also Linux-specific. # - The script uses udisksctl (from udisks2) to power down devices. This is also Linux-specific.
# Users on non-Linux platforms can comment it and use an alterntive to power-down disks. # Users on non-Linux platforms can comment it and use an alterntive to power-down disks.
# #
# Shell: POSIX compliant # Shell: POSIX compliant
# Author: Arun Prakash Jana # Author: Arun Prakash Jana
prompt="device name ['l' lists]: " prompt="device name [e.g. sdXn] ('l'ist, 'q'uit): "
lsblk lsblk
@ -24,7 +26,7 @@ printf "\nEnsure you aren't still in the mounted device.\n"
printf "%s" "$prompt" printf "%s" "$prompt"
read -r dev read -r dev
while ! [ -z "$dev" ] while [ -n "$dev" ]
do do
if [ "$dev" = "l" ]; then if [ "$dev" = "l" ]; then
lsblk lsblk

View File

@ -1,6 +1,5 @@
#!/usr/bin/env sh #!/usr/bin/env sh
# #############################################################################
# Description: Sample script to play files in apps by file type or mime # Description: Sample script to play files in apps by file type or mime
# #
# Shell: POSIX compliant # Shell: POSIX compliant
@ -14,7 +13,7 @@
# 2. Run nnn with the program option to indicate a CLI opener # 2. Run nnn with the program option to indicate a CLI opener
# nnn -c # nnn -c
# # The -c program option overrides option -e # # The -c program option overrides option -e
# 3. nuke can use nnn plugins (e.g. mocplay is used for audio), $PATH is updated. # 3. nuke can use nnn plugins (e.g. mocq is used for audio), $PATH is updated.
# #
# Details: # Details:
# Inspired by ranger's scope.sh, modified for usage with nnn. # Inspired by ranger's scope.sh, modified for usage with nnn.
@ -42,7 +41,7 @@
# rar: list with unrar # rar: list with unrar
# 7-zip: list with 7z # 7-zip: list with 7z
# pdf: zathura (GUI), pdftotext, mutool, exiftool # pdf: zathura (GUI), pdftotext, mutool, exiftool
# audio: mocplay (nnn plugin using MOC), mpv, media_client (Haiku), mediainfo, exiftool # audio: mocq (nnn plugin using MOC), mpv, media_client (Haiku), mediainfo, exiftool
# avi|mkv|mp4: smplayer, mpv (GUI), ffmpegthumbnailer, mediainfo, exiftool # avi|mkv|mp4: smplayer, mpv (GUI), ffmpegthumbnailer, mediainfo, exiftool
# log: vi # log: vi
# torrent: rtorrent, transmission-show # torrent: rtorrent, transmission-show
@ -53,17 +52,16 @@
# Multimedia by mime: # Multimedia by mime:
# image/*: imv/sxiv (GUI), viu (https://github.com/atanunq/viu), img2txt, exiftool # image/*: imv/sxiv (GUI), viu (https://github.com/atanunq/viu), img2txt, exiftool
# video/*: smplayer, mpv (GUI), ffmpegthumbnailer, mediainfo, exiftool # video/*: smplayer, mpv (GUI), ffmpegthumbnailer, mediainfo, exiftool
# audio/*: mocplay (nnn plugin using MOC), mpv, media_client (Haiku), mediainfo, exiftool # audio/*: mocq (nnn plugin using MOC), mpv, media_client (Haiku), mediainfo, exiftool
# application/pdf: zathura (GUI), pdftotext, mutool, exiftool # application/pdf: zathura (GUI), pdftotext, mutool, exiftool
# Other mimes: # Other mimes:
# text/troff: man -l # text/troff: man -l
# text/* | */xml: vi # text/* | */xml: vi
# image/vnd.djvu): djvutxt, exiftool # image/vnd.djvu): djvutxt, exiftool
# #
# ToDo: # TODO:
# 1. Adapt, test and enable all mimes # 1. Adapt, test and enable all mimes
# 2. Clean-up the unnecessary exit codes # 2. Clean-up the unnecessary exit codes
# #############################################################################
# set to 1 to enable GUI apps # set to 1 to enable GUI apps
GUI="${GUI:-0}" GUI="${GUI:-0}"
@ -88,67 +86,68 @@ is_mac() {
} }
handle_pdf() { handle_pdf() {
if [ "$GUI" -ne 0 ] && is_mac; then if [ "$GUI" -ne 0 ]; then
nohup open "${FPATH}" >/dev/null 2>&1 & if is_mac; then
exit 0 nohup open "${FPATH}" >/dev/null 2>&1 &
elif [ "$GUI" -ne 0 ] && which zathura >/dev/null 2>&1; then elif type zathura >/dev/null 2>&1; then
nohup zathura "${FPATH}" >/dev/null 2>&1 & nohup zathura "${FPATH}" >/dev/null 2>&1 &
exit 0 else
elif which pdftotext >/dev/null 2>&1; then return
fi
elif type pdftotext >/dev/null 2>&1; then
## Preview as text conversion ## Preview as text conversion
pdftotext -l 10 -nopgbrk -q -- "${FPATH}" - | eval "$PAGER" pdftotext -l 10 -nopgbrk -q -- "${FPATH}" - | eval "$PAGER"
exit 0 elif type mutool >/dev/null 2>&1; then
elif which mutool >/dev/null 2>&1; then
mutool draw -F txt -i -- "${FPATH}" 1-10 | eval "$PAGER" mutool draw -F txt -i -- "${FPATH}" 1-10 | eval "$PAGER"
exit 0 elif type exiftool >/dev/null 2>&1; then
elif which exiftool >/dev/null 2>&1; then
exiftool "${FPATH}" | eval "$PAGER" exiftool "${FPATH}" | eval "$PAGER"
exit 0 else
return
fi fi
exit 0
} }
handle_audio() { handle_audio() {
if which mocp >/dev/null 2>&1 && which mocplay >/dev/null 2>&1; then if type mocp >/dev/null 2>&1 && type mocq >/dev/null 2>&1; then
mocplay "${FPATH}" "opener" >/dev/null 2>&1 mocq "${FPATH}" "opener" >/dev/null 2>&1
exit 0 elif type mpv >/dev/null 2>&1; then
elif which mpv >/dev/null 2>&1; then
mpv "${FPATH}" >/dev/null 2>&1 & mpv "${FPATH}" >/dev/null 2>&1 &
exit 0 elif type media_client >/dev/null 2>&1; then
elif which media_client >/dev/null 2>&1; then
media_client play "${FPATH}" >/dev/null 2>&1 & media_client play "${FPATH}" >/dev/null 2>&1 &
exit 0 elif type mediainfo >/dev/null 2>&1; then
elif which mediainfo >/dev/null 2>&1; then
mediainfo "${FPATH}" | eval "$PAGER" mediainfo "${FPATH}" | eval "$PAGER"
exit 0 elif type exiftool >/dev/null 2>&1; then
elif which exiftool >/dev/null 2>&1; then
exiftool "${FPATH}"| eval "$PAGER" exiftool "${FPATH}"| eval "$PAGER"
exit 0 else
return
fi fi
exit 0
} }
handle_video() { handle_video() {
if [ "$GUI" -ne 0 ] && is_mac; then if [ "$GUI" -ne 0 ]; then
nohup open "${FPATH}" >/dev/null 2>&1 & if is_mac; then
exit 0 nohup open "${FPATH}" >/dev/null 2>&1 &
elif [ "$GUI" -ne 0 ] && which smplayer >/dev/null 2>&1; then elif type smplayer >/dev/null 2>&1; then
nohup smplayer "${FPATH}" >/dev/null 2>&1 & nohup smplayer "${FPATH}" >/dev/null 2>&1 &
exit 0 elif type mpv >/dev/null 2>&1; then
elif [ "$GUI" -ne 0 ] && which mpv >/dev/null 2>&1; then nohup mpv "${FPATH}" >/dev/null 2>&1 &
nohup mpv "${FPATH}" >/dev/null 2>&1 & else
exit 0 return
elif which ffmpegthumbnailer >/dev/null 2>&1; then fi
elif type ffmpegthumbnailer >/dev/null 2>&1; then
# Thumbnail # Thumbnail
[ -d "${IMAGE_CACHE_PATH}" ] || mkdir "${IMAGE_CACHE_PATH}" [ -d "${IMAGE_CACHE_PATH}" ] || mkdir "${IMAGE_CACHE_PATH}"
ffmpegthumbnailer -i "${FPATH}" -o "${IMAGE_CACHE_PATH}/${FNAME}.jpg" -s 0 ffmpegthumbnailer -i "${FPATH}" -o "${IMAGE_CACHE_PATH}/${FNAME}.jpg" -s 0
viu -n "${IMAGE_CACHE_PATH}/${FNAME}.jpg" | eval "$PAGER" viu -n "${IMAGE_CACHE_PATH}/${FNAME}.jpg" | eval "$PAGER"
exit 0 elif type mediainfo >/dev/null 2>&1; then
elif which mediainfo >/dev/null 2>&1; then
mediainfo "${FPATH}" | eval "$PAGER" mediainfo "${FPATH}" | eval "$PAGER"
exit 0 elif type exiftool >/dev/null 2>&1; then
elif which exiftool >/dev/null 2>&1; then
exiftool "${FPATH}"| eval "$PAGER" exiftool "${FPATH}"| eval "$PAGER"
exit 0 else
return
fi fi
exit 0
} }
# handle this extension and exit # handle this extension and exit
@ -157,22 +156,22 @@ handle_extension() {
## Archive ## Archive
a|ace|alz|arc|arj|bz|bz2|cab|cpio|deb|gz|jar|lha|lz|lzh|lzma|lzo|\ a|ace|alz|arc|arj|bz|bz2|cab|cpio|deb|gz|jar|lha|lz|lzh|lzma|lzo|\
rpm|rz|t7z|tar|tbz|tbz2|tgz|tlz|txz|tZ|tzo|war|xpi|xz|Z|zip) rpm|rz|t7z|tar|tbz|tbz2|tgz|tlz|txz|tZ|tzo|war|xpi|xz|Z|zip)
if which atool >/dev/null 2>&1; then if type atool >/dev/null 2>&1; then
atool --list -- "${FPATH}" | eval "$PAGER" atool --list -- "${FPATH}" | eval "$PAGER"
exit 0 exit 0
elif which bsdtar >/dev/null 2>&1; then elif type bsdtar >/dev/null 2>&1; then
bsdtar --list --file "${FPATH}" | eval "$PAGER" bsdtar --list --file "${FPATH}" | eval "$PAGER"
exit 0 exit 0
fi fi
exit 1;; exit 1;;
rar) rar)
if which unrar >/dev/null 2>&1; then if type unrar >/dev/null 2>&1; then
## Avoid password prompt by providing empty password ## Avoid password prompt by providing empty password
unrar lt -p- -- "${FPATH}" | eval "$PAGER" unrar lt -p- -- "${FPATH}" | eval "$PAGER"
fi fi
exit 1;; exit 1;;
7z) 7z)
if which 7z >/dev/null 2>&1; then if type 7z >/dev/null 2>&1; then
## Avoid password prompt by providing empty password ## Avoid password prompt by providing empty password
7z l -p -- "${FPATH}" | eval "$PAGER" 7z l -p -- "${FPATH}" | eval "$PAGER"
exit 0 exit 0
@ -201,10 +200,10 @@ handle_extension() {
## BitTorrent ## BitTorrent
torrent) torrent)
if which rtorrent >/dev/null 2>&1; then if type rtorrent >/dev/null 2>&1; then
rtorrent "${FPATH}" rtorrent "${FPATH}"
exit 0 exit 0
elif which transmission-show >/dev/null 2>&1; then elif type transmission-show >/dev/null 2>&1; then
transmission-show -- "${FPATH}" transmission-show -- "${FPATH}"
exit 0 exit 0
fi fi
@ -212,7 +211,7 @@ handle_extension() {
## OpenDocument ## OpenDocument
odt|ods|odp|sxw) odt|ods|odp|sxw)
if which odt2txt >/dev/null 2>&1; then if type odt2txt >/dev/null 2>&1; then
## Preview as text conversion ## Preview as text conversion
odt2txt "${FPATH}" | eval "$PAGER" odt2txt "${FPATH}" | eval "$PAGER"
exit 0 exit 0
@ -221,10 +220,10 @@ handle_extension() {
## Markdown ## Markdown
md) md)
if which glow >/dev/null 2>&1; then if type glow >/dev/null 2>&1; then
glow -sdark "${FPATH}" | eval "$PAGER" glow -sdark "${FPATH}" | eval "$PAGER"
exit 0 exit 0
elif which lowdown >/dev/null 2>&1; then elif type lowdown >/dev/null 2>&1; then
lowdown -Tterm "${FPATH}" | eval "$PAGER" lowdown -Tterm "${FPATH}" | eval "$PAGER"
exit 0 exit 0
fi fi
@ -233,13 +232,13 @@ handle_extension() {
## HTML ## HTML
htm|html|xhtml) htm|html|xhtml)
## Preview as text conversion ## Preview as text conversion
if which w3m >/dev/null 2>&1; then if type w3m >/dev/null 2>&1; then
w3m -dump "${FPATH}" | eval "$PAGER" w3m -dump "${FPATH}" | eval "$PAGER"
exit 0 exit 0
elif which lynx >/dev/null 2>&1; then elif type lynx >/dev/null 2>&1; then
lynx -dump -- "${FPATH}" | eval "$PAGER" lynx -dump -- "${FPATH}" | eval "$PAGER"
exit 0 exit 0
elif which elinks >/dev/null 2>&1; then elif type elinks >/dev/null 2>&1; then
elinks -dump "${FPATH}" | eval "$PAGER" elinks -dump "${FPATH}" | eval "$PAGER"
exit 0 exit 0
fi fi
@ -247,10 +246,10 @@ handle_extension() {
## JSON ## JSON
json) json)
if which jq >/dev/null 2>&1; then if type jq >/dev/null 2>&1; then
jq --color-output . "${FPATH}" | eval "$PAGER" jq --color-output . "${FPATH}" | eval "$PAGER"
exit 0 exit 0
elif which python >/dev/null 2>&1; then elif type python >/dev/null 2>&1; then
python -m json.tool -- "${FPATH}" | eval "$PAGER" python -m json.tool -- "${FPATH}" | eval "$PAGER"
exit 0 exit 0
fi fi
@ -308,22 +307,24 @@ handle_multimedia() {
## Image ## Image
image/*) image/*)
if [ "$GUI" -ne 0 ] && is_mac; then if [ "$GUI" -ne 0 ]; then
nohup open "${FPATH}" >/dev/null 2>&1 & if is_mac; then
exit 0 nohup open "${FPATH}" >/dev/null 2>&1 &
elif [ "$GUI" -ne 0 ] && which imvr >/dev/null 2>&1; then exit 0
load_dir imvr "${FPATH}" >/dev/null 2>&1 & elif type imvr >/dev/null 2>&1; then
exit 0 load_dir imvr "${FPATH}" >/dev/null 2>&1 &
elif [ "$GUI" -ne 0 ] && which sxiv >/dev/null 2>&1; then exit 0
load_dir sxiv "${FPATH}" >/dev/null 2>&1 & elif type sxiv >/dev/null 2>&1; then
exit 0 load_dir sxiv "${FPATH}" >/dev/null 2>&1 &
elif which viu >/dev/null 2>&1; then exit 0
fi
elif type viu >/dev/null 2>&1; then
viu -n "${FPATH}" | eval "$PAGER" viu -n "${FPATH}" | eval "$PAGER"
exit 0 exit 0
elif which img2txt >/dev/null 2>&1; then elif type img2txt >/dev/null 2>&1; then
img2txt --gamma=0.6 -- "${FPATH}" | eval "$PAGER" img2txt --gamma=0.6 -- "${FPATH}" | eval "$PAGER"
exit 0 exit 0
elif which exiftool >/dev/null 2>&1; then elif type exiftool >/dev/null 2>&1; then
exiftool "${FPATH}" | eval "$PAGER" exiftool "${FPATH}" | eval "$PAGER"
exit 0 exit 0
fi fi
@ -466,11 +467,11 @@ handle_mime() {
## DjVu ## DjVu
image/vnd.djvu) image/vnd.djvu)
if which djvutxt >/dev/null 2>&1; then if type djvutxt >/dev/null 2>&1; then
## Preview as text conversion (requires djvulibre) ## Preview as text conversion (requires djvulibre)
djvutxt "${FPATH}" | eval "$PAGER" djvutxt "${FPATH}" | eval "$PAGER"
exit 0 exit 0
elif which exiftool >/dev/null 2>&1; then elif type exiftool >/dev/null 2>&1; then
exiftool "${FPATH}" | eval "$PAGER" exiftool "${FPATH}" | eval "$PAGER"
exit 0 exit 0
fi fi
@ -479,12 +480,14 @@ handle_mime() {
} }
handle_fallback() { handle_fallback() {
if [ "$GUI" -ne 0 ] && which xdg-open >/dev/null 2>&1; then if [ "$GUI" -ne 0 ]; then
nohup xdg-open "${FPATH}" >/dev/null 2>&1 & if type xdg-open >/dev/null 2>&1; then
exit 0 nohup xdg-open "${FPATH}" >/dev/null 2>&1 &
elif [ "$GUI" -ne 0 ] && which open >/dev/null 2>&1; then exit 0
nohup open "${FPATH}" >/dev/null 2>&1 & elif type open >/dev/null 2>&1; then
exit 0 nohup open "${FPATH}" >/dev/null 2>&1 &
exit 0
fi
fi fi
echo '----- File details -----' && file --dereference --brief -- "${FPATH}" echo '----- File details -----' && file --dereference --brief -- "${FPATH}"

View File

@ -3,21 +3,21 @@
# Description: Batch rename selection or current directory with qmv # Description: Batch rename selection or current directory with qmv
# #
# Notes: # Notes:
# - Try to mimic current batch rename functionality but with correct # - Try to mimic current batch rename functionality but with correct
# handling of edge cases by qmv or vidir. # handling of edge cases by qmv or vidir.
# Qmv opens with hidden files if no selection is used. Selected # - Qmv opens with hidden files if no selection is used. Selected
# directories are shown. # directories are shown.
# Vidir don't show directories nor hidden files. # - Vidir don't show directories nor hidden files.
# #
# Shell: POSIX compliant # Shell: POSIX compliant
# Author: José Neder # Author: José Neder
selection=${NNN_SEL:-${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection} selection=${NNN_SEL:-${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection}
if which qmv >/dev/null 2>&1; then if type qmv >/dev/null 2>&1; then
batchrenamesel="qmv -fdo -da" batchrenamesel="qmv -fdo -da"
batchrename="qmv -fdo -a" batchrename="qmv -fdo -a"
elif which vidir >/dev/null 2>&1; then elif type vidir >/dev/null 2>&1; then
batchrenamesel="vidir" batchrenamesel="vidir"
batchrename="vidir" batchrename="vidir"
else else
@ -33,6 +33,11 @@ fi
if [ "$resp" = "y" ]; then if [ "$resp" = "y" ]; then
# -o flag is necessary for interactive editors # -o flag is necessary for interactive editors
xargs -o -0 $batchrenamesel < "$selection" xargs -o -0 $batchrenamesel < "$selection"
# Clear selection
if [ -p "$NNN_PIPE" ]; then
printf "-" > "$NNN_PIPE"
fi
elif [ ! "$(LC_ALL=C ls -a)" = ". elif [ ! "$(LC_ALL=C ls -a)" = ".
.." ]; then .." ]; then
# On older systems that don't have ls -A # On older systems that don't have ls -A

View File

@ -7,15 +7,10 @@
EDITOR="${EDITOR:-vim}" EDITOR="${EDITOR:-vim}"
is_cmd_exists () { if type sudo >/dev/null 2>&1; then
which "$1" > /dev/null 2>&1
echo $?
}
if [ "$(is_cmd_exists sudo)" -eq "0" ]; then
sudo "$EDITOR" "$1" sudo "$EDITOR" "$1"
elif [ "$(is_cmd_exists sudoedit)" -eq "0" ]; then elif type sudoedit >/dev/null 2>&1; then
sudoedit "$1" sudoedit "$1"
elif [ "$(is_cmd_exists doas)" -eq "0" ]; then elif type doas >/dev/null 2>&1; then
doas "$EDITOR" "$1" doas "$EDITOR" "$1"
fi fi

View File

@ -78,13 +78,8 @@ modkey = Mod4
# QUIRKS # QUIRKS
quirk[Firefox:Dialog] = FLOAT quirk[Firefox:Dialog] = FLOAT
quirk[Element] = WS[7] quirk[Element] = WS[7]
quirk[TelegramDesktop] = WS[7]
quirk[Zathura] = WS[4] quirk[Zathura] = WS[4]
quirk[mpv] = WS[6] quirk[mpv] = WS[6]
quirk[krita] = FLOAT
quirk[Inkscape] = FLOAT
quirk[Gimp-2.10] = FLOAT
quirk[Gimp] = FLOAT
quirk[Thunderbird] = WS[3] quirk[Thunderbird] = WS[3]
quirk[Emacs:emacs] = IGNORESPAWNWS quirk[Emacs:emacs] = IGNORESPAWNWS
quirk[Komikku] = FLOAT quirk[Komikku] = FLOAT

View File

@ -78,13 +78,8 @@ modkey = Mod4
# QUIRKS # QUIRKS
quirk[Firefox:Dialog] = FLOAT quirk[Firefox:Dialog] = FLOAT
quirk[Element] = WS[7] quirk[Element] = WS[7]
quirk[TelegramDesktop] = WS[7]
quirk[Zathura] = WS[4] quirk[Zathura] = WS[4]
quirk[mpv] = WS[6] quirk[mpv] = WS[6]
quirk[krita] = FLOAT
quirk[Inkscape] = FLOAT
quirk[Gimp-2.10] = FLOAT
quirk[Gimp] = FLOAT
quirk[Thunderbird] = WS[3] quirk[Thunderbird] = WS[3]
quirk[Emacs:emacs] = IGNORESPAWNWS quirk[Emacs:emacs] = IGNORESPAWNWS
quirk[Komikku] = FLOAT quirk[Komikku] = FLOAT

View File

@ -342,9 +342,6 @@ bindsym $mod+Shift+0 move container to workspace $ws10
# #
# Floating # Floating
for_window [app_id="info.febvre.Komikku"] floating enable for_window [app_id="info.febvre.Komikku"] floating enable
for_window [class="Gimp-2.10"] floating enable
for_window [app_id="org.inkscape.Inkscape"] floating enable
for_window [class="krita"] floating enable
for_window [title="About Mozilla Firefox"] floating enable for_window [title="About Mozilla Firefox"] floating enable
for_window [title="Picture-in-Picture"] floating enable for_window [title="Picture-in-Picture"] floating enable
@ -353,4 +350,3 @@ assign [app_id="thunderbird"] $ws3
assign [app_id="org.pwmt.zathura"] $ws4 assign [app_id="org.pwmt.zathura"] $ws4
assign [app_id="mpv"] $ws6 assign [app_id="mpv"] $ws6
assign [class="Element"] $ws7 assign [class="Element"] $ws7
assign [app_id="org.telegram.desktop.desktop"] $ws7

View File

@ -1,13 +0,0 @@
#!/bin/sh -e
git clone https://github.com/FollieHiyuki/nnn.git
cd nnn
if command -v doas >/dev/null
then
doas -- make O_NERD=1 PREFIX=/usr install
else
sudo make O_NERD=1 PREFIX=/usr install
fi
cd ..