Skip to content

how do i open file links with the ranger file manager?

when trying to open the containing folder of a file i just downloaded in firefox i get asked what program i would like to open this file link with. i selected /bin/ranger and nothing happens. how do i get the equivialent of typing "ranger (well most of the time it's ~/Downloads)" in a terminal?

13 points10 comments
Open on Reddit
About this post
Posted
Archived
Score
13 · 100% up
Kind
Text
ID
93fm8a

Author

4
posts
21
comments
1
media
View profile

11 comments

If I understand your question, it's because you don't call ranger in a terminal, try something like

yourterm -e ranger

Like you would do in a launcher.

8 points

my arch installation does not know "yourterm" nor can pacman or yaourt find it.

-17 points

No I meant yourterm need to be replaced by your actual terminal emulator, sry. So if you're using urxvt, you need to write

urxvt -e ranger

Same with xterm, termite etc

Edit : Typo

15 points
unknown author1 hidden

You should probably use something other than yaourt.

10 points

Put that in a script.

#!/bin/sh
ranger "${1#/*:-~/Downloads}"

Probably. Certainly some string substitution to check as I am currently not on my computer to verify.

2 points

what's the "${1#/*:-~/Downloads}" do?

1 points

I can try breaking it down:

${1}

same as $1 but enables you to put special bash syntax

${1#pattern}

the # after a variable name is "Parameter expansion: remove shortest matching prefix pattern" so

${1#/*}

just means "remove first letter in the variable if it is a forward slash". This to me doesn't make much sense because it would just remove the initial (root) slash, perhaps the author meant ${1%pattern} which is "remove shortest suffix pattern" (which is after), the "/*" expands to a forward slash and ANY string following it, so in the case of suffix it would remove everything after, in the case of shortest prefix it would only remove the slash

${1:-word}

means "Parameter expansion: Use default value", which just means that if the $1 variable is unset it will default to the word following it

edit: just so you know, this has nothing to do with what you're asking for, the answer is that you need to open a terminal to use terminal programs.

3 points
unknown author

Deleted before we saved it.

1 points

Remove file name (after last / in path). If no argument given then return the downloads folder.

I guess, you'll have to try because I'm not at my computer

1 points

Keyboard shortcuts

Move and act

jork
Next / previous post or comment
Enteroro
Open the post
f
Open the media viewer
s
Save
h
Hide (the toast has Undo)
Tab
Right after an action: the toast's Undo
x
Collapse the comment
v
Next layout: cards, compact, grid

Go to

/
Search
gthenh
Home
gthena
All
gthens
Subreddits
gthenl
Library
?
This list
Esc
Close a menu or this list

In the viewer

←or→
Previous / next file
↑or↓
Previous / next post
korj
Previous / next post
Space
Play / pause
m
Mute
z
Zoom
s
Save
o
Open the post (on its own page: back to it)
Esc
Close

Keys do nothing while you type in a box.