Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

My school has our Linux accounts using csh/tcsh by default. I, however, have a lot setup on my home bashrc and I'd like to use that at school. BUT there's also some important stuff that happens in our cshrc so I'd sort of like to not change my shell on each login. Is there a way for me to call or execute my bashrc within my cshrc and get the same effects or should I find out how to translate my bashrc into cshrc? I don't know crazy of an idea this is - I'm only really used to bashrc personally.

Thanks for any help!

Edit: I've decided to translate my cshrc into a bashrc so I can use bash... Ick Csh - anyone have input on translating this?

My cshrc I'm looking to work on probably later today:

set defaultsdir=~defaults
# source ${defaultsdir}/linuxpaths
source ${HOME}/linuxpaths
# # add your custom shell commands here
# # see 'man tcsh' for more info
if ( $?prompt ) then
  set autoexpand
  set autolist
  set cdpath = ( ~ )
  set pushdtohome

  set savehist=10000
  set histfile=~/.history

# Load aliases from ~/.alias
  if ( -e ~/.alias )    source ~/.alias

share|improve this question

3 Answers 3

up vote 2 down vote accepted

How about appending exec bash at the end of your .cshrc ?

Beware, though, that this is not entirely risk-free, so you might want to do it in one window/session while testing the results in another, so you have a chance of reverting it. (Or have a site admin nearby).

share|improve this answer
You'll inherit the environment that way, but you'll lose everything shell-specific: aliases, prompt changes, etc. –  Warren Young Mar 24 '11 at 15:53
Not at the end of .cshrc (why would you want to start csh at all?), but at the end of .login. –  Gilles Mar 24 '11 at 20:14
This works. I will warn any who find this though, Be sure to disable exec bash when you're loggin out because it will prevent you from logging in at all - good thing I have some root access to fix these issues :) –  jphenow Apr 7 '11 at 20:38

Most of that .cshrc is including external files (the source command) that you'll have to translate as well. The if ( $?prompt ) section is executed only in interactive shells; you don't have to worry about that in bash. Some of the set commands are setting shell options that don't have exact equivalents; you may want to tune bash completion settings. The few lines that matter are:

set defaultsdir=~defaults                defaultsdir=~defaults
source ${HOME}/linuxpaths                . ~/linuxpaths.sh
set savehist=10000                       HISTSIZE=10000; HISTFILESIZE=$HISTSIZE
if ( -e ~/.alias ) source ~/.alias       . ~/.alias.sh

There's no reason why you would change your ~/.cshrc, but you may want to change your ~/.login so that text mode logins drop you into bash, or even zsh if it's available. Use this at the end of ~/.login:

if ($?prompt != 0) then
  which bash >/dev/null >&/dev/null
  if ($status == 0) then
    setenv SHELL bash
    exec bash --login
share|improve this answer
Hmm yea the main thing i was worried about was the source command, I have most of my prompt stuff set up on my repo of my profile defaults that I pass around my computers. I wonder if there's a script I could write that would quickly parse the sourced cshrc stuff into bash-able stuff so that I don't have to make for editing that file directly. –  jphenow Mar 24 '11 at 21:20
@jphenow: I doubt that a prompt escapes converter exists. It would be technically possible, but a lot of work, and very few users need that. –  Gilles Mar 24 '11 at 21:26
@Gilles: I've never seen that trick with which bash. Very, very careful. I like it. Bug in your login script are hell to fix. Thanks. Should we also include the option --login when calling exec bash? –  kevinarpe Nov 25 at 1:16
@kevinarpe Yes, --login is a good idea, to make bash read ~/.bash_profile or ~/.profile. –  Gilles Nov 25 at 10:06

The .cshrc and .bashrc files are written in the language of the shell itself, and the two languages are not compatible. Further, the things you typically put into these files are commands to affect the startup behavior of the shell, so running one shell from the other will only help to a limited degree.

You're going to have to translate one of the files to the other syntax if you want features from both the site .cshrc and your home .bashrc.

If you'd rather convert the site .cshrc to work under Bash than the reverse, you can switch your shell permanently on that machine with this command:

% chsh -s /bin/bash

The other option is to translate your home .bashrc to C shell syntax and add it to the .cshrc file. I wouldn't recommend this since Csh Programming [is] Considered Harmful. :)

share|improve this answer
That's kind of what I expected I suppose, I just figured I'd ask and cross my fingers for a possibly quicker way of doing this. Thanks –  jphenow Mar 24 '11 at 14:39
How different are the two for translating? –  jphenow Mar 24 '11 at 14:45
They're quite different. The simplest forms of aliases and I/O redirection are the same, while the more complex forms differ. Conditional and loop statements are quite different. Historically Bourne shells had functions where Csh derivatives had aliases, but now that modern Bourne-alikes have aliases, too, the lack in Csh derivatives can be annoying. The Bourne/Csh thing isn't like most things in Unix-land, where there was a split that was later healed; they are entirely separate developments that have occasionally borrowed from each other, so that they're largely incompatible even today. –  Warren Young Mar 24 '11 at 15:10
Bummer - Do you have a preference? I'm actually an assistant Linux admin at my school so I might just crack open my cshrc and translate THAT to bash and talk my boss into switching my default shell –  jphenow Mar 24 '11 at 19:08
Well I think they have it locked so my boss would have to change shells, but the real issue is that they have lots of aliases that are linked over nfs in some magical land ;) so I'll see what I can do –  jphenow Mar 24 '11 at 19:09

Your Answer


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.