How to add lines to the file .cshrc
I need to add a line (to create an alias) to the file .cshrc: how can I do this?
As far as I understood I should do that from the C shell, but I am working with the bash shell. Because I always use the bash shell, does it make sense to modify the .bashrc file as well? I am sorry if the question seems a bit confusing, but I am not an expert with Linux and Ubuntu. Thanks a lot!! |
Hi Ashotti and welcome to LinuxQuestions! :)
Indeed, the file .cshrc is used by the C-shells upon login. If your default shell is /bin/bash you must add the alias to .bashrc. Some Linux distributions use a file named .alias, that in turn is sourced by .bashrc. For example, in my OpenSuSE box I have: Code:
test -s ~/.alias && . ~/.alias || true The difference between sourcing and executing a script is that in the former the statements inside the script run in the current shell, so that all the variable, function and alias definitions are retained. In the latter the script starts (forks) its own process (subshell), all the definitions are local to the new process and they are lost upon exiting. This is the reason why all the configuration files like .cshrc or .bashrc are sourced and not executed. Hope this helps. |
Thank you for your answer!
I don't have a .alias file, or at least it doesn't appear when I type "ls -a" in the shell, so that I suppose that I have to add a line directly to the .baschrc file, but (sorry for the stupid question) how can I do that? If I understood correctly, when I modify the .baschrc file, the change will apply every time that I start a shell, is that right? Thansk again for your help! |
Quote:
Quote:
Code:
gedit $HOME/.bashrc Quote:
Take in mind that every change you make in a shell (defining an alias, a shell function or changing the value of an environment variable) is local to the current shell and it's lost when you close the shell session. In other words, settings made in a terminal don't reflect in other terminals. This is the reason why you need a file whose content is executed (actually sourced) every time you start a new shell session (that is every time you open a new terminal). Hope it's a bit more clear now! :) |
Again, thanks a lot!
Quote:
Quote:
Quote:
|
Well done! :) You're welcome!
|
All times are GMT -5. The time now is 01:45 AM. |