3

As far as I know, when you hit Ctrl+Alt+T, the Linux terminal pops up. However, it opens in the default home directory. I want to set up this shortcut to open in the directory I am currently in at my file manager. Is there any way to do that? I know that if I right-click anywhere on the directory it will give me the option to do that. But I want to do stuff using my keyboard.

After doing a web search, I found this post on How to Open the Terminal to a Specific Directory in Linux. But here, the shortcut is mapped to open in another specific directory. So, in turn, it will require me to change the .bashrc file everytime I want to open terminal in a specific directory.

My Desktop environment is KDE and I use Dolphin file manager. My terminal emulator is Konsole.

Is there any way to achieve what I want? Let me know. Thanks in advance.

4
  • 1
    As far as I know, when you hit Ctrl+Alt+T, the Linux terminal pops up. As far as i know it's not. Not on my computer. It maybe true in your window manager, which you didn't state, but it's not in general.
    – tansy
    Commented May 21, 2022 at 14:17
  • Please edit and tell us (1) your desktop environment, (2) the terminal emulator you want to open, (3) the file manager you refer to, (4) the shell you want to run in the terminal. Commented May 22, 2022 at 13:34
  • @KamilMaciorowski, added. Please have a look.
    – belmont
    Commented May 22, 2022 at 16:38
  • 1
    My Dolphin reacts to F4 and Shift+F4 out of the box. Commented May 22, 2022 at 17:23

6 Answers 6

0

If you're using Caja, have a keyboard with a Menu key, and have the Caja "Open terminal" extension installed and enabled, you can do what you want by hitting the Menu key and then hitting the t key.

If you're using an antique, laptop, or other keyboard lacking a Menu key, you can use the key combination Shift+F10 in place of the Menu key.

The "Open terminal" extension puts an "Open in Terminal" option in Caja's context menu (i.e. "right-click" menu), which the above key sequence accesses. After enabling the extension, it may be necessary to restart Caja for the option to show up.

0

I found a solution to my problem, posting it here! My file manager is Caja, and I am running Ubuntu-Mate.

In this website I found them asking me to make a file named 'open-terminal-here' in the folder '.config/caja/scripts/'. But I saw that this folder is already there in my computer and the same text they asked me to write is written there too.

#!/bin/sh
#
# This script opens a gnome-terminal in the current directory. 
#
# Distributed under the terms of GNU GPL version 2 or later
#
# Original author: Keith Conger <[email protected]>
#
# Sourced from
# https://forums.linuxmint.com/viewtopic.php?p=773382&sid=9939ce160bd97313f849367231eb721a#p773382
# http://g-scripts.sourceforge.net/nautilus-scripts/Execute/Open%20terminal/terminal-here
#
# Put this file in your ~/.config/caja/scripts/ directory.
# You need to have caja-actions installed to use scripts.

cd $CAJA_SCRIPT_CURRENT_URI
exec gnome-terminal

Then as suggested in the next step I went to folder '.config/caja/' and opened the file named 'accels' using vim(or any other editor) in this file I could see the line about making a shortcut to open terminal in current directory and I was surprized. Here in this file all lines starts with a semicolon(;), and I learnt that that means it is a commented line.

So I found this line

; (gtk_accel_path "<Actions>/ScriptsGroup/script_file:\\s\\s\\shome\\sUSERNAME\\s.config\\scaja\\sscripts\\sopen-terminal-here" " ")

*username will be your username

and removed the ':' and space at the end of the line

Now, inside the bracket in the second quote, I put the shortcut I needed. I used "<Shift>F4" (this is because I am used with it from Opensuse)

now, the line looks like this:

(gtk_accel_path "<Actions>/ScriptsGroup/script_file:\\s\\s\\shome\\sUSERNAME\\s.config\\scaja\\sscripts\\sopen-terminal-here" "<Shift>F4")

While saving this file, I had no problem. But I kept caja all processes killed while doing this using the commands

pkill -KILL caja
killall caja

I used both since I was not sure which will work better.

However, from the previous post I mentioned it seems like some people will still have problems editing the file, it gets rewritten automatically. In that case, try to follow the steps explained here in this page. At some point, I think I have also used it, in the beginning, I was able to save changes properly.

Now, technically the shortcut is written and it should work, but it was not :(

I realized that the file we made in the scripts folder 'open-terminal-here' is supposed to be an executable initially. However, I forced to make it an executable again by running the command

chmod +x .config/caja/scripts/open-terminal-here

Now, just for curiosity I tried to run this executable from my home folder from the terminal. So, I have the executable 'open-terminal-here' in the folder '.config/caja/scripts/'. now I just ran

.config/caja/scripts/open-terminal-here

It tried to run it, but showed an error which became the final solution to my problem. It was telling me can't find 'gnome-terminal'!

Then I checked top to see what program is running while my terminal is open and it says it was mate-terminal. So, I went straight back to the file '.config/caja/scripts/open-terminal-here' and edited the last line to

exec mate-terminal

NOTE: previously it was gnome-terminal by default

and now I tried my shortcut in any folder, and it works well!!

0

In Ubuntu (or, more precisely, when running Gnome), you can use the --working-directory argument:

gnome-terminal --working-directory=$HOME/tmp

Well... that will work from the commandline. So if you want to write a script (and run it from the commandline) to open a new terminal (with the desired directory), there you go.

If you want to make this a double-clickable shortcut... well, this option is 50% of your answer. Now you need to make this [hypothetical] script into a double-clickable shortcut.

Oh, and figure out the equivalent for this under KDE/Konsole. So maybe this is just a 20% answer! (But... useful if someone landed on this page with the same question for Ubuntu/Gnome... like I did!)

1
  • For me (on Xubuntu) xfce4-termiinal --working-directory=<path> did the trick. On Xubuntu it should be possible to use xfce4-keyboard-settings to make a shortcut for that. Commented Jan 16 at 21:54
0

If you are using debian xfce4, Then here's how you do it.

  • Launch Thunar.
  • Go to edit > Configure Custom actions.
  • There you can see the 'open terminal here'. Double click it, or tap the settings.
  • Then you can see the keyboard shortcut there, which you can use to set your preferred shourtcut for open terminal here.

I hope this works on other distros for xfce too.

0

With Dolphin it's very easy, by default you can use the ALT+SHIFT+F4 or SHIFT+F4 shortcuts for it (the latter supposedly shouldn't open the terminal in the current directory, but it does). You can edit the shortcuts in Dolphin's Configure Keyboard Shortcuts... menu (ALT+CTRL+,). It uses the default terminal emulator (you can change that in KDE's System Settings), which should be Konsole on a KDE system.

-2

I use mate desktop in openSUSE leap 15.3. File manager is caja. If you set up the "open terminal" option in the file manager, you can right click on any directory and select "terminal" and a terminal window opens in that directory.

I also use kde and gnome occasionally but I have not tested those file managers to see if the "open terminal" option is available. I would assume all desktops have it available.

tom kosvic

1
  • I have also mentioned that in my post. There is an option of opening a terminal after right clicking. But I am looking for a shortcut that will do the same, especially from key press.
    – belmont
    Commented May 22, 2022 at 3:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .