blob: 68aed0ba775987b4ac6a8f6750b026c27adf35ec (
plain)
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
|
---
date: "2003-11-06T19:20:55Z"
title: cdup Fun!
---
<p>
<a href='http://www.richlowe.net/'>Richard (richlowe)</a> and a few other people from <code>#fu</code> were talking about being able to do things like <kbd>cdup 5</kbd> to jump up 5 directories. I thought it would be nicer if my existing <kbd>..</kbd> alias took an optional argument to do the same thing. Here's the result (for bash):
</p>
<p>
<pre>
function cdup() {
if [ "x$1" = "x" ]; then max=1; else max=$1; fi
for ((i=0; i<$max; i++)); do cd ..; done
}
alias ..="cdup";
</pre>
</p>
<p>
So <kbd>..</kbd> works the same as it did before, but now you can do stuff like this:
</p>
<p>
<pre>
pabs@vault:/usr/local/share/raggle/themes> ..
pabs@vault:/usr/local/share/raggle> .. 2
pabs@vault:/usr/local>
</pre>
</p>
<p>
<a href='http://www.richlowe.net/cdup.zsh'>Richard's version</a> does the same thing for <a href='http://www.zsh.org/'>zsh</a>.
</p>
|