Skip to content

Is there a way to make "Open Folder"/"Show in Filemanager" to open the filepath in terminal?

I haven't been using any file manager ever since I started using i3wm (thought I've thought about getting one) and the experience has been much better in nearly all cases

My only real issue is when I'm using some GUI program or whatever (e.g. the Brave/Firefox) and none of the open folder/show in filemanager buttons ever work, since I don't have any filemanager.

If I download something with the browser then I can't just click on the button to go to where the file is located.

So I'm just wondering if maybe there's some way to make these buttons just open the terminal and enter cd /file/path

 

And just for the record I don't think I want any actual terminal-based file-manager, I just want to open a fish shell in terminal

9 points15 comments
Open on Reddit
About this post
Posted
Archived
Score
9 · 92% up
Kind
Text
ID
ytnv28

Author

4
posts
40
comments
0
media
View profile

18 comments

I would:

  • Create a script that receives a directory as an argument and starts your terminal in that directory (see your terminal docs)
  • Create a desktop file in $HOME/.local/share/applications with Name=Open terminal in directory, Type=Application, Exec=/path/to/your/script %U and MimeType=inode/directory;. Look at existing desktop files in /usr/share/applications for guidance, but I don't think you need anything other than those 4 properties.
  • Run xdg-mime default <desktop-file-name> inode/directory. Use the filename with .desktop extension but without the path here.
  • Test with xdg-open /path/to/directory

Alternatively you can skip the script part and just put the correct command in your desktop file.

There may be some details I missed here, see man pages for xdg-mime and xdg-open for more info. All of those should be run as your normal user, in a desktop session.

5 points

This seems like what I'm looking for, but I'm just wondering about one thing.

I'm using i3wm (window manager) and afaik don't use any desktop environment, so I don't have a desktop right?

1 points

I did exactly according to instruction (I tried several), but it still doesn't work :(

> Test with xdg-open /path/to/directory

It works great! But it works only by pressing this command, when I click button "Show in folder" it still opens in Thunar.

Do you have any ideas, what do I do incorrect? Maybe the problem in firefox/telegram?

1 points

Thanks, this worked perfectly.

Create a script that receives a directory as an argument and starts your terminal in that directory (see your terminal docs)

Alternatively you can skip the script part and just put the correct command in your desktop file.

For alacritty (the terminal I use) I just had to set the command to Exec=alacritty --working-directory %u

 

Just mentioning this since this was the only non-obvious part (you fully explained everything else in an easy to follow step by step process) and I just couldn't figure out what else to add after --working-directory, turns out I wasn't supposed to add anything else

1 points

Use a file manager with easy access to the terminal. e.g. nnn

4 points

pcmanfm has this feature builtin. You just need to set your terminal of choice in the preferences.

1 points

I added alacritty as the terminal emulator and I can open terminal of current folder with the button in this file manager

But when I select Show In Folder in Firefox it opens the folder in the Filemanager, not in the terminal

1 points

Interesting. My Firefox always opens folder locations in the terminal though I don't ever recall setting it to do so but I also don't use a DE so I think that has something to do with it. It must look to some default gsettings value. I would look into it further but I don't currently have my computer with me to check and I'm on my way to work. I can check when I get home if you would like me to update you with what I find.

2 points

Write a shell script and name it after a file manager's binary. Stuck it in the usual bin folder for executables.

-2 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.