Go Back   The macosxhints Forums > OS X Help Requests > UNIX - Newcomers



Reply
 
Thread Tools Rating: Thread Rating: 60 votes, 4.98 average. Display Modes
Old 02-11-2002, 10:30 AM   #21
stetner
MVP
 
Join Date: Jan 2002
Location: Brisbane, Australia
Posts: 1,108
Quote:
Originally posted by ebow

UPDATE/edit: The fact that the file never properly got sourced made me think there must be something wrong with the *file* itself, as opposed to the path, filename, contents, etc. So, I renamed environment.mine to ___.BACKUP, and then pasted the contents into a new textfile in BBEdit. I saved it with Unix line breaks, opened a new terminal window, and voila! It's in the loop.
.

For what it is worth, I went through this a while ago (read: too long to remember what I discovered!) and ended up leaving this comment in my environment.mine file:

Code:
# This gets over written by sys defaults.  put stuff in rc.mine

Now, if I could only remember what I meant by that cryptic little comment.....

UPDATE: I think I remember now... I was trying to set something standard like a 'MANPATH' maybe, and it was never showing up because one of the /usr/share/init/tcsh/... files was over riding my variable. Got ticked off and just reminded myself where I could set thing and not have them be over-ridden.

I do know I am setting my environment variables in my rc.mine file.


Personally, I think this is a case of 'trying to please everyone'. The fact that the initialization files have become this convoluted make them more of a hinderance than a help.

Ahh, if only I could find a ksh that lived up to my expectations.

Doug
__________________
Douglas G. Stetner
UNIX Live Free Or Die

Last edited by stetner; 02-11-2002 at 10:38 AM.
stetner is offline   Reply With Quote
Old 02-11-2002, 10:45 AM   #22
sao
Moderator
 
Join Date: Jan 2002
Location: Singapore
Posts: 4,237
pmccann, glad you came...

Actually, I was thinking when will you come to join us here as I trust your experience and jugdement a lot.

I know, I know, and I agree with you. I'm all for the ".cshrc and .login" twosome" as you called them.

Problem is everywhere they glorify and teach you how to "creatively abuse their ~/.cshrc or ~/.tcshrc or ~/Library/init..."as you did say. And most of us finish by having a lot of probably unnecessary files.

Noboby explains or teach newcomers how to establish themselves just working with the:

".cshrc and .login"

I see this as a chance, we can all learn something.
Please, if you would just explain further how do you manage these two files, I will be very grateful.

Cheers...
sao is offline   Reply With Quote
Old 02-11-2002, 11:53 AM   #23
pmccann
Major Leaguer
 
Join Date: Jan 2002
Location: Adelaide, South Australia
Posts: 470
Hey, cut the flattery, sao!

