User Name
Password
AppleNova Forums » Apple Products »

Terminal Tricks


Register Members List Calendar Search FAQ Posting Guidelines
Terminal Tricks
Thread Tools
Gargoyle
http://ga.rgoyle.com
 
Join Date: May 2004
Location: In your dock hiding behind your finder icon!
 
2004-05-30, 04:26

I have been using Linux and the likes for a few years now and never came across this little gem before. Hope you find it useful

Code:
cd -
This takes you to the previous directory you were in. not the parent like ".." does. So if you were in "/Users/fred/Desktop" then you cd to "/Users/bob/Desktop". Doing a "cd -" will take you back to freds desktop directory.

Enjoy.

OK, I have given up keeping this sig up to date. Lets just say I'm the guy that installs every latest version as soon as its available!

Last edited by Gargoyle : 2004-05-31 at 04:29. Reason: Title change
  quote
chucker
 
Join Date: May 2004
Location: near Bremen, Germany
Send a message via ICQ to chucker Send a message via AIM to chucker Send a message via MSN to chucker Send a message via Yahoo to chucker Send a message via Skype™ to chucker 
2004-05-30, 05:49

You can even combine those. cd -- will take you *two* steps back.
  quote
SilentEchoes
Unique Like Everyone Else
 
Join Date: May 2004
Location: Rochester, NY
Send a message via AIM to SilentEchoes  
2004-05-30, 09:27

Well would you look at that. I dunno though its not very often I go skipping around to random directories that are not parents of each other and need to go back. If this had happened to me in the past odds are I cd'ed the entire path in which case I would just hit the up arrow the desired number of times and cd to that dir again.


Either way thanks for the tip

WARNING: Do not let Dr. Mario touch your genitals. He is not a real doctor.
  quote
curiousuburb
Antimatter Man
 
Join Date: May 2004
Location: that interweb thing
 
2004-05-30, 12:41

terminal typing is ok.
being able to drag and drop directory listings into terminal directly from finder is better.

and of course there's always the coolest terminal trick for sci-fi fans.

telnet towel.blinkenlights.nl

set your terminal window translucency and sit back and watch
  quote
thuh Freak
Finally broke the seal
 
Join Date: May 2004
 
2004-05-30, 18:48

similar to that 'cd -' trick is the pushd & popd pair, and dirs. if you are using the bash shell (and presumably others), pushd will act just like cd. but, popd acts like 'cd -'. using these names, i find, helps amplify the stack nature of the directories. and a call to 'dirs' lists the stack, incase you want to go far back in the annals of history, and have lost your way. oh, perhaps worthy of mention, pushd and popd aren't exactly like 'cd'. they are like 'cd $@;dirs', b/c after going to a dir, they list out the contents of the directory stack.
  quote
Wickers
is not a kind of basket
 
Join Date: May 2004
 
2004-05-30, 18:52

Neat,

Kinda useful, I like it.

But this thread should be renamed to "Terminal Tricks" because nothing pointed out so far is limited to just OS X.

  quote
Gargoyle
http://ga.rgoyle.com
 
Join Date: May 2004
Location: In your dock hiding behind your finder icon!
 
2004-05-31, 04:31

Bah, editing the title in the first post still does not change the title of the thread... Which is probably a good thing...

Do us a favour mod, change this to just "Terminal Tricks" and other people can keep posting new tricks.

Ta

OK, I have given up keeping this sig up to date. Lets just say I'm the guy that installs every latest version as soon as its available!
  quote
Mac+
9" monochrome
 
Join Date: May 2004
Location: 🇦🇺
 
2004-06-01, 08:16

Quote:
Originally Posted by Gargoyle
I have been using Linux and the likes for a few years now and never came across this little gem before. Hope you find it useful

Code:
cd -
This takes you to the previous directory you were in. not the parent like ".." does. So if you were in "/Users/fred/Desktop" then you cd to "/Users/bob/Desktop". Doing a "cd -" will take you back to freds desktop directory.

Enjoy.
Ahhh Gargoyle - thank you... I was wishing for something like this, this week - I was getting tired of going into a directory and then coming back up via the same path before traversing a different directory.

Dragging form the finder is cool, but so is this. Thanks for enlightening me.

All I want is a simple life
twitter
  quote
ZO
Member
 
Join Date: May 2004
Location: Paris, FR
 
2004-06-02, 04:10

how do I force quit an app that does NOT want to quit?

Also, when im in terminal, and run TOP is there a way to see more of the application names? There are multiple instances of "Apple" and Microsoft", etc...

I'm having deja-vu and amnesia at the same time. I think I've forgotten this before.
  quote
thuh Freak
Finally broke the seal
 
Join Date: May 2004
 
2004-06-02, 07:47

Quote:
Originally Posted by ZO
how do I force quit an app that does NOT want to quit?

Also, when im in terminal, and run TOP is there a way to see more of the application names? There are multiple instances of "Apple" and Microsoft", etc...
to the first item, here's what you do. first you have to discover the "process id" (often called the 'pid'). you can find this in `top`, or in `ps ax`. if the program is not a cocoa app (or more specifically, if it is a command line program), you won't need the pid. you could simply do `sudo killall programName`. that doesn't always work for cocoa apps though. so, once you find the pid, you do `sudo kill pid`. sometimes neither of those will work. if they spit an error message, like "no process was found" then you got the wrong prog name or pid. at this point, if the program didn't die, you should know that there are 31 ways to 'kill' a program. not all of them are fatal, but different programs react to each differently, and a lot of the time, trying to kill a program with all of these will eventually get it. copying and pasting the following into terminal (and replacing the 'pid' at the end) will attempt to kill a program in all kinds of heinous ways. if this doesn't work, you're pretty much sol. (note: you can also replace 'kill', with 'killall' and 'pid' with 'programName').
for f in 0 1 2 3; for d in 0 1 2 3 4 5 6 7 8 9; sudo kill -$f$d pid

to the second item, if you stretch your terminal window wider you can see more. moving beyond that, i don't think top gives you many options. actually, there should be a configuration bit somewhere in there to cut or alter some of the columns. i dont remember how to do that though. `ps ax` has less wide output (iirc), and you can avoid the width problem by 'piping' it to less, ie `ps ax | less`. then you should be able to get the full file names.
  quote
chucker
 
Join Date: May 2004
Location: near Bremen, Germany
Send a message via ICQ to chucker Send a message via AIM to chucker Send a message via MSN to chucker Send a message via Yahoo to chucker Send a message via Skype™ to chucker 
2004-06-02, 08:17

Quote:
Originally Posted by ZO
how do I force quit an app that does NOT want to quit?
1. Get a tool that can assign an AppleScript to a keyboard short cut. I use alt-control-slash for kill, and alt-control-shift-slash for force-kill.
2. Create two AppleScripts:

tell application "System Events" to set theApp to name of the first process whose frontmost is true
do shell script "killall " & quoted form of theApp

and

tell application "System Events" to set theApp to name of the first process whose frontmost is true
do shell script "killall -9 " & quoted form of theApp

3. Save the first as "Kill Frontmost Application.scpt" and the second as "Force-Kill Frontmost Application.scpt".
4. Assign keyboard shortcuts.

Now, whenever you have an application that seems to hang, try Kill first, and if that doesn't seem to do the job, Force-Kill definitely should.

(If that still doesn't do it, then your entire GUI is hanging.)
  quote
Posting Rules Navigation
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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

Post Reply

Forum Jump
Thread Tools

« Previous Thread | Next Thread »

All times are GMT -5. The time now is 15:51.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004 - 2024, AppleNova