'Make custom opener for file manager

I am currently using the file manager nnn. I want to be able to open all currently selected files. This question is not specific to nnn hence I wrote an opener

#!/usr/bin/env sh

sel=${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection

if [ -s $sel ]; then
    while IFS= read -r file; do
        echo "$file"
        xdg-open $file > /dev/null
    done < $sel
    xdg-open $1
else
    xdg-open $1
fi

basic rundown $1: currently hovered file $sel: the file containing the currently selected files with each file in a line. like
<file 1>\n
<file 2>\n
<file 3>\n

But when run this script it only opens the currently hovered file.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source