Add ‘Open in Terminal’ to Pantheon Context menu in Elementary OS

Last updated: September 28, 2013

Are you using the Elementary OS instead of Ubuntu? Well, here I’ll show you how to add the ‘Open in terminal’ option to the Pantheon file manager right-click menu. So that you can quickly open terminal and automatically navigate to the current directory in Pantheon.

open in terminal for pantheon

To get started, use your favorite editor to create the config file /usr/share/contractor/openinterminal.contract and edit it. I prefer Gedit, so I install it and edit the file via below commands:

sudo apt-get install gedit

sudo gedit /usr/share/contractor/openinterminal.contract

Copy and paste below lines into the file and save it.

[Contractor Entry]
Name=Open in terminal
Icon=terminal
Description=Open in terminal
MimeType=inode;application/x-sh;application/x-executable;
Exec=pantheon-terminal -d %U
Gettext-Domain=pantheon-terminal

Log out and back in and done! Or you need a restart if it doesn’t work properly.

Twitter

I'm a freelance blogger who started using Ubuntu in 2007 and wishes to share my experiences and some useful tips with Ubuntu beginners and lovers. Please comment to let me know if the tutorial is outdated! And, notify me if you find any typo/grammar/language mistakes. English is not my native language. Contact me via ubuntuhandbook1@gmail.com Buy me a coffee: https://ko-fi.com/ubuntuhandbook1 |

11 responses to Add ‘Open in Terminal’ to Pantheon Context menu in Elementary OS

  1. I do that, And always Open terminal in my home directory instead where I am, Then I check out in terminal use the script to open a directory :
    pantheon-terminal -d /dir/to/go
    and nothing , always open a terminal in Home Directory. I will find another solution thanks for the help is something :D

  2. Hey,I try with sudo pantheon-terminal -d /my/dir/to/go and Run perfect !
    But doesn’t work without sudo, I just thought It never work for me, thus I open a directory and click in Open in terminal then works fine :D Really I don’t know what happens but now it work perfectly :D thanks budy!

    • Just gksudo pantheon-files /usr/share

    • The contractor instructions are right but you need to change:
      Exec=pantheon-terminal -d %U
      in
      Exec=pantheon-terminal -w %U

      Doing so it will work without ‘sudo’.

  3. It’s not working for me. I just opens the ~/ dir

  4. Hi everyone,

    I’ve just solved this problem installing xfce4-terminal and modifying some lines:

    [Contractor Entry]
    Name=Open in terminal
    Icon=terminal
    Description=Open in terminal
    MimeType=inode;application/x-sh;application/x-executable;
    Exec=xfce4-terminal --working-directory %U
    Gettext-Domain=xfce4-terminal

    Thanks for share ;)

    • Hi guys,

      I just solved the current folder opening problem

      use -w (working directory) istead if -d

      [Contractor Entry]
      Name=Open in terminal
      Icon=terminal
      Description=Open in terminal
      MimeType=inode;application/x-sh;application/x-executable;
      Exec=pantheon-terminal -w %U
      Gettext-Domain=pantheon-terminal

  5. i tried to make this work with terminator but nothing happend
    this is my contractor
    [Contractor Entry]
    Name=Open in terminal
    Icon=terminator
    Description=Open in terminal
    MimeType=inode;application/x-sh;application/x-executable;
    Exec=terminator -w %U
    Gettext-Domain=terminator

    what am i doing wrong? if someone can help thanks

    • may be that can help other you have to make this change
      Exec=terminator–working-directory=%u

  6. First of all, there is no reason why this should be in `/usr/share/contractor/` and not in `~/.local/share/contractor/`. – Even so, it maybe worked in Freya but it does not in Loki. — And there seems to be a problem with the line ` MimeType=inode;application/x-sh;application/x-executable`, intended for both directories and executables (running a script in terminal, like Dolphin does). – The argument for opening a terminal in a directory path is different than that for running a script in terminal: for terminals like Terminator and Gnome Terminal, not to mention the fact that Pantheon Terminal lacks such arguments. – Considering only Terminator: the line `Exec=terminator –working-directory=%u` works for directories, but its useless in Loki, where you have that by default under ‘Open in’; to have a contractor for running scripts and such in Terminator, use `Exec=terminator -x` (with only `MimeType=application/x-sh;application/x-executable;`).