I have a specific workspace that I must navigate to that is annoyingly long. like/really/damn/annoyingly/long/and/it/takes/a/while/to/type. I wanted to write a shell script that would just cd me into it, but of course, that won't work. Is there another way to make it so I can just cd into this directory without the hassle of typing it out?

Don't tell me copy and paste.

Thank you!

marked as duplicate by wjandrea, karel, pomsky, muru bash Jul 25 at 15:29

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Are you trying to re-create the functionality of Windows 10, "command prompt here", from a pop-up menu? This is an already build-in feature in Gnome when you browse using Files. Highlight a folder, right click and choose Open in Terminal. – Bernard Wei Jul 24 at 18:31
  • Read man bash, see CDPATH – waltinator Jul 24 at 21:54

You can't use a shell script to change directory, because the script runs in a different process and that child process cannot alter the environment of the current shell process.

You need to write a function or alias that will operate in your current interactive shell. One of these will work:

alias go='cd /really/damn/annoyingly/long/and/it/takes/a/while/to/type'
# or
go() { cd /really/damn/annoyingly/long/and/it/takes/a/while/to/type; }

Pick one, save it in your ~/.bashrc, type source ~/.bashrc and you should be ready to go.


You could use a symlink, which is a special type of file that links to another file:

ln -s "/really/damn/annoyingly/long/and/it/takes/a/while/to/type" link_name

This creates a symlink called link_name which links to /really/damn/annoyingly/long/and/it/takes/a/while/to/type.

Then, in a shell:

~$ cd link_name

Shell variable

Or create a variable:


Put that in your ~/.bashrc, run source ~/.bashrc, then you can simply cd "$variable_name".

Actually you CAN cd in a script -- just put your cd command in a script. You have to execute it like this though: . ./script1. The . in front causes the script to run in your current shell instead of launching a new one.

~$ cat script1
cd ./ISO
~$ . ./script1
  • Honestly I like Glenn's answer better though, it is a better way to achieve the result. – Patrick Taylor Jul 24 at 18:45
  • source is the same as the dot command ., and easier to read. – wjandrea Jul 24 at 20:46

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