Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to write a simple bash script, which when run from the command line, will cd into a default directory and then open up the folder in the file-browser:


if [ -z "$1" ]
  # unless $1 is specified, cd into main proj
  cd code/ruby/my-main-proj
  # cd into project specified by $1
  cd code/ruby/$1

# open folder in file manager    
pcmanfm .

This is great, it gives me two things:

  1. a command-prompt whose working directory is set to the project I want
  2. a file-browser for the same project

The trouble is that I would like to run my bash script by clicking on a desktop icon but in it's current form, the terminal does not open up, just the file browser..

So I've made a modification to try and get the terminal to open too:

  # unless $1 is specified, cd into main proj
  x-terminal-emulator -e "cd code/ruby/my-main-proj"
  # code same as before    

But while the terminal does open, it just displays a blank screen, with no prompt or PWD. How can I get a terminal to open up, and have it's working directory change to the one I'm trying to specify in my bash script?

share|improve this question
up vote 4 down vote accepted

I didn't get it to work with x-terminal-emulator, but with the standard gnome terminal.

user@MacBookPro:~$ gnome-terminal --working-directory=~/code/ruby/my-main-proj

Hope this helps.

share|improve this answer
ahh, thanks, the --working-directory flag seems to fix this – marflar Feb 13 '13 at 15:20

Your problem is that you're not executing a shell in your temrinal emulator, you're trying to execute cd, which is a shell command, not an actual shell (not even an actual executable for that matter).

You could make a desktop entry file that starts a shell in a custom working directory, like this:


[Desktop Entry]
Name=My Project

Note the Path=… above.

share|improve this answer
Thanks a lot that helps make sense of a few things – marflar Feb 13 '13 at 15:21

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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