Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Mac OS X > Anyone to implement a mkcd command?

Anyone to implement a mkcd command?
Thread Tools
Senior User
Join Date: Mar 2001
Location: The Netherlands
Status: Offline
Reply With Quote
Sep 10, 2003, 04:55 PM
 
I "surf" the terminal sometimes (in fact more and more) and a mkcd command would come in handy (mkdir + cd).

I did a google search, found a solution but it left me confused. Anyone capable to implement this? Thx.
I'm-a trying to wonder, wonder, wonder why you, wonder, wonder why you act so.
     
Mac Enthusiast
Join Date: Apr 2001
Status: Offline
Reply With Quote
Sep 10, 2003, 09:31 PM
 
well I'm new to this too but i just made and tested an alias 30 seconds ago and it worked fine.

Like this in tsch shell:

alias mkcd 'set thepath = \!*; mkdir $thepath; cd $thepath'


now i can just do

mkcd /user/example/path/with/dir/name

and it makes and moves to that dir but I'm sure there is a better way
     
Mac Elite
Join Date: May 2001
Status: Offline
Reply With Quote
Sep 10, 2003, 09:58 PM
 
If you make it mkdir -p it'll create all the non-existing folders from your example too

-
     
Mac Enthusiast
Join Date: Apr 2001
Status: Offline
Reply With Quote
Sep 11, 2003, 03:58 AM
 
lol I was gonna add that and in fact I had -p in there but deleted it at the last second because
I feel it should not be hard coded in since it is an option after all
     
fhoubi  (op)
Senior User
Join Date: Mar 2001
Location: The Netherlands
Status: Offline
Reply With Quote
Sep 11, 2003, 12:37 PM
 
Works, terrific! Thanks a lot!
I'm-a trying to wonder, wonder, wonder why you, wonder, wonder why you act so.
     
Dedicated MacNNer
Join Date: Dec 2002
Location: someplace
Status: Offline
Reply With Quote
Sep 11, 2003, 04:27 PM
 
Bourne-shell style alias:
alias mkcd='mkdir -p $1 && cd $1'
     
   
Thread Tools
Forum Links
Forum 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
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 08:25 AM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2