3 # Description: Open selected files in nuke one by one or in oneshot
5 # Notes: 1. Opens the hovered file if the selection is empty
6 # 2. nuke is the default, set OPENER below for custom
7 # 3. Opener is invoked once for each file in a loop
8 # 4. Keep pressing "Enter" to open files one by one
11 # Author: Arun Prakash Jana
13 sel=${NNN_SEL:-${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection}
14 OPENER="${XDG_CONFIG_HOME:-$HOME/.config}/nnn/plugins/nuke"
16 if [ -s "$sel" ]; then
18 while IFS= read -r -d '' entry || [ -n "$entry" ]; do
22 elements=${#targets[@]}
24 if (( elements == 1 )); then
25 # If there's only one file selected, open without prompts
26 "$OPENER" "${targets[0]}"
31 for ((index=0; index <= ${#targets[@]}; index++)); do
32 "$OPENER" "${targets[index]}"
33 if [ "$all" != "A" ] && (( index+1 < elements )); then
34 printf "press Enter to open '%s'\n" "${targets[index+1]}"
36 if [[ $key != "" ]]; then
44 if [ -s "$sel" ] && [ -p "$NNN_PIPE" ]; then
45 printf "-" > "$NNN_PIPE"
47 elif [ -n "$1" ]; then