Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
OK, I'm so lost it's difficult to even pose my question. My default shell is bash; and I'd like [actually, required to] have the ability to type csh and enter the TC shell...but it's not working at all. All the changes I made to the ~/.bashrc file work great, but I can't seem to access tcsh to see if the commands in my ~/.tcshrc file work.
When I type "csh", my old PS1 [prompt] displays and I have to type "exit" to get back to the one in the bashrc file and then type "bye" to log out off the system.
I've spent the last 3 days researching this, but every article/blog/site discusses permanently changing my log in...NOT going to happen. As you see, I need all the help anyone can give.
Sincerely it's not clear what the problem is. The csh executable is a link to /bin/tcsh on recent systems. If the csh command runs without problems and it actually starts a tcsh session, the file ~/.tcshrc should be sourced accordingly. You may try to put an echo statement inside it to verify.
Look at the /etc/shells file. Is sch or tsch listed?
If you want to change shells, you can use the chsh command to change your login shell.
You should be able to enter a shell in bash. At that point you are using the other shell in a subshell.
Maybe it isn't installed.
Thanks for this info...I just checked and both "/bin/csh" and "/bin/tcsh" files are there...so it seems I'm good there. I'm just not sure how to get my newly created ~/.tcshrc file to work...meaning which one should I stick in the test like the following code at the beginning of my .bashrc file:
# .bashrc
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
I think that's the problem I have seeing that I have accessed the TC shell; I don't have a test, so my .tcshrc file isn't getting accessed. Does this explain a little more? And if so, can you help?
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
I think that's the problem I have seeing that I have accessed the TC shell; I don't have a test, so my .tcshrc file isn't getting accessed. Does this explain a little more? And if so, can you help?
The test in ~/.bashrc is there because the file /etc/bashrc (the system-wide configuration - for all the users) is not one of the files sourced by the shell when invoked (I mean it is not sourced by default, since it's not hard-coded in the bash functionality). The bash shell uses /etc/profile, then looks for configuration files in the user's home directory. This is the reason of the test you mentioned. Anyway I don't see in which way this is related to your issue.
If I understand well, the problem is that the file ~/.tcshrc is not sourced whenever a C-shell session is started, right? What is the actual content of the ~/.tcshrc? What does it make you guess it's not sourced? Have you tried to put an echo statement inside it to verify?
The test in ~/.bashrc is there because the file /etc/bashrc (the system-wide configuration - for all the users) is not one of the files sourced by the shell when invoked (I mean it is not sourced by default, since it's not hard-coded in the bash functionality). The bash shell uses /etc/profile, then looks for configuration files in the user's home directory. This is the reason of the test you mentioned. Anyway I don't see in which way this is related to your issue.
If I understand well, the problem is that the file ~/.tcshrc is not sourced whenever a C-shell session is started, right? What is the actual content of the ~/.tcshrc? What does it make you guess it's not sourced? Have you tried to put an echo statement inside it to verify?
Well, when you code a ~/.XXshrc file, you have to test for the existence of its default profile. Once you know it's there, then you have the shell read your personally designed profile...which would be the ~/.XXshrc.
To answer your question, here's the code for my ~/.tcshrc file:
# .tcshrc
# Source global definitions
if (-f /etc/tcsh) then
. /etc/tcshrc
endif
# User specific aliases and functions
alias rm 'rm -i' #always checks prior to removing a file
alias cp 'cp -i' #always checks prior to copying a file
alias mv 'mv -i' #always checks prior to moving or renaming file
alias lal 'ls -a --color=tty' #required alias
alias bye 'exit' #exiting the TC shell back to bash
set savehist = 150 #saves 150 commands
set
prompt = '[%n@-tcsh%~]%# ' #distinguish prompt form bash
Now it works!!! I was just over-thinking the whole thing. All I had to do was change "bash" to 'tcsh' and revamp the if-statement to 'endif' and now I'm in the tcsh subshell from my bash shell. Thanks to all of you that responded...many were helpful in getting me to think!
Well, when you code a ~/.XXshrc file, you have to test for the existence of its default profile. Once you know it's there, then you have the shell read your personally designed profile...which would be the ~/.XXshrc.
Of course. But the default profile name not necessarily is equal to the personal one (without the leading dot). Anyway, every shell's man page describes the behaviour at invocation and lists the related configuration files. I cannot find any mention of /etc/tcshrc in the man page of tcsh and I've never heard about that, despite I've used it a lot on Unix machines.
Quote:
Originally Posted by New2LQ
# Source global definitions
if (-f /etc/tcsh) then
. /etc/tcshrc
endif
Just a glitch in this code: it should be -f /etc/tcshrc.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.