Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Is there any way to save the path of the current directory from the current Gnome Terminal window. I need this to when I open another terminal refuse to type cd repeatedly again?

share|improve this question
add comment

5 Answers 5

up vote 9 down vote accepted

Press Ctrl+Shift+N in gnome-terminal for a new terminal window.

Press Ctrl+Shift+T in gnome-terminal for a new terminal tab.

Or right click in the terminal and chose New Terminal or New Tab

The new terminal window or tab inherits the working directory from its parent terminal.

This works also with the Xfce terminal.

LXTerminal only inherits the working directory from its parent terminal on a new tab.

share|improve this answer
add comment

GNOME wiki suggests sourcing vte.sh from your ~/.bashrc profile.

I.e. add this line to your ~/.barshrc file:

. /etc/profile.d/vte.sh

This way Ctrl+Shift+N in gnome-terminal will inherit current working directory.

share|improve this answer
add comment

You can make an alias for the current working directory in ~/.bash_aliases

echo alias \'alias-name\'=\"cd "$(pwd)"\" >> ~/.bash_aliases

Now you can access that directory by running only the alias name on the terminal.

Example:

avinash@avinash-Lenovo-IdeaPad-Z500:~/Desktop/rah$ echo alias \'go\'=\"cd "$(pwd)"\" >> ~/.bash_aliases

Then i run the below command on a new terminal,

avinash@avinash-Lenovo-IdeaPad-Z500:~$ go
avinash@avinash-Lenovo-IdeaPad-Z500:~/Desktop/rah$ 

To clear all the aliases,

echo "" > ~/.bash_aliases
share|improve this answer
add comment

There are many ways to simplyfy your task ie to save you from typing the CD thing again and again.

1. Make an alias for it to help you go to the directory again and again like

vi  ~/.bashrc 

Add the line mentioned below

alias goto='cd ~/path/to/yourdir'

Then

source  ~/.bashrc 

Now whenever you want to go to the directory just type goto on your terminal.

it.

problem : This will require you to make multiple aliases for different directories.

2 A function to save your life - extended aliases.

Steps :

1. vi ~/.bashrc
2. write this 

    function lifesaver(){
    cd "$1"
    }
3. source ~/.bashrc

4. to move to a directory /home/userMusic, use 

    lifesaver /home/userMusic

3. Installing nautilus-open-terminal .Here's a link to it.

http://askubuntu.com/a/207448/278183

Problem with it is that every time you need to go to the directory manually and then click open terminal.

Choose what suits you the best :-)

share|improve this answer
    
Your 1st solution only works for a specific directory, your second does absolutely nothing. It is the same as using cd directly. How is lifesaver.sh foo/ different from cd foo/? The only difference is that it is longer to type. Oh, and you want cd "$@", not $0, $0 is the name of the script so cd $0 would actually run cd /usr/bin/lifesaver.sh. –  terdon May 10 at 16:57
    
Thanks for pointing my mistakes.I updated them. –  cafebabe1991 May 10 at 17:29
    
Ah, much better, thanks :). I still don't see the point of your 2nd approach though. It is just a more complex way of running the cd command. The OP can just do cd /home/userMusic why would they use your function? –  terdon May 10 at 17:34
    
i know you are right,but if alias is a right way to change directory then a function would make things generic i guess. –  cafebabe1991 May 10 at 17:35
    
Not at all, your function just does cd foo, if anything, it is harder to use than the simple cd and does not offer any extra functionality whatsoever. –  terdon May 10 at 17:36
add comment

If you want to open terminal for a current directory and don't want to use cd in terminal to move to current directory then

Install nautilus-open-terminal available in software centre.

you can right click in the current directory and you will find 'open in terminal' option.

You need to restart nautilus after installing to restart nautilus type in terminal

nautilus -q (it will quit the nautilus)

to start again

nautilus
share|improve this answer
add comment

Your Answer

 
discard

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.