DaemonForums  

Go Back   DaemonForums > Miscellaneous > Guides

Guides All Guides and HOWTO's.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 2nd May 2008
anomie's Avatar
anomie anomie is offline
Local
 
Join Date: Apr 2008
Location: Texas
Posts: 446
Thanked 69 Times in 46 Posts
Default Quick, simple tcsh tips for beginners

New to tcsh? Already familiar with bash? Sure, you could easily read through the manpages for tcsh(1), but here are a few quick and easy tips to help you feel right at home.

-----------------------------------------

Enable Tab command completion
One approach (or simply edit with your favorite editor):
Code:
echo 'set autolist' >> ~/.cshrc
Colorize your ls output
Use this (or simply edit with your favorite editor):
Code:
echo 'setenv CLICOLOR' >> ~/.cshrc
Source a file in to your environment
In Bourne shells (like bash), this is accomplished using:
Code:
. file_here
In csh / tcsh shells, this is accomplished using (logically enough):
Code:
source file_here
You'll need to do that to source in your ~/.cshrc changes, so now is a good time to practice!

Jump around the command line
So, you typed a long command (but haven't hit enter yet), and now you need get back to the very beginning of the command line -- simple: use Ctrl + A.

Now you fixed that typo at the very beginning of the command line, and you want to get back to the end of it to keep typing -- simple: use Ctrl + E.

Write a script that utilizes your cool new tcsh shell
I had to tack this one on, just in case.

Use Bourne shells for scripting. Do not use csh / tcsh for scripting. The reasons are exhaustively enumerated here:

http://www.faqs.org/faqs/unix-faq/shell/csh-whynot/

-----------------------------------------

Hopefully these tips have just made you slightly more productive within tcsh. Have fun with your new shell!
__________________
Kill your t.v.

Last edited by anomie; 2nd May 2008 at 03:48 PM.
Reply With Quote
  #2   (View Single Post)  
Old 2nd May 2008
ephemera's Avatar
ephemera ephemera is offline
Knuth's homeboy
 
Join Date: Apr 2008
Posts: 537
Thanked 49 Times in 43 Posts
Default

tcsh's history-search-forward/backward is a nifty feature and AFAIK bash doesn't have have it.
type the first few chars of any previous command and press up arrow to cycle through the matching commands in history.

tip: you will need to run rehash to use a newly command/utility installed while you are logged in.

some differences:
Code:
Tcsh                                           Bash

cmd >& file                                   cmd >file 2>&1
source .cshrc                                 . bashrc
prompt                                         PS1
Ctrl-d                                            Tab-Tab
.cshrc                                            .bashrc
setenv PATH ${PATH}:/opt             export PATH=${PATH}:/opt

tcsh has a whole bunch of other cool features that makes it a first class interactive shell. read the excellent man page for more.

Last edited by ephemera; 2nd May 2008 at 05:01 PM.
Reply With Quote
  #3   (View Single Post)  
Old 4th May 2008
erno erno is offline
Port Guard
 
Join Date: May 2008
Location: Finland
Posts: 12
Thanked 1 Time in 1 Post
Default

Linux ls colors in tcsh.

Code:
setenv CLICOLOR YES
setenv LSCOLORS ExGxFxdxCxDxDxhbadExEx
To make these settings permanent add those lines to your ~/.cshrc
Reply With Quote
  #4   (View Single Post)  
Old 5th May 2008
mtx's Avatar
mtx mtx is offline
Real Name: Valentin Bud
Fdisk Soldier
 
Join Date: May 2008
Location: RO/TM
Posts: 79
Thanked 5 Times in 3 Posts
Default

grep colorized output.

in tcsh
Code:
setenv GREP_OPTIONS --color=auto
setenv GREP_COLOR 32
to make this settings permanent add them to your ~/.cshrc (quoting erno)
a list of colors can be found here at the bottom of the page.
in bash use export.

here is some output to see how it's working:
Code:
> setenv GREP_OPTIONS --color=auto
> setenv GREP_COLOR 32
> dmesg -a | grep key
keymap
keymap file ".iso" not found
>
all the best,
v
__________________
Stop! think! ... the problem is somewhere between the monitor and chair...
"First they ignore you, then they laugh at you, then they fight you, then you win." Gandhi
links: spreadbsd syk
Reply With Quote
  #5   (View Single Post)  
Old 5th May 2008
jb_daefo jb_daefo is offline
Package Pilot
 
Join Date: May 2008
Posts: 196
Thanked 5 Times in 5 Posts
Default

not so simple but can save time.
...........
find several huge .cshrc; print them, and add any cool
features to your own
..........
especially the save-history-across-reboots so you do not have to
re-read man pages next week, next year etc
Reply With Quote
  #6   (View Single Post)  
Old 5th May 2008
JMJ_coder JMJ_coder is offline
VPN Cryptographer
 
Join Date: May 2008
Posts: 464
Thanked 8 Times in 8 Posts
Default

Hello,

Quote:
Originally Posted by jb_daefo View Post
not so simple but can save time.
...........
find several huge .cshrc; print them, and add any cool
features to your own
..........
especially the save-history-across-reboots so you do not have to
re-read man pages next week, next year etc
Is there an online repository of such .cshrc/.tcshrc files?
__________________
And the WORD was made flesh, and dwelt among us. (John 1:14)
Reply With Quote
  #7   (View Single Post)  
Old 5th May 2008
mtx's Avatar
mtx mtx is offline
Real Name: Valentin Bud
Fdisk Soldier
 
Join Date: May 2008
Location: RO/TM
Posts: 79
Thanked 5 Times in 3 Posts
Default

you might wanna try this dotfiles.com/
Lot's of dotfiles for all sorts of apps. I browsed it once and found very interesting and complex .cshrc files. enjoy it.

all the best,
v
__________________
Stop! think! ... the problem is somewhere between the monitor and chair...
"First they ignore you, then they laugh at you, then they fight you, then you win." Gandhi
links: spreadbsd syk
Reply With Quote
Reply

Tags
completion, csh, tab, tcsh

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
A simple question Mr-Biscuit Off-Topic 1 16th April 2009 04:26 PM
History not saved in tcsh RandomSF FreeBSD General 8 9th December 2008 11:59 PM
Simple Firewall with PF jones FreeBSD General 3 7th November 2008 02:02 AM
TCSH: 'set promptchars' not effecting su like it should JMJ_coder General software and network 4 9th July 2008 09:51 PM
TCSH - getting to start of line maxrussell FreeBSD General 3 4th July 2008 11:55 AM


All times are GMT. The time now is 02:59 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick