<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Quick Bash Tip : Directory Bookmarks</title>
	<atom:link href="http://www.huyng.com/archives/quick-bash-tip-directory-bookmarks/492/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.huyng.com/archives/quick-bash-tip-directory-bookmarks/492/</link>
	<description></description>
	<lastBuildDate>Mon, 16 Aug 2010 10:05:24 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Velko</title>
		<link>http://www.huyng.com/archives/quick-bash-tip-directory-bookmarks/492/comment-page-1/#comment-2744</link>
		<dc:creator>Velko</dc:creator>
		<pubDate>Sat, 19 Jun 2010 11:31:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.huyng.com/?p=492#comment-2744</guid>
		<description>Great Job!

Putting &quot;mdump&quot; or its source code in ~/.bash_logout did not work.

So after little testing adding mdump to the m1-9 commands solves it.

Enjoy.

I like the simplicity of it - with the numbers from 1-9.

INSTALL instructions:
- put into ~/bin/bookmarks or sth.
- source it from ~/.bashrc - add &quot;. ~/bin/bookmarks&quot;
USAGE:
- use m1-9, g1-9 and lma. 
- sing/hum some nice melody


#!/bin/bash
# Bash Directory Bookmarks
alias mdump=&#039;alias&#124;grep -e &quot;alias g[0-9]&quot;&#124;grep -v &quot;alias m&quot; &gt; ~/.bookmarks&#039;
alias lma=&#039;alias &#124; grep -e &quot;alias g[0-9]&quot;&#124;grep -v &quot;alias m&quot;&#124;sed &quot;s/alias //&quot;&#039;
alias m1=&#039;alias g1=&quot;cd `pwd`&quot;; mdump&#039;
alias m2=&#039;alias g2=&quot;cd `pwd`&quot;; mdump&#039;
alias m3=&#039;alias g3=&quot;cd `pwd`&quot;; mdump&#039;
alias m4=&#039;alias g4=&quot;cd `pwd`&quot;; mdump&#039;
alias m5=&#039;alias g5=&quot;cd `pwd`&quot;; mdump&#039;
alias m6=&#039;alias g6=&quot;cd `pwd`&quot;; mdump&#039;
alias m7=&#039;alias g7=&quot;cd `pwd`&quot;; mdump&#039;
alias m8=&#039;alias g8=&quot;cd `pwd`&quot;; mdump&#039;
alias m9=&#039;alias g9=&quot;cd `pwd`&quot;; mdump&#039;
touch ~/.bookmarks
source ~/.bookmarks</description>
		<content:encoded><![CDATA[<p>Great Job!</p>
<p>Putting &#8220;mdump&#8221; or its source code in ~/.bash_logout did not work.</p>
<p>So after little testing adding mdump to the m1-9 commands solves it.</p>
<p>Enjoy.</p>
<p>I like the simplicity of it &#8211; with the numbers from 1-9.</p>
<p>INSTALL instructions:<br />
- put into ~/bin/bookmarks or sth.<br />
- source it from ~/.bashrc &#8211; add &#8220;. ~/bin/bookmarks&#8221;<br />
USAGE:<br />
- use m1-9, g1-9 and lma.<br />
- sing/hum some nice melody</p>
<p>#!/bin/bash<br />
# Bash Directory Bookmarks<br />
alias mdump=&#8217;alias|grep -e &#8220;alias g[0-9]&#8220;|grep -v &#8220;alias m&#8221; &gt; ~/.bookmarks&#8217;<br />
alias lma=&#8217;alias | grep -e &#8220;alias g[0-9]&#8220;|grep -v &#8220;alias m&#8221;|sed &#8220;s/alias //&#8221;&#8216;<br />
alias m1=&#8217;alias g1=&#8221;cd `pwd`&#8221;; mdump&#8217;<br />
alias m2=&#8217;alias g2=&#8221;cd `pwd`&#8221;; mdump&#8217;<br />
alias m3=&#8217;alias g3=&#8221;cd `pwd`&#8221;; mdump&#8217;<br />
alias m4=&#8217;alias g4=&#8221;cd `pwd`&#8221;; mdump&#8217;<br />
alias m5=&#8217;alias g5=&#8221;cd `pwd`&#8221;; mdump&#8217;<br />
alias m6=&#8217;alias g6=&#8221;cd `pwd`&#8221;; mdump&#8217;<br />
alias m7=&#8217;alias g7=&#8221;cd `pwd`&#8221;; mdump&#8217;<br />
alias m8=&#8217;alias g8=&#8221;cd `pwd`&#8221;; mdump&#8217;<br />
alias m9=&#8217;alias g9=&#8221;cd `pwd`&#8221;; mdump&#8217;<br />
touch ~/.bookmarks<br />
source ~/.bookmarks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sham</title>
		<link>http://www.huyng.com/archives/quick-bash-tip-directory-bookmarks/492/comment-page-1/#comment-2411</link>
		<dc:creator>Sham</dc:creator>
		<pubDate>Sun, 07 Mar 2010 18:18:57 +0000</pubDate>
		<guid isPermaLink="false">http://www.huyng.com/?p=492#comment-2411</guid>
		<description>In zsh alias does not print alias g1 but just g1. Ugly hack to get it to print this (i am new to grep, awk, zsh) so please fix the ugly ugly mdump and lma lines!

#ZSH Directory Bookmarks
alias m1=&#039;alias g1=&quot;cd `pwd`&quot;&#039;
alias m2=&#039;alias g2=&quot;cd `pwd`&quot;&#039;
alias m3=&#039;alias g3=&quot;cd `pwd`&quot;&#039;
alias m4=&#039;alias g4=&quot;cd `pwd`&quot;&#039;
alias m5=&#039;alias g5=&quot;cd `pwd`&quot;&#039;
alias m6=&#039;alias g6=&quot;cd `pwd`&quot;&#039;
alias m7=&#039;alias g7=&quot;cd `pwd`&quot;&#039;
alias m8=&#039;alias g8=&quot;cd `pwd`&quot;&#039;
alias m9=&#039;alias g9=&quot;cd `pwd`&quot;&#039;

alias mdump=&#039;alias &#124; grep -e &quot;g[0-9]=&quot; &#124; grep -v &quot;m[0-9]&quot; &#124; awk &#039;\&#039;&#039;{ print &quot;alias &quot; $1 &quot; &quot; $2 }&#039;\&#039;&#039; &#124; cat &gt; ~/.bookmarks&#039;

alias lma=&#039;alias &#124; grep -e &quot;g[0-9]=&quot; &#124; grep -v &quot;m[0-9]&quot; &#124; awk &#039;\&#039;&#039;{ print &quot;alias &quot; $1 &quot; &quot; $2 }&#039;\&#039;&#039;&#039;

touch ~/.bookmarks
source ~/.bookmarks</description>
		<content:encoded><![CDATA[<p>In zsh alias does not print alias g1 but just g1. Ugly hack to get it to print this (i am new to grep, awk, zsh) so please fix the ugly ugly mdump and lma lines!</p>
<p>#ZSH Directory Bookmarks<br />
alias m1=&#8217;alias g1=&#8221;cd `pwd`&#8221;&#8216;<br />
alias m2=&#8217;alias g2=&#8221;cd `pwd`&#8221;&#8216;<br />
alias m3=&#8217;alias g3=&#8221;cd `pwd`&#8221;&#8216;<br />
alias m4=&#8217;alias g4=&#8221;cd `pwd`&#8221;&#8216;<br />
alias m5=&#8217;alias g5=&#8221;cd `pwd`&#8221;&#8216;<br />
alias m6=&#8217;alias g6=&#8221;cd `pwd`&#8221;&#8216;<br />
alias m7=&#8217;alias g7=&#8221;cd `pwd`&#8221;&#8216;<br />
alias m8=&#8217;alias g8=&#8221;cd `pwd`&#8221;&#8216;<br />
alias m9=&#8217;alias g9=&#8221;cd `pwd`&#8221;&#8216;</p>
<p>alias mdump=&#8217;alias | grep -e &#8220;g[0-9]=&#8221; | grep -v &#8220;m[0-9]&#8221; | awk &#8216;\&#8221;{ print &#8220;alias &#8221; $1 &#8221; &#8221; $2 }&#8217;\&#8221; | cat &gt; ~/.bookmarks&#8217;</p>
<p>alias lma=&#8217;alias | grep -e &#8220;g[0-9]=&#8221; | grep -v &#8220;m[0-9]&#8221; | awk &#8216;\&#8221;{ print &#8220;alias &#8221; $1 &#8221; &#8221; $2 }&#8217;\&#8221;&#8217;</p>
<p>touch ~/.bookmarks<br />
source ~/.bookmarks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Huy</title>
		<link>http://www.huyng.com/archives/quick-bash-tip-directory-bookmarks/492/comment-page-1/#comment-2302</link>
		<dc:creator>Huy</dc:creator>
		<pubDate>Thu, 11 Feb 2010 04:52:01 +0000</pubDate>
		<guid isPermaLink="false">http://www.huyng.com/?p=492#comment-2302</guid>
		<description>Karthick, 
Amazing !  This is way better than my implementation. The snippet below adds tab completion to your script.

&lt;code&gt;

# enable custom tab completion
shopt -s progcomp

# jump to bookmark
function g {
   source ~/.sdirs
   cd $(eval $(echo echo $(echo \$DIR_$1)))
}


# list bookmarks without dirname
function _l {
   source ~/.sdirs
   env &#124; grep &quot;^DIR_&quot; &#124; cut -c5- &#124; grep &quot;^.*=&quot; &#124; cut -f1 -d &quot;=&quot;
}

# completion command for g
function _gcomp {
    local curw
    COMPREPLY=()
    curw=${COMP_WORDS[COMP_CWORD]}
    COMPREPLY=($(compgen -W &#039;`_l`&#039; -- $curw))
    return 0
}

# bind completion command for g to _gcomp
complete -F _gcomp g

# Usage: g [TAB]

&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>Karthick,<br />
Amazing !  This is way better than my implementation. The snippet below adds tab completion to your script.</p>
<p><code></p>
<p># enable custom tab completion<br />
shopt -s progcomp</p>
<p># jump to bookmark<br />
function g {<br />
   source ~/.sdirs<br />
   cd $(eval $(echo echo $(echo \$DIR_$1)))<br />
}</p>
<p># list bookmarks without dirname<br />
function _l {<br />
   source ~/.sdirs<br />
   env | grep "^DIR_" | cut -c5- | grep "^.*=" | cut -f1 -d "="<br />
}</p>
<p># completion command for g<br />
function _gcomp {<br />
    local curw<br />
    COMPREPLY=()<br />
    curw=${COMP_WORDS[COMP_CWORD]}<br />
    COMPREPLY=($(compgen -W '`_l`' -- $curw))<br />
    return 0<br />
}</p>
<p># bind completion command for g to _gcomp<br />
complete -F _gcomp g</p>
<p># Usage: g [TAB]</p>
<p></code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Karthick</title>
		<link>http://www.huyng.com/archives/quick-bash-tip-directory-bookmarks/492/comment-page-1/#comment-2289</link>
		<dc:creator>Karthick</dc:creator>
		<pubDate>Wed, 10 Feb 2010 15:03:22 +0000</pubDate>
		<guid isPermaLink="false">http://www.huyng.com/?p=492#comment-2289</guid>
		<description>Btw, it is also possible to use TAB completion on bookmark names using compgen/complete in bash.. so doing something like:
$ g my
should complete to
$ g mybookmarkname</description>
		<content:encoded><![CDATA[<p>Btw, it is also possible to use TAB completion on bookmark names using compgen/complete in bash.. so doing something like:<br />
$ g my<br />
should complete to<br />
$ g mybookmarkname</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Karthick</title>
		<link>http://www.huyng.com/archives/quick-bash-tip-directory-bookmarks/492/comment-page-1/#comment-2279</link>
		<dc:creator>Karthick</dc:creator>
		<pubDate>Wed, 10 Feb 2010 13:45:43 +0000</pubDate>
		<guid isPermaLink="false">http://www.huyng.com/?p=492#comment-2279</guid>
		<description>I did the following to give descriptive bookmark names:

&lt;code&gt;
function s {
   cat ~/.sdirs &#124; grep -v &quot;export DIR_$1=&quot; &gt; ~/.sdirs1
   mv ~/.sdirs1 ~/.sdirs
   echo &quot;export DIR_$1=$PWD&quot; &gt;&gt; ~/.sdirs
}

function g {
   source ~/.sdirs
   cd $(eval $(echo echo $(echo \$DIR_$1)))
}

function l {
   source ~/.sdirs
   env &#124; grep &quot;^DIR_&quot; &#124; cut -c5- &#124; grep &quot;^.*=&quot;
}
&lt;/code&gt;

Mnemonics:
s - Save directory (argument is a shorthand bookmark name)
g - Go to directory
l - List saved directories

Usage:
$ cd /foo/bar/some/dir
$ s mybookmarkname

...
In an other shell:
$ l
mybookmarkname=/foo/bar/some/dir
$ g mybookmarkname
should take you to /foo/bar/some/dir

Obviously you&#039;ll use far less characters than the 14 used in &quot;mybookmarkname&quot;..

Incidentally, it is also ok to leave the bookmark name..
$ cd /foo/bar/some/dir
$ s

...
In an other shell:
$ l
=/foo/bar/some/dir
$ g
should take you to /foo/bar/some/dir</description>
		<content:encoded><![CDATA[<p>I did the following to give descriptive bookmark names:</p>
<p><code><br />
function s {<br />
   cat ~/.sdirs | grep -v "export DIR_$1=" &gt; ~/.sdirs1<br />
   mv ~/.sdirs1 ~/.sdirs<br />
   echo "export DIR_$1=$PWD" &gt;&gt; ~/.sdirs<br />
}</p>
<p>function g {<br />
   source ~/.sdirs<br />
   cd $(eval $(echo echo $(echo \$DIR_$1)))<br />
}</p>
<p>function l {<br />
   source ~/.sdirs<br />
   env | grep "^DIR_" | cut -c5- | grep "^.*="<br />
}<br />
</code></p>
<p>Mnemonics:<br />
s &#8211; Save directory (argument is a shorthand bookmark name)<br />
g &#8211; Go to directory<br />
l &#8211; List saved directories</p>
<p>Usage:<br />
$ cd /foo/bar/some/dir<br />
$ s mybookmarkname</p>
<p>&#8230;<br />
In an other shell:<br />
$ l<br />
mybookmarkname=/foo/bar/some/dir<br />
$ g mybookmarkname<br />
should take you to /foo/bar/some/dir</p>
<p>Obviously you&#8217;ll use far less characters than the 14 used in &#8220;mybookmarkname&#8221;..</p>
<p>Incidentally, it is also ok to leave the bookmark name..<br />
$ cd /foo/bar/some/dir<br />
$ s</p>
<p>&#8230;<br />
In an other shell:<br />
$ l<br />
=/foo/bar/some/dir<br />
$ g<br />
should take you to /foo/bar/some/dir</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Huy</title>
		<link>http://www.huyng.com/archives/quick-bash-tip-directory-bookmarks/492/comment-page-1/#comment-1111</link>
		<dc:creator>Huy</dc:creator>
		<pubDate>Fri, 11 Sep 2009 17:27:36 +0000</pubDate>
		<guid isPermaLink="false">http://www.huyng.com/?p=492#comment-1111</guid>
		<description>ubersoldat, yes I have a similar alias &quot;lma&quot;  that is used for listing the bookmarks.</description>
		<content:encoded><![CDATA[<p>ubersoldat, yes I have a similar alias &#8220;lma&#8221;  that is used for listing the bookmarks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: gof</title>
		<link>http://www.huyng.com/archives/quick-bash-tip-directory-bookmarks/492/comment-page-1/#comment-1109</link>
		<dc:creator>gof</dc:creator>
		<pubDate>Fri, 11 Sep 2009 12:19:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.huyng.com/?p=492#comment-1109</guid>
		<description>Very nice!  Think I will use this today!</description>
		<content:encoded><![CDATA[<p>Very nice!  Think I will use this today!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ubersoldat</title>
		<link>http://www.huyng.com/archives/quick-bash-tip-directory-bookmarks/492/comment-page-1/#comment-1108</link>
		<dc:creator>ubersoldat</dc:creator>
		<pubDate>Fri, 11 Sep 2009 11:35:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.huyng.com/?p=492#comment-1108</guid>
		<description>Hi

You could also find useful listing your bookmarks:

alias favs=&#039;alias&#124;grep -e &quot;alias g[0-9]&quot;&#124;grep -v &quot;alias m&quot;</description>
		<content:encoded><![CDATA[<p>Hi</p>
<p>You could also find useful listing your bookmarks:</p>
<p>alias favs=&#8217;alias|grep -e &#8220;alias g[0-9]&#8220;|grep -v &#8220;alias m&#8221;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Huy</title>
		<link>http://www.huyng.com/archives/quick-bash-tip-directory-bookmarks/492/comment-page-1/#comment-1105</link>
		<dc:creator>Huy</dc:creator>
		<pubDate>Fri, 11 Sep 2009 04:54:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.huyng.com/?p=492#comment-1105</guid>
		<description>Good idea. I just added it to my bash_logout</description>
		<content:encoded><![CDATA[<p>Good idea. I just added it to my bash_logout</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark</title>
		<link>http://www.huyng.com/archives/quick-bash-tip-directory-bookmarks/492/comment-page-1/#comment-1104</link>
		<dc:creator>Mark</dc:creator>
		<pubDate>Fri, 11 Sep 2009 02:05:43 +0000</pubDate>
		<guid isPermaLink="false">http://www.huyng.com/?p=492#comment-1104</guid>
		<description>I created a similar .bat script for windows.
Mine is d.bat

To add an alias to the current directory you type &#039;d &#039;.
And then to go to that directory it is the same command.

An additional feature I have is it adds each alias as an environment variable prefixed with &#039;d-&#039;. You can then use those as parameters for other commands.

eg.
C:\Windows&gt; d win
d-win=C:\Windows
C:\Windows&gt; cd /d F:\test
F:\test&gt; d test
d-test=F:\test
F:\test&gt; d win
C:\Windows&gt; copy *.* %d-test%</description>
		<content:encoded><![CDATA[<p>I created a similar .bat script for windows.<br />
Mine is d.bat</p>
<p>To add an alias to the current directory you type &#8216;d &#8216;.<br />
And then to go to that directory it is the same command.</p>
<p>An additional feature I have is it adds each alias as an environment variable prefixed with &#8216;d-&#8217;. You can then use those as parameters for other commands.</p>
<p>eg.<br />
C:\Windows&gt; d win<br />
d-win=C:\Windows<br />
C:\Windows&gt; cd /d F:\test<br />
F:\test&gt; d test<br />
d-test=F:\test<br />
F:\test&gt; d win<br />
C:\Windows&gt; copy *.* %d-test%</p>
]]></content:encoded>
	</item>
</channel>
</rss>
