Create Default Path When Terminal Is opened
My terminal goes to /home/$USER when I click on terminal.
However, I am doing BASH scripting and I want the terminal to automatically go to /home/$USER/bash_folder whenever I double click on the terminal. So how is this done? |
Hi hitmen,
you can simply add a line to your .bashrc Code:
cd bash_folder Markus |
This is seriosly a noob question but there are so many bashrc files, so which one am I supposed to edit?
c@c-laptop:~/Desktop$ locate .bashrc /etc/bash.bashrc /etc/skel/.bashrc /home/c/.bashrc /home/c/.bashrc.swo /home/c/.bashrc.swp /root/.bashrc /usr/share/base-files/dot.bashrc /usr/share/doc/adduser/examples/adduser.local.conf.examples/bash.bashrc /usr/share/doc/adduser/examples/adduser.local.conf.examples/skel/dot.bashrc |
Well, this is not newbie question because it depends.
here the appropriate text from the bash-manpage Quote:
When you open a terminal in X, bash isn't invoked as a login-shell, therefore a .bashrc file should be sourced. You'll have to try it out. Note that it is possible (but I don't know) that you can change the path in the properties of the terminal-button in the menu (or wherever you click). In KDE this is possible, but I suppose you're using Gnome. Markus |
Normally that'd be the one in your home dir...
|
Quote:
Quote:
The "*.swp" and "*.swo" files are files used by the Vim editor. If there's a swap file called ".example.swp", it means that either there is an instance of Vim running that has the file "example" opened in it, or that an instance of Vim that was editing "example" wasn't closed properly. |
To add this to your bashrc in the terminal enter the following command;
echo "cd /where/ever/you/want/to/go" >> ~/.bashrc Remember to make a copy of the .bashrc file and to test it after before logging out (you can test by reading the .bashrc back into the current shell by entering ". .bashrc" this time without the quotes) Good luck. |
Got A few questions.
Ok here is the relevant output in my home folder:
c@c-laptop:~$ ls -la total 60220 drwxr-xr-x 2 c c 4096 2011-08-22 21:05 bash_folder -rw------- 1 c c 7530 2011-08-22 21:15 .bash_history -rw-r--r-- 1 c c 220 2011-01-08 00:43 .bash_logout -rw-r--r-- 1 c c 115 2011-08-22 21:04 .bash_profile -rw-r--r-- 1 c c 3007 2011-07-12 21:56 .bashrc -rw-r--r-- 1 c c 12288 2011-07-12 21:18 .bashrc.swo -rw-r--r-- 1 c c 12288 2011-07-12 21:15 .bashrc.swp I have already edited .bash_profile but it doesnt work c@c-laptop:~$ cat ./.bash_profile alias ll="ls -l" alias today='date +"%A, %B %-d, %Y"' # open bash_folder automatically in terminal cd bash_folder HOME/$USER/bash_folder doesnt open when I double click on the terminal. In addition, the alias 'll' and 'today' doesnt work even though the file is edited. Can anyone explain why? |
Quote:
bash_profile is executed when you log in, and its purpose is to set up the environment for all the programs and scripts you will be running. bashrc is a script that's run only when you open an interactive terminal, to set up things like your prompt, convenience aliases, etc. that you only want in interactive terminals. You wouldn't want them in scripts since they can change the way the script behaves. Quote:
Code:
cd HOME/$USER/bash_folder |
Can you elaborate more on this? :
bash_profile is executed when you log in, and its purpose is to set up the environment for all the programs and scripts you will be running. |
Try re-reading post #4 and having a look at man bash as all the information you are requesting is there.
|
All times are GMT -5. The time now is 09:13 PM. |