/
tip-create-and-move-to-directory.html
70 lines (65 loc) · 2.71 KB
/
tip-create-and-move-to-directory.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="chrome=1" />
<meta name="viewport" content="width=device-width, minimum-scale=1.0" />
<link rel="stylesheet" href="/css/style-c5940180f1eee87aee88f035a95023ac.css" type="text/css" />
<link rel="alternate" type="application/atom+xml" href="http://tomafro.net/atom.xml" />
<link rel="canonical" href="http://tomafro.net/2009/08/tip-create-and-move-to-directory"/>
<script type="text/javascript" src="http://use.typekit.com/brv6igt.js"></script>
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
<title>Tip: Create and move to directory · tomafro.net</title>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-1103395-2']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script');
ga.src = ('https:' == document.location.protocol ? 'https://ssl' :
'http://www') + '.google-analytics.com/ga.js';
ga.setAttribute('async', 'true');
document.documentElement.firstChild.appendChild(ga);
})();
</script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<body>
<nav>
<ul>
<li><a href='/'>tomafro.net</a><span class='byline'>, a blog by Tom Ward</span></li>
<li><a href='/about'>about</a></li>
<li><a href='https://github.com/tomafro'>github</a></li>
<li><a href='https://twitter.com/tomafro'>twitter</a></li>
</ul>
</nav>
<article>
<header>
<h1><a href="/2009/08/tip-create-and-move-to-directory">Tip: Create and move to directory</a></h1>
</header>
<div class="content">
<p>Before my next post on database indexes, here's a useful little function from the <a href="http://peepcode.com/products/advanced-command-line">Advanced Command Line peepcode screencast</a> (which I highly recommend).:</p>
<div class="highlight"><pre><span class="c"># Create and move to a directory in a single command</span>
<span class="c"># Usage: take ~/Projects/tools/awesometer</span>
take<span class="o">()</span> <span class="o">{</span>
mkdir -p <span class="nv">$1</span>
<span class="nb">cd</span> <span class="nv">$1</span>
<span class="o">}</span>
</pre>
</div>
</div>
<footer>
<span class='author'><a rel='author' href='http://tomafro.net'>Tom Ward</a></span>
<span class='date'><a href="/2009/08">12th August 2009</a></span>
<ul>
<li><a href="/tags/tiny" rel="tag">tiny</a></li>
<li><a href="/tags/tip" rel="tag">tip</a></li>
<li><a href="/tags/zsh" rel="tag">zsh</a></li>
<li><a href="/tags/peepcode" rel="tag">peepcode</a></li>
</ul>
</footer>
</article>
</body>
</html>