|
|
#41 |
|
League Commissioner
Join Date: Jan 2002
Posts: 5,536
|
whoops. yeah, heh, it's a thing with the quotes. the ticks need to be backslash-escaped in the echo redirect. but vB needs to see two, dual, redundant, back-to-back backslashes to habla blah blah...
edit2: i should make this clearer. vBullitin, the system that runs this board, needs two backslashes together in the post editor to show one in the thread. hmm, not much clearer, but you'll either figure it out or you won't. Code:
add-alias ()
{
local name=$1 value="$2"
echo alias $name=\\'$value\\' >> ~/.bash_aliases
eval alias $name='$value'
alias $name
}
Last edited by mervTormel; 05-07-2002 at 07:31 PM. |
|
|
|
|
|
#42 |
|
MVP
Join Date: Jan 2002
Location: Boston, MA
Posts: 1,489
|
Thanks, but dang those pesky escape characters!
One neat feature of your function is that you don't have to close the current terminal session to use the new aliases.
__________________
:: 3.4GHz Core i7 iMac 4GB RAM :: Black MacBook SR :: 10.7.2 :: iPhone 4 / iOS 5 :: |
|
|
|
|
|
#43 |
|
MVP
Join Date: Jan 2002
Posts: 1,562
|
Thnx for the informative thread guys - I actually solved my prob via someone recommending this thread. On a related note - in my search for answer I ran across an interesting repository of user-submitted shell files. I posted this to the Hints page the other day - but it never made it in I guess.
http://www.dotfiles.com/ I would be a bit wary of simply grabbing other peoples stuff an instituting it - but it could be a great source to pick up tidbits from. |
|
|
|
|
|
#44 |
|
Site Admin
Join Date: Dec 2001
Location: Minneapolis, MN
Posts: 3,988
|
Geez, I just wandered in here. Great work, folks. I am not worthy!
Is it possible to generate a summary of the findings to date? Maybe a book on the subject (I'm sure O'Reilly would be interested)? |
|
|
|
|
|
#45 |
|
MVP
Join Date: Jan 2002
Location: Boston, MA
Posts: 1,489
|
One more thing, how do I get .bashrc to look to .bash_aliases? The function we have been fiddling with sets aliases fine for the current shell but no new ones.
btw, found your source for the function, merv, and there it looks like this: Code:
# Function which adds an alias to the current shell and to
# the ~/.bash_aliases file.
addalias ()
{
local name=$1 value="$2"
echo alias $name=\\'$value\\' >> ~/.bash_aliases
eval alias $name=\\'$value\\'
alias $name
}
__________________
:: 3.4GHz Core i7 iMac 4GB RAM :: Black MacBook SR :: 10.7.2 :: iPhone 4 / iOS 5 :: |
|
|
|
|
|
#46 |
|
Moderator
Join Date: Jan 2002
Location: Singapore
Posts: 4,237
|
Hi all,
Well, now that the old good thread came back to life, it's time to post an update on the subject. So, for all the tcsh lovers out there... Here is how my .cshrc file looks today : Code:
source /sw/bin/init.csh
date
set prompt="\! [%{\033[32m%}%n%{\033[0m%} @%{\033[36m%}%/%{\033[0m%}] : "
alias l 'ls -Ahl --color=always'
alias lh 'ls -Al --color=always'
alias ls 'ls -A --color=always'
alias m 'more'
alias top 'top -u -s 10'
set histfile = .history
set savehist = ( 250 merge )
set complete=enhance
alias lo 'logout'
alias fword ' grep -i \!* /usr/share/dict/web2 '
xttitle pm@$cwd
alias cd 'chdir \!*;xttitle pm@$cwd'
alias pushd 'pushd \!*;xttitle pm@$cwd'
alias popd 'popd \!*;xttitle pm@$cwd'
alias back 'cd -'
alias h 'history'
alias psh 'pushd'
alias pop 'popd'
alias md 'mkdir'
alias krm 'rm -i'
alias r 'rehash'
alias cl 'cd \!* ; ls'
fortune
http://compsci.salve.edu/macosx.html (a lot of good info on this site, and by the way, pmccann, another mathematician working hard on a mac, check it out). From bash, I think you can change the xterm/aterm/Eterm/rxvt/ title like this: echo -e "\e]2;This is the title\007" and in the man console_codes you can see the other variants of window/icon title. Truth is, I also installed bash and I'm learning the way, slowly. But not yet enough to start posting about it. Maybe next time. Cheers... Last edited by sao; 05-07-2002 at 10:56 PM. |
|
|
|
|
|
#47 | |||||||||||||||||||
|
League Commissioner
Join Date: Jan 2002
Posts: 5,536
|
put a call to ~/.bash_aliases in ~/.bashrc ? Code:
if [ -e ~/.bash_aliases ]; then . ~/.bash_aliases; fi # load .bash_aliases |
|||||||||||||||||||
|
|
|
|
|
#48 |
|
League Commissioner
Join Date: Jan 2002
Posts: 5,536
|
okay, my previous reply was a little terse, so i'll flesh it out a little. this is bash specific in odor, but the fragrance applies to other shellage...
~/.bash_profile is automagically called on login by the bash executable, as per the man pages. this file performs the things you want to happen on the inital login session. one of those things is to load the ~./bashrc file. Code:
# ~/.bash_profile if [ -f ~/.bashrc ]; then . ~/.bashrc ; fi date who biff y echo "home size: `du -sh ~`" fortune # -o the file ~/.bash_aliases is not in the bash startup sequence. it's a user-invented file. therefore, it needs to be 'existed' and loaded. the reason i broke out aliases to their own file was so i could define a reasonable, portable and mostly self-contained add_alias function and not worry about polluting the end of another file or of writing additional aliases beyond a premature exit or return. since .bashrc is the meat of my shell brains, i have a 'return' at a logical place in my .bashrc and beyond that 'return' are notes and test code that i want to keep, so my .bashrc looks like: Code:
production code
decision making code
calls to other files, like .bash_aliases
return
junk and embarrassing stuff
notes and epithets towards steve balmer
test code and stuff that can't pass for code
i realize this may be confusing; it's harder to explain than experience. a handy tip is to always have several shell windows open when you modify your startup scriptage so you can switch back to the un-tainted to fix things up. and test test test, lest you be unable to login to your shell to fix it. feel free to ask questions and make suggestions (the non-lurid kind). |
|
|
|
|
|
#49 |
|
Moderator
Join Date: Jan 2002
Location: Singapore
Posts: 4,237
|
MervTormel, rusto,
Sorry, just getting in the middle a little bit to finish my post from above. Of course, if you want to display your location in the window title, without using xttitle, you can do the following: create a file in your home directory named .settitle with: Code:
alias settitle 'echo -n "^[]2;$cwd^G"' settitle alias cd 'cd \!*;settitle' alias pushd 'pushd \!*;settitle' alias popd 'popd \!*;settitle' The ^G character by pressing ctrl-v followed by ctrl-g. After you created .settitle, add the following to your ~/.cshrc file: source ~/.settitle Now you should get your location in the window title. Thank you, let's now continue with the bash education. (By the way MervTormel, what I wrote about bash title in my post above, does it make any sense?) Cheers... PS: Bluehz, for tidbits besides http://www.dotfiles.com you can also check http://www.shelldorado.com/shelltips/beginner.html Last edited by sao; 05-08-2002 at 02:40 AM. |
|
|
|
|
|
#50 | ||||||||||||||||||||||||||||||||||||||
|
MVP
Join Date: Jan 2002
Posts: 1,562
|
Maybe I am missing someting here or its losing something in the text to HTML display translation. I tried the ctr-v followed by.... scenario and I get nothing - or I get the tcsh help facility. Why can I not just use the "^" provided on the keyboard?
Thx! Checkin it out right now...
ADD: shelldorado is great! Thanx for the turn-on. BYW - did you happen to visit the Tutorials page http://www.shelldorado.com/links/index.html#tutorials it is a HUGE page of links to UNIX related tutorials. Could take a while to digest all this! Last edited by bluehz; 05-08-2002 at 09:46 AM. |
||||||||||||||||||||||||||||||||||||||
|
|
|
|
|
#51 |
|
Moderator
Join Date: Jan 2002
Location: Singapore
Posts: 4,237
|
bluehz,
Best, is to create the .settitle file with vim, I had trouble with pico to type the special characters. Don't miss any characters or it will not work. Let me know. Cheers... PS: Wow, quite a few links to unix tutorials there. Last edited by sao; 05-08-2002 at 10:50 AM. |
|
|
|
|
|
#52 |
|
MVP
Join Date: Jan 2002
Posts: 1,562
|
Yes - I think I figured that out - copy and paste doesn't work in pico. I don't get around very well in VIM, etc. Guess I'm gonna have to start learning....
|
|
|
|
|
|
#53 |
|
Moderator
Join Date: Jan 2002
Location: Singapore
Posts: 4,237
|
bluehz,
Go for it. Learn a couple of commands in vim and you are done in five minutes. It's not so difficult, I promise. Or, if you still have XFree installed you can call gvim, the GUI version of vim, and there just type, save and quit. Good luck. Cheers... |
|
|
|
|
|
#54 |
|
All Star
Join Date: Jan 2002
Location: Dexter, MI, USA
Posts: 704
|
<flamebait>vim is the devil! Use Emacs!</flamebait>
Or xemacs, if you want a gui version.
__________________
- Greg Happy user of OS X since the Public Beta. Help Team Mac OS X cure cancer, Alzheimer's, ALS, Parkinson's, and more! |
|
|
|
|
|
#55 |
|
Moderator
Join Date: Jan 2002
Location: Singapore
Posts: 4,237
|
xchanyazy,
Yes, emacs, Xemacs are great. I suggested vim because I found is slighlty easier for a beginner) By the way, in order to use all of them and not to be concerned about the devil, you need to be.... |
|
|
|
|
|
#56 |
|
MVP
Join Date: Jan 2002
Location: Brisbane, Australia
Posts: 1,108
|
The main reason I always use vi is because there are not many UNIX boxes that does not have it. At one time I tried using emacs, became quite comfortable with it, but then started cursing when I could not us it on certain machines (it is not installed by default on a lot of machines and has a huge footprint which precludes putting it on others). I then went back to good old vi which works the same every where and exists everywhere!
My opinion of course 8-)
__________________
Douglas G. Stetner UNIX Live Free Or Die |
|
|
|
|
|
#57 |
|
MVP
Join Date: Jan 2002
Posts: 1,562
|
I d/l, compiled and installed VIM today. Haven't had much chance to mess with it yet. VI just totally confuses me. Its not that I couldn't learn it in a few mins - its just I shouldn't have to spend an inordinate amount of time learning to use a simple text editor. I guess thats why so many people use tcsh - you can normally just poke and peck and get around. More than once I have gotten stuck in VI, can't go back, can't go forward - totally confounding. Obviously I don't know the secret code...ahahahaha....
Giving VIM a good try though.... |
|
|
|
|
|
#58 |
|
League Commissioner
Join Date: Jan 2002
Posts: 5,536
|
yeah, vi is a bit awkward at first. but stetner is correct. it's recommended to know, at least with a passing familiarity, because it is universally available on unix installs.
there's only a few notions and a handful of key sequences to know to be able to use vi at a minimal level. and get out of messes. even tho the man pages has a fast start section that covers the minimum, it might be useful to start a vi thread somewhere. |
|
|
|
|
|
#59 | |||||||||||||||||||
|
MVP
Join Date: Jan 2002
Location: Brisbane, Australia
Posts: 1,108
|
That said, vi has two modes, insert and command mode. If you are not sure where you are, hit <ESC> and you are in command mode (two times if you happen to be in a 'raw keystroke entry mode IE have just hit ^V). Then just a ':q' to quit (or ':q!' to quit if the buffer has been changed, or ':wq' to write and quit). If check out:www.google.com/search?hl=en&q=vi+cheat+sheet You will see there are a lot of cheat sheets to help you get started. The two things I like best are key mapping and the search/replace. Key mapping lets you do something like (where ^V is control-V and ^[ is <ESC>: Code:
:map g 0iStart of Line - ^V^[$aEnd of Line - ^V^[j Code:
aaa bbb ccc ddd To: Start of Line - aaa - End of Line Start of Line - bbb - End of Line Start of Line - ccc - End of Line Start of Line - ddd - End of Line if you had: Code:
Fish is good Beef is good Fish is good Beef is good A search/replace of: :g/Fish/s/good/bad/ Turns it into: Fish is bad Beef is good Fish is bad Beef is good Anyway, there are a million neat things you can do in vi (from the keyboard) that make it very good for hacking text.
__________________
Douglas G. Stetner UNIX Live Free Or Die |
|||||||||||||||||||
|
|
|
|
|
#60 |
|
Moderator
Join Date: Jan 2002
Location: Singapore
Posts: 4,237
|
stetner,
Thanks for the input and the "nipple" memories. Since Vim 6.1 became available through Fink, and I realized that I could launch gvim as long as I had X11 running, I never looked back. Although it may look strange as vim has two modes, learning from scratch was fast and easy for me. Cheers... Last edited by sao; 05-10-2002 at 12:51 AM. |
|
|
|
![]() |
|
|