Seriously, I really don't think there's very much I can say! [Update, on rereading this: doesn't seem to have stopped me from writing a lot!]

Anything that's in a .tcshrc file could just be chucked into a .cshrc file and the former deleted. That whole swag of files in ~/Library/init/tcsh are really only "sourced" as necessary, so you can similarly throw any such commands into one of the terrible twosome (.login / .cshrc).

Stepping back a little: obviously the whole philosophy behind the Apple arrangement (as explained in Fred Sanchez's README file in /usr/share/init/tcsh) is that you shouldn't need to think, for example, about where an alias command should be put: you just put all your aliases in

~/Library/init/tcsh/aliases.mine

and the existing scripts in /usr/share/init/tcsh will take care of loading them as required, as explored by you folk in great depth above. But part of the motivation for this seems to have been overridden by the default set-up: you'll notice that the README talks about throwing the scripts into your .tcshrc and .login and .logout files, but in fact they've already been installed system-wide, leaving the .cshrc/.tcshrc/.login/.logout files in your home directory effectively empty. Which is fine until someone else comes and *requires* you to be using those (as I think you mentioned with fink), and until you start talking to people who've used unix for a long time and just reel off "add this to your .cshrc" in response to any number of queries; and the reality of the current situation is that almost all unix experts that you encounter will have the vast majority of their experience in an environment *other* than Mac OS X.

I had wondered whether this system was adopted from, say, FreeBSD, but having just logged onto a FreeBSD box I can't see an equivalent set of files for users there: instead it's just the usual /usr/share/skel/ (ie "skeleton") files, "dot.cshrc", "dot.shrc", "dot.(whatever...)" that get copied into a new user's account. There's certainly nothing equivalent in Solaris either. Maybe one of the other BSD's?

Please note that I'm not saying there's anything wrong with following the letter of the README, it's just that you'll have something of a problem in translation if you do so. "So should that go in my 'completions.mine' file in my ~/Library/init/tcsh directory?" is not a question I've heard a lot! Admittedly that's a little unfair, in that completions are outrageously groovy, and not used nearly enough in other OS's I've known. But the fact that apple has *only* done this for tcsh (as far as I can tell; corrections welcome!) is somewhat telling: if it's a general strategy then surely it should be available to zsh users, for example. What do they do? Then bash users have to fit into this somehow as well. Seems weird to have tcsh singled out this way.

In short I think this might just be one of those wheels that didn't really need to be reinvented.

So where's this rambling nonsense taking us? NOT FAR! What "should" a .cshrc contain: well, aliases, "set" commands to the shell, and maybe (gulp!) a "source path_to_file" command or two, most probably including the one that fink inserts!

And a .login? Pretty much just environment variables *for me*. Your mileage should probably differ! There *is* a slightly skew aspect to OS X and Terminal.app that I'll quickly try to outline. If you log in to a Solaris box, say, the .cshrc executes, and then the .login executes. Just like OS X. But on other unices you then tend to open a whole slew of Xterm windows to "do your business". On OS X you open multiple terminal windows, *each* of which executes your .cshrc and .login. Slightly odd; I really wish Apple would put some more effort into making the terminal a nicer place to live. It's pretty awful at the moment (cf some of the other threads on these boards), and is also one of the things that receives really bad press among some of the new breed of OS X users; converts from other unix platforms. (Interesting aside: there's a small but steady drift of high-profile perl developers/maintainers who are either using OS X or are very interested in doing so. This can only be good for the OS. Already Perl 5.7.2 (a developer release) is reported to pretty much build out of the box, whereas 5.6.1 required quite a bit of tweaking to do the same. If other people observer similar drift for other projects it'd be nice to hear about it sometime.)

OK, that's me done. Best I can hope for here is that I didn't make the water *muddier* for anyone!

Regards,
Paul
pmccann is offline   Reply With Quote
Old 02-11-2002, 12:41 PM   #24
mervTormel
League Commissioner
 
Join Date: Jan 2002
Posts: 5,536
'good times' paul, thanks. and thanks to doug.s for his story and POV. i think he's right, it's a 'trying to please everyone' thing, but i add, 'poorly'.

it seems to me that Fred Sanchez's startup methodology was thrown together to prevent the flood of calls from UNIX newcomers to apple about what goes where, as paul alluded. no thinking required, which is why we're stuck in this post-50's rut. nevermind. don't get me started.

by the way, paul

% bash --version
GNU bash, version 2.05.0(1)-release (powerpc-apple-darwin5.2)
Copyright 2000 Free Software Foundation, Inc.
...

/Volumes/foo/bash-2.05a/examples/startup-files/apple/README

is the same lead-filled snowshoe, er, footprint as Fred.S' tcsh startup, but there are other startup examples more traditional.

paul's other good point (among many) is that you should probably have a glancing familiarity how other unices work so you don't sound like a stuttering macolyte zombie at vaunted sysadmin cocktail parties. a veritable plea for a verbal de-pantsing.

-mt

--
i pine for the 50's and i wasn't even born then!
mervTormel is offline   Reply With Quote
Old 02-11-2002, 01:18 PM   #25
sao
Moderator
 
Join Date: Jan 2002
Location: Singapore
Posts: 4,237
(pmccann, this time I promise no flatery at all.)

What can I say, you wrote a great post.

Just think, about all the beginners and the others, that will be reading what we wrote, and that is good, the purpose is served.

By the way, MervTormel adviced me before in other thread that the subject was going to be "a considerable post with a lot of subjective bickering".

Then, I couldn't understand why. All I wanted was to clear up for beginners how to use the files they tell us to use.

Thanks to your post, I know better now how to implement and simplify things. Hope other people understand too.

By the way, I also noticed the perl developers moving slowly to OS X, and I think is great.

Cheers...
sao is offline   Reply With Quote
Old 02-12-2002, 03:06 AM   #26
sao
Moderator
 
Join Date: Jan 2002
Location: Singapore
Posts: 4,237
Some thoughts...

After having a good night sleep, I read our posts again.

And there are some things that keep running around in my mind.

I can say "I'm not an old Unix hand". (Although I was already alive in the 50', born in 48)
But, have always been a loyal Macintosh user.

I started studying Unix from the time Apple released OS X Beta. I moved fast to XFree86 (actually, from tips learned in Macosxhints) and since then, continue studying every day.

Ater digesting what I learned, from what we wrote in the previous posts, I feel a little more can be done.

Many experienced Unix users had passed through this forum, but I haven't seen this approach explained before. Why?

How are the newcomers suppose to learn what's the best to do?
The hard way I suppose, then.

Wouln't be easier if we all put our knowledge to better use and really say what we think is best and why we think it's the best, so that everybody can learn, without the subjective touch?

In answer to MervTormel post at:*

http://forums.macosxhints.com/showth...=&threadid=591

I wrote:
<<And it will not turn always into subjective bickering if we keep it focused to the real beginner (somebody, who opens the term for the first time and says "and now what?")>>

So, I say it now, "and now what" ?

(Probably, I know a little more than a beginner to figure it out myself)
But that's not the case, with a true beginner. (And, this is, a Unix newcomers thread)

I would love to keep this thread alive, my intentions are pure, I want to learn, we all want to learn. If the situation is messy, let's clean it up.

But, I need your help guys, I'm not an old "Unix" hand. But of course, feel free to pick up the ball or not. Respectfully yours.

Cheers...

Last edited by sao; 02-12-2002 at 03:29 AM.
sao is offline   Reply With Quote
Old 02-12-2002, 08:33 AM   #27
Titanium Man
Guest
 
Posts: n/a
You took the words out of my mouth, sao. I understand that the way proscribed in the /usr/share/init/tcsh/README might be easier for mac users new to Unix, since you don't have to determine what goes where, and that most Unix people apparently have only 2 files they modify, the ~/.cshrc and the ~/.login (that's if I've understood what was previously posted). So, since I'm eager to learn, is it maybe better then to move the contents of the .mine files to the ~/.cshrc and ~/.login files? Is this better if we want to modify environments in different shells (since it's a more "Unix" way?) I'm trying to learn how things work in bash, but now have NO idea where to put what. Thanks for all the help, this has been so informative already!
  Reply With Quote
Old 02-12-2002, 09:19 AM   #28
sao
Moderator
 
Join Date: Jan 2002
Location: Singapore
Posts: 4,237
Hi Timan,

I share your concern.

But let me tell you that I already deleted my ~/.tcshrc file and wrote my aliases, prompt, my source path to fink and some other things (fortune, etc.) in the ~/.cshrc file.

Is all working very smoothly. And I'm glad I made the changes.

I don't really know if this is more the "Unix way", but this is probably a much simpler way and I hope it's the message I could understand from pmccann.

Still, I have a lot to learn, and every day is two steps forward and one step back. But I'm really enjoying the ride.

The world of Unix is incredible interesting to me. Rgds and...

Cheers...

PS: Sorry I don't know anything about bash, maybe, MervTormel or pmccann can help us here. I probably will also install bash with fink.

Last edited by sao; 02-12-2002 at 09:23 AM.
sao is offline   Reply With Quote
Old 02-13-2002, 04:46 AM   #29
sao
Moderator
 
Join Date: Jan 2002
Location: Singapore
Posts: 4,237
Thanks to a great tip from pmccann at the following thread:

http://forums.macosxhints.com/showth...=&threadid=842

I have now also add the following to my .cshrc file:

set histfile = .history

set savehist = ( 250 merge )

alias lo ' logout '

Cheers...

Last edited by sao; 02-14-2002 at 12:45 AM.
sao is offline   Reply With Quote
Old 02-13-2002, 09:14 PM   #30
Fritz
Prospect
 
Join Date: Jan 2002
Location: Seattle, WA
Posts: 11
Thumbs up You folks are GREAT

I just want to say thanks for all your solid input here. I have searched and searched feeling all alone in my quest for information and people interested as I am in the underpinnings of OSX. I am Sooooo happy to have finally found you all.

Thanks for a great subject and outstanding input.
I am home...

Best regards
Fritz
Fritz is offline   Reply With Quote
Old 02-14-2002, 02:55 AM   #31
sao
Moderator
 
Join Date: Jan 2002
Location: Singapore
Posts: 4,237
Hi there,

sorry for mixing threads, but I thought it was important to include the following in this one:

-----------------------------
Sao wrote:

pmccann,

thanks, it works like a charm, please tell me what else do you stick in your... .cshrc file?

Come on man, no more secrets here.

and also, pleaseeeee.... open up your .login file, we all want to know what you have inside.

thanks again...

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

pmccann wrote:

As for my .cshrc file: that's like asking to see my petticoat: errr, my stockings... ummm, my underwear. Phew: got there eventually.

I've just scoured the file in question and can't find anything that's incredibly interesting: maybe this bunch might be of general worth...

set complete=enhance
set color
alias lsc 'ls-F'
alias work 'ssh -L 2001:my.server.com:110 my.server.com'
alias vnc 'ssh -C -L5910:my.work.com:5901 my.work.com'
alias top 'top -u -s 10'

The first one was kicking around osxhints relatively recently: it just makes your tab completion in the shell case insensitive. That is, if you enter

cd /sy

and then hit the tab key it'll fill out the directory to /System (note the capitalization) and so on. I think the pros of this approach outweight the cons, (basically, if you have two files, say "makefile" and "Makefile.PL" to choose a decidedly loaded example you can't discriminate by entering the capital M, but enter m[tab] -> makefile -> makefile.[tab] if you can see what I mean.) Yep, on further consideration, it's definitely worth it: to get to the cgi directory, for example...

/l[tab]w[tab]c[tab][return]

instead of having to enter three capital letters. I have e e cummings' disease when it comes to entering commands. (And no, he's not from Adelaide either!)

The second and third are linked, and provide a colour coded directory listing in your terminal readout when you enter "lsc" (ie ls"coloured", but call it what you will. Not particularly stunning, but fine and possibly helpful if you don't have too many items in your directories.

The fourth is a command I run every time I connect with my modem. It just logs me on to my old work server using ssh, and tunnels port 2001 locally to port 110 (the pop port) on that machine. So in my email application I enter the server as 127.0.0.1 and the port as 2001, and my pop requests travel in an ssh tunnel to the server instead of my all-too-powerful password being thrown out there in the clear every time I collect my mail, which is a bit of a horrifying thought.

The fifth is almost identical, except that it connects me to a vnc server that's running on another machine, and again tunnels local requests to port 5910 through to port 5901 on the other machine. (vnc servers grab the first open port after 5900, and you need to know which one your server started on to get this right: I basically leave mine running all the time, so tying it down this way doesn't cause any difficulties.) The -C requests that compression should be used on the data travelling in that tunnel, which is worthwhile here because the *amount* of data that vnc must send back and forth is non-trivial.

The final one just calms "top" down. MacOSX and FreeBSD just crank up top with a refresh rate that's way too high for me (every second?), so I just modify the command so that it refreshes every ten seconds instead, and is sorted by cpu usage. Only (slight) downside of this command is due to what I think is a bug in the version of top on OSX: it starts out will all proc's consuming 0.00%, and doesn't give real results until the first refresh. Just hit space to invoke the refresh manually. Actually the top we get is terribly lame compared to the utility on other platforms (and don't mention the way that terminal. app draws the characters at the bottom of the screen: even the "q" that you enter to quit.)

For a short post this is awfully long. Enough...

Paul
-------------------------------

Cheers...
sao is offline   Reply With Quote
Old 02-14-2002, 03:35 AM   #32
sao
Moderator
 
Join Date: Jan 2002
Location: Singapore
Posts: 4,237
When I joined this thread my ~/.cshrc file had only the following :

source /sw/bin/init.csh

Cleaning up other files and now my ~/.cshrc file looks like this:

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 lo 'logout'
alias top 'top -u -s 10'
set histfile = .history
set savehist = ( 250 merge )
set complete=enhance
fortune

Cheers...
sao is offline   Reply With Quote
Old 02-14-2002, 04:36 AM   #33
mervTormel
League Commissioner
 
Join Date: Jan 2002
Posts: 5,536
c'mon sao, we know that's a fortune -o


okay, so paul convinced you to go back to the monolithic, one size fits none approach.

there are advantages to breaking out certain command types into their own files, such as aliases and the florid completions.

e.g., it's handy to have a tool to add new aliases as they become necessary...

here's a bash function:
Code:
# Function which adds an alias to the current shell and to
# the ~/.bash_aliases file.
add-alias ()
{
   local name=$1 value="$2"
   echo alias $name=\'$value\' >> ~/.bash_aliases
   eval alias $name=\'$value\'
   alias $name
}
resulting:

$ add-alias foo "argle bargle bliz \`blaz\` blah blah blah"
alias foo='argle bargle bliz `blaz` blah blah blah'

not so much "subjective bickering" as "respectfully submitted for your consideration"
mervTormel is offline   Reply With Quote
Old 02-14-2002, 06:58 AM   #34
sao
Moderator
 
Join Date: Jan 2002
Location: Singapore
Posts: 4,237
Welcome back, MervTormel,

Yes... I confess... it's a -o

Pmccann, has the taste, and it's great to learn from his posts...
Many things cleared up following his advice.
(pshhhh......don't tell him........he doesn't like flattery)

And, you MervTormel, you have the oustanding quality of a "great professor".
Not the kind that makes you sleepy...but that one who "awakes" you to many possibilities and slowly guide you to solve the problems by yourself.

I'm in good hands here.

Thanks for your tip to add aliases.

Can you also make it work for tcsh ?

(Haven't installed bash yet.)

Cheers...
sao is offline   Reply With Quote
Old 02-14-2002, 02:10 PM   #35
Titanium Man
Guest
 
Posts: n/a
Merv, that's GOLD thanks! Sao, this is a primitive ugly thing I was doing to manually add aliases, but it worked for me.

alias mkalias "pico ~/Library/init/tcsh/aliases.mine"

As I said this isn't near as elegant as Merv's script since it only opens your aliases.mine file when you type

mkalias

and then you have to add the alias yourself, but it's a starting point. Salutations to all!

TiMan

Come to think of it, how about this?

alias mkalias 'echo \!* >> /Users/timan/Library/init/tcsh/aliases.mine'

You would of course substitute your user name for timan and instead of mkalias you call it whatever you want (I know YOU know this, sao, but this *is* the newcomers section). You would add this command to your ~/Library/init/tcsh/aliases.mine file or .cshrc file and when you type this, for example

mkalias "alias ls 'ls-a'"

(that's a single quote followed by a double quote at the end of the line)
and you'll have a new alias for the ls command. Not as pretty as Merv's script, and this might not work for everything, but I'm a newbie so bear with me.
  Reply With Quote
Old 02-14-2002, 02:34 PM   #36
mervTormel
League Commissioner
 
Join Date: Jan 2002
Posts: 5,536
thanks, sao. i've been called worse things than pedantic and didactic.

yes, we are all in good company here.

tcsh no habla functions, to my knowledge. and there's a lot of trouble getting quoting right in csh. here's some gnarlyness from UNIX Power Tools about getting quoting right in csh.
Code:
## QUOTING RIGHT IN ALIASES:
##
## quote and makealias -- Get quoting right in csh aliases
#
alias quote     "/usr/bin/sed -e 's/\\!/\\\\\!/g' \
-e 's/'\\\''/'\\\'\\\\\\\'\\\''/g' \
-e 's/^/'\''/' -e 's/"\$"/'\''/'"
alias makealias "quote | /usr/bin/sed 's/^/alias \!:1 /' \!:2*"

then feed makealias your alias name, and enter its value thusly...

% makealias mycat
cat `ls | sed '1,/!*/d'` | less
^d
alias mycat 'cat `ls | sed '\''1,/\!*/d'\''` | less'
%
hmmm, switching to bash is my very next priority.
mervTormel is offline   Reply With Quote
Old 02-15-2002, 06:13 AM   #37
sao
Moderator
 
Join Date: Jan 2002
Location: Singapore
Posts: 4,237
Thanks, Timan and MervTormel.

I need to study a little more about aliases and tsch.

Now I got things working and organized with tsch.

And I need the courage to start messing up with bash.

Unless I get help in setting up everything again, I plan to wait for a while. (and study)

Found an interesting article about csh and bash:

http://mirrors.gw.com/tcsh-book/csh-whynot

Cheers...
sao is offline   Reply With Quote
Old 05-07-2002, 05:02 PM   #38
rusto
MVP
 
Join Date: Jan 2002
Location: Boston, MA
Posts: 1,489
There's nothing like heating up a thread thought long stored away in the cooler...

mervTormel, a few posts up you toss out this function:

Code:
# Function which adds an alias to the current shell and to
# the ~/.bash_aliases file.
add-alias ()
{
   local name=$1 value="$2"
   echo alias $name='$value' >> ~/.bash_aliases
   eval alias $name='$value'
   alias $name
}
nice! But I'm foggy on where to put the function...in .bashrc? Or in as a standalone file in ~/bin?
__________________
:: 3.4GHz Core i7 iMac 4GB RAM :: Black MacBook SR :: 10.7.2 :: iPhone 4 / iOS 5 ::
rusto is offline   Reply With Quote
Old 05-07-2002, 05:10 PM   #39
mervTormel
League Commissioner
 
Join Date: Jan 2002
Posts: 5,536
put it in .bashrc so that it exists in your function stack when you login.
mervTormel is offline   Reply With Quote
Old 05-07-2002, 05:25 PM   #40
rusto
MVP
 
Join Date: Jan 2002
Location: Boston, MA
Posts: 1,489
Great, that was my guess...but say I want an alias to take me to /Library/StartupItems, so I clack this in:

Code:
add-alias cdsi "cd /Library/StartupItems/"
the function echoes (as expected):

Code:
alias cdsi='cd /Library/StartupItems/'
but upon doing cat .bash_aliases it is revealed that the function has actually written:

Code:
alias cdsi=$value
I suspect it's a thing with the quotes...or is it?
__________________
:: 3.4GHz Core i7 iMac 4GB RAM :: Black MacBook SR :: 10.7.2 :: iPhone 4 / iOS 5 ::

Last edited by rusto; 05-07-2002 at 05:27 PM.
rusto is offline   Reply With Quote
Reply


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



All times are GMT -5. The time now is 10:35 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.