How to open terminal in folder linux

Is it possible to open a terminal in the current directory?

I am new to Ubuntu, and was wondering whether it is posible to open a terminal with a path matching your current location in the file manager? In Windows it was very easy, but how do you do it in Linux?

@kos found the related answer to the question, and linked it in my answer. I’d say this question is a duplicate

13 Answers 13

Run sudo apt-get install nautilus-open-terminal in a terminal, followed by nautilus -q to quit all open nautilus windows. When nautilus is next opened, a line saying open in terminal should appear in the right click menu.

Please note that the package nautilus-open-terminal is in the universe repositories.

This should be the correct answer: simple, direct, solves the problem and the program/plugin is already available in Ubuntu repos.

I recall installing a gnome scripts package some time ago that added this functionality along with others like some «convert to . » and etc. It was quite the learning experience and it led me to write a script to convert a directory of videos to .webm format (to conserve space). I beleive I found the package of which I speak at g-scripts.sourceforge.net

Since Ubuntu 15, including now 22.04, just right-click inside Folder and contextual Menu will show Open in Terminal

With Dolphin , KDE’s file manager, you have two options:

enter image description here

  1. Open a terminal as a panel in the same window. Use the keyboard shortcut F4 or the menu: ControlPanelsTerminal. The working directory is synchronized between the two panels; changing directories in either of the two panels will also change it in the other. Sweet! In this screenshot you even see the sweetness of having this as a toolbar item in the top.
  2. Open a terminal in a new window. Use Shift + F4 to do that. It will not have the feature to have the working directory synchronized, but it just opens a new window with the current working directory set.

The same applies to other apps in KDE Plasma, like the Kate text editor (enable it in Kate’s settings, it’s a built-in plug-in). Opening a terminal with a single keyboard shortcut from your text editor with the context of the file, is simply brilliant.

@EliahKagan I was referring to the feature of the first option in which the terminal follows path changes in the panel above and vice versa. The ‘cd’ commands seen in my screen shot aren’t typed by me, but performed by browsing in the file manager.

Update , April 11

Create a simple script opendirectory.sh with the following contents

#!/bin/sh # set -x OPENDIR=$(zenity --entry --text="Type or paste address");gnome-terminal --working-directory="$OPENDIR" & 

Bind that script to a shortcut , for instance Ctrl + Alt + i , or whatever you like.

Читайте также:  Linux show memory info

Now, when you are in some directory in nautilus, press Ctrl + L to open address bar. Copy the address of your current directory with Ctrl + X .

Lauch the shortcut you just created and paste the address with Ctrl + V in to the dialog. Terminal should pop-up with the directory that you told the dialog to open.

IMHO, this is as «native» as it gets and doesn’t require additional installation. Sure, it is not a right click type of thing, but it works and can be implemented quickly. Will work for other file managers that don’t support this option,too

Original Post

Technically nautilus, the default file manager, doesnt have open terminal here option, but there is a plug in for that in the repositories. You might be more interested in other file managers that support this option out of the box

As a workaround you could try the following:

Ctrl + L willopen the text filed for entering address, with the current working directory highlighted. Cut that out with Ctrl X , and paste into terminal with Ctrl Shift V or right click. Alternative , use run dialog to launch gnome-terminal —working-directory= and paste whatever you copied after = sign.

Drag and drop: Drag the button/tab (not sure how it’s called) into terminal, add cd in front

enter image description here

Another way: Open the file manager and terminal. Drag and drop the folder you want to access into terminal, and add cd to the path.

For instance, if I want to access bin directory in my /home/serg/ directory, i would drag that directory to terminal and it would appear as ‘/home/serg/bin’ . Next, add cd , so that the whole line is cd ‘/home/serg/bin’ .

Источник

Set up a shortcut to open terminal in a specific directory

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.

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.

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.

Читайте также:  Linux on flash drive ubuntu

3 Answers 3

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.

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

; (gtk_accel_path "/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 «F4» (this is because I am used with it from Opensuse)

now, the line looks like this:

(gtk_accel_path "/ScriptsGroup/script_file:\\s\\s\\shome\\sUSERNAME\\s.config\\scaja\\sscripts\\sopen-terminal-here" "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’ !

Читайте также:  Linux update fonts cache

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

NOTE: previously it was gnome-terminal by default

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

Источник

Shortcut to open the terminal specific directory

I’d like to know the shortcut that lets you open a terminal window in a specific directory just like when you press the left button on it and you click on ‘Open in terminal’ in the pop-up menu. Thanks in advance !!

Are you referring to the Nautilus file manager? That hasn’t worked for several releases now. In Nemo, it’s F4.

2 Answers 2

The shortest way in a default installation is Ctrl + F10 E . There is no single shortcut key to directly open a terminal.

Caveat In Ubuntu 22.04 (Files 42.2) this is broken. Ctrl + F10 E now opens the folder menu of the bar (⁞) instead of the right-click context menu. That behavior also breaks the use of the Python extension described below to a large extent. Still, assigning a nautilus specific shortcut using the extension works.

A good way to implement a direct shortcut key is to replace the default extension by a nautilus python extension, nautilus-open-any-terminal. Next to allowing for a single shortcut key, it allows you to substitute a terminal of your choice, if you wish.

  1. Quit nautilus fully nautilus -q
  2. Make sure python3-nautilus is installed: sudo apt install python3-nautilus
  3. Install the extension, either using pip as indicated on the website, or by grabbing the source code and placing it in a text file ~/.local/share/nautilus-python/extensions/open_any_terminal_extension.py .
  4. Enable the dconf settings glib-compile-schemas ~/.local/share/glib-2.0/schemas/
  5. Define the settings:

gsettings set com.github.stunkymonkey.nautilus-open-any-terminal terminal gnome-terminal

Supply gnome-terminal or any other of the terminals listed in the source code.

gsettings set com.github.stunkymonkey.nautilus-open-any-terminal keybindings ‘t’

to set the Nautilus keybinding for opening the terminal.

gsettings set com.github.stunkymonkey.nautilus-open-any-terminal new-tab true

if you want to open the current directory in a new tab in a running instance. Otherwise, it will be a new window.

  • Remove the now superfluous default extension: sudo apt remove nautilus-extension-gnome-terminal .
  • Enable hotkeys in the right-click menu by editing the source code of the extension: where the menu label is defined, add an underscore before the letter you want to activate as a hotkey for the function, as in label=_(u»Op_en <> Here»).format(terminal.title()),

With this example, also Ctrl + F10 E will work to open a terminal here.

Источник

Оцените статью
Adblock
detector