How can I open a terminal in the desktop directory?

I am using Ubuntu 16.04 and Nautilus 3.14.3 (default version).

There is an open terminal context menu when right- clicking on the desktop. It opens the terminal with ~ as working directory, but I'd like it to open in ~/Desktop.

I think there was a dconf option to change this behavior, but I cannot find anything related under /org/gnome/nautilus.


Simply add the following to ~/.bashrc

if [[ $PWD == $(realpath ~) ]]; then
    cd ~/Desktop/
fi

My solution changes the directory to the desktop even when you press ctrl + alt + t
(default keyboard shortcut to open terminal)

My solution check the working directory and if it is the same as ~, then cd to Desktop

Note: Macerarius' solution always opens in a certain path
(even when you click "Open in Terminal" inside a folder in Nautilus)


Alternatively

Not literally what you asked for, but an alternative solution is to add the command:

/bin/bash -c "cd ~/Desktop && gnome-terminal" 

to a shortcut of your choice. On pressing the shortcut, a terminal window will open with the Desktop as working directory.

Choose: System Settings > "Keyboard" > "Shortcuts" > "Custom Shortcuts". Click the "+" and add the command:

/bin/bash -c "cd ~/Desktop && gnome-terminal"

...to a shortcut of your choice.

The (subjective) advantage is that you don't need to touch ~/.bashrc and that the default directory will be unchanged.

Note

The exact directory (-name) per language may vary. In Dutch: ~/Bureaublad


Two options:

  1. Edit the file ~/.bashrc and add this line at the end of the file:

    cd /path/to/folder
    

Save the change and logout/login. Terminal should now open the specified directory by default.

  1. Edit the file ~/.bashrc and add an alias to quickly change the directory in terminal:

    alias cdd="cd /path/to/folder"
    

Save the change and logout/login. Open terminal, cdd takes you quickly to the specified directory.