Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'OT - A possible solution for odd Terminal behaviors' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
OT - A possible solution for odd Terminal behaviors
Authored by: webbix on Nov 03, '04 12:57:53PM
Slightly off topic but maybe someone can point me to the right place. I am still using tcsh for my shell as I can not get my alias entries in the correct format. I have made a '.bash_profile' (I think I duplicated my tcsh file) and also '.bashrc' to include additional paths. However, when I try to set my default shell to bash I get errors see below). I have looked for info in my unix books and online and can not find anything that shows the difference even when the topic is discussed specifically.
After editing my original this is what I have. It yields errors on launch asking for the type of terminal

Welcome to Darwin!
You have mail.
tset: can't initialize terminal type !* (error -1)
Terminal type? 
I type in xterm to just see what I can get

-bash: export: `cat -n | tail -1 | awk '{print $1}')': not a valid identifier
-bash: alias: print: not found
-bash: alias: $2: not found
-bash: alias: }: not found
This is what I edited to; would have to get my original from home BU

# added 1223.2002 to allow use of alias
# source /Users/user/.aliases

# added a source to 'rc' for my alias file in home directory
# '.aliases' 09.25.2002
# setenv PATH /usr/local/bin:$PATH

export PATH=$PATH:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/opt/local/bin

# enable access to mysql; 07-07-2003

export PATH=$PATH:/Library/MySQL/bin"

##
# TCSH Expanded C-Shell INITIALIZATION FILE
# Aliases file
#
# Wilfredo Sanchez Jr. | tritan@mit.edu
# June 10, 1994
#
# MIT Project Athena
##
alias . ='pwd'
alias ..= 'cd ..'
alias cd..='cd ..'
alias cdwd='cd `pwd`'
alias cwd ='echo $cwd'
alias files='find \!:1 -type f -print'      # files x => list files in x
alias ff='find . -name \!:1 -print'      # ff x => find file named x
alias line='sed -n '''\!:1 p''' \!:2'    # line 5 file => show line 5 of file
alias l='ls -lg'
alias ll='ls -lag \!* | more'
alias term='set noglob; unsetenv TERMCAP; eval `tset -s -I -Q - \!*`'
alias word='grep \!* /usr/share/dict/web2' # Grep thru dictionary
alias wordcount='(cat \!* | tr -s '''  .,;:?\!()[]"''' '''\012''' |' \
                'cat -n | tail -1 | awk '''{print $1}''')' # Histogram words
##
# My aliases are listed below
#
#
# 
##

# showalias: to remind yourself of an alias (given some part of it)
alias showalias='grep \!$ ~/.aliases'

# addaliasitem: to add more alias entries
alias addaliasitem='pico ~/.aliases'

# mylsof: lsof command to show open ports
alias mylsof='sudo lsof -u user -u root | grep TCP | sort +2'

# from OSXFAQ site to search for strings in text files
alias ftxt='find . -name "*.txt" -exec grep -il \!:1 {} \;'

# easy ssh connect to server afp
alias sshano='ssh user@1.1.1.2'  

# launch darkstat from non-standard location?
alias darkst='sudo /usr/local/sbin/darkstat --detach'
  
# kill darkstat
alias kdark='sudo kill `cat darkstat.pid`'

# launch ntop as daemon on 6160
#alias webntop='ntop -d -w 6160'

# ls with color for /bin/ls2
alias ls2='/bin/ls2 --color -axl'

# today in history script
alias 2day='cat /usr/share/calendar/* | grep `date +"%m/%d"`'

# ssh connection through host to main file server
alias afpssh='sudo ssh -C -L 55548:1.1.1.1:548 user@1.1.1.1'
  
# homeland security threat level
alias hstl='echo -n "Threat Level: ";'" curl -s http://www.dhs.gov/dhspublic/getAdvisoryCondition | tail -n 1 | awk -F\"'"'" '{ print "\$2" }''
 
# TOP without memory reporting to reduce CPU load
alias ttop='top -ocpu -R -F -s 2 -n30'

Any pointers?

[ Reply to This | # ]
OT - A possible solution for odd Terminal behaviors
Authored by: thrig on Nov 03, '04 02:17:10PM

bash and tcsh are very different; to debug, perhaps run 'bash -x' or 'bash --verbose' to see what might be going wrong?



[ Reply to This | # ]
OT - A possible solution for odd Terminal behaviors
Authored by: n8gray on Nov 03, '04 03:25:36PM

alias . ='pwd'
alias ..= 'cd ..'
These are broken. You can't put spaces around the = in alias lines. You have to use:

alias .='pwd'
alias ..='cd ..'
Also, aliases can't take arguments in bash so this won't work:

alias files='find !:1 -type f -print'
Instead use a function:

files () { find $1 -type f -print; }
Be sure to leave a space after the { and put a semicolon after the command. You can also use a multi-line syntax for longer functions:

files () { 
   find $1 -type f -print
   echo "hello world"
}
In this case semicolons aren't necessary since the commands are on individual lines.

Hope this helped.

[ Reply to This | # ]

OT - A possible solution for odd Terminal behaviors
Authored by: webbix on Nov 03, '04 04:31:12PM

Thanks, exactly what I needed.

Hated to lose the functionality I had but did not know enough about it and have wanted to give bash a try since 10.3 came out. I will edit my config and give it a try.



[ Reply to This | # ]
OT - A possible solution for odd Terminal behaviors
Authored by: kholburn on Nov 03, '04 05:17:22PM

If you want to check a bash script (which is what this is) you can always run it like this:

bash -x script

or even this

bash -vx script

This will show what bash does for each line



[ Reply to This | # ]