1

I am on a SUSE Linux Enterprise Desktop 11 (SP4) machine, with Gnome 2.28.2 running. I set a keyboard shortcut to launch "gnome-terminal" command. And I also added a Launcher shortcut to Panel to do the same.

The launcher shortcut on the panel works correctly. It brings up the terminal and sources my profile and changes directory to my home directory.

But the keyboard shortcut brings up the terminal, does NOT source my profile and changes directory to /

How can I make the keyboard shortcut open the terminal while also sourcing my profile and cd-ing into my home directory?

2

Answer 1 - Modify gnome shortcut to open correct directory

It is possible to modify shortcuts in Gnome using the gconf-editor, which you may or may not need to install by running the following command.

yum install gconf-editor

After starting the program you will go to apps > metacity > keybinding_commands as seen in the image below.

gconf-editor fron nixtutor.com

Next you will select an unused or modify an existing shortcuts "value' to the following:

gnome-terminal --working-directory=/path/to/dir

This will not source your .profile, but it will ensure the shortcut opens in the appropriate directory.

Answer 2 - Change default working directory in Gnome

It is possible to modify default working directory in Gnome using the gconftool-2, which you may or may not need to install by running the following command.

yum install gconftool-2

Then run the following as your user to fix the current session

gconftool-2 --set --type=bool /apps/nautilus-open-terminal/desktop_opens_home_dir true

Then as root, run the following command to make this take effect on login

gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.defaults --set --type=bool /apps/nautilus-open-terminal/desktop_opens_home_dir true

Sources

ANSWER-1 nixtutor.com - Adding Custom Shortcuts to Gnome

ANSWER-2 redhat.com - How do I change the "default working" directory of terminal applications

  • I do want it to source the profile. How can I make the keyboard shortcut behave exactly like how the launcher shortcut works? In the settings for launcher shortcut, the command is only "gnome-terminal", just like the keyboard shortcut. No idea why they work differently. – shikhanshu Apr 14 '17 at 23:45
  • I've elaborated my solution to show you how to modify the native keyboard shortcuts. Will this fix your issue? – Jay Holister Apr 15 '17 at 2:08
  • I also included an additional solution, which may be closer to what you're looking for. – Jay Holister Apr 15 '17 at 2:27
  • Thank you @Jay! I was mistaken, my profile does get sourced regardless of working directory. I just set the --working-directory option as per your suggestion and I am good to go! – shikhanshu Apr 15 '17 at 17:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.