0

How can I execute a pre-command in a new tcsh interactive shell?

Ex: For mimicking bash -O globstar in tcsh we can do set globstar.

However, I need to start a new tcsh shell with 'set globstar' without depending on / changing the user's rcfile.

tcsh -c 'set globstar won't work as it won't leave the interactive shell. Exits immediately after executing the command.

Krishna
  • 124

1 Answers1

0

Bash understands --rcfile, which allows you to source alternative .bashrc, but I haven't found similar option for tcsh.

Without it, I managed to achieve what you want by modifying this answer of mine. It uses expect. The script is:

#!/usr/bin/expect 

log_user 0
spawn /bin/tcsh
send "set globstar\n"
interact

Adjust paths if needed. Save the code in a file, make the file executable, then run it.