Guidance with bash shell scripting?

ArchieLinux

New Member
Joined
Jun 10, 2026
Messages
1
Reaction score
1
Credits
26
Greetings! Long time Arch/EOS user but brand new to this forum. I've got a bash scripting challenge that I cannot readily solve...

Specifics: Currently, within the ranger file manager, I can use a shell script to launch an email app (in message composition mode) with a single attachment. But I'd like to be able to add multiple attachments (selected within ranger) to an email composition. The email app is thunderbird or betterbird (same difference).

Here's what I've already got that successfully launches the email app in composition mode with a single selected file as the attachment:

:shell betterbird -compose "attachment=%s"

This works perfectly ... but if multiple file selections are made the email app chokes, reporting that the string provided by %s is not acceptable.

This %s parameter seen above is a text string provided by ranger that includes however many currently selected files there are within the file manager. But the email app cannot interpret the list produced. Apparently, it needs to be , (comma) separated with no intervening spaces as discussed below.

From Mozilla's CLI documentation for thunderbird (of which betterbird is a cloned fork with same specs): https://kb.mozillazine.org/Command_line_arguments_-_Thunderbird

1781129539601.png


So... what I have been unable to figure out is how to parse the %s string to eliminate any spaces and place , separators between the names of each selected file.

Familiarity with ranger and its "macro strings" might be helpful background to solve this.

FWIW, I've got similar functionality working perfectly in nnn (another TUI interface file manager I've been using for 7 years or so). But the nnn bash script solution operates differently enough that it isn't helping me solve this one.

Since ranger is written in python, another possibility might be to craft a plugin python script, but I haven't wandered into that forest yet. ;-)

I've tried a number of approaches, so far without success. To anyone who sees what I'm trying to accomplish and has some ideas on how I can proceed, I'd sure appreciate hearing your thoughts!
 


Follow Linux.org

Members online

No members online now.

Latest posts

Top