Discussion:
DirB as in Linux Journal October 2010
Patrick Connolly
2010-09-25 06:49:50 UTC
Permalink
Has anyone tried DirB?

I read the article in Linux Journal. It took me a while to work out
that I couldn't download it from www.DirB.info/bashDirB as was stated.
What I had to do was go to www.DirB.info itself and save that text as
~/.bashDirB.

But when I tried to source that file, I get a message like this:

source ~/.bashDirB
: command not found
bash: /home/pat/.bashDirB: line 81: syntax error near unexpected token `elif'
'ash: /home/pat/.bashDirB: line 81: ` elif [ "$1" == "-" ]
17:53:41 1014>

That last line is the ballsed up command prompt. Which wouldn't be so
bad except that the cursor blinks over at the beginning of the line,
and not where one traditionally sees a prompt. It was easy enough to
deal with that by commenting out the line

PS1="\[\033]0;\w\007\]\t \!> "

There was a note in the comments to that effect (which I should have
taken as a warning) that line 18 could be commented out. But even
avoiding that problem, there's still the error message mentioned above
with line 81 which looks like this:

elif [ "$1" == "-" ]

Can somebody explain what that error message is telling us? Could it
be that something has screwed up in the process of pasting the text
from a browser window into emacs? I'm particularly puzzled by the
last line before the garbled prompt line.

Ideas gratefully accepted.
--
___ Patrick Connolly
{~._.~}
_( Y )_ Good judgment comes from experience
(:_~*~_:) Experience comes from bad judgment
(_)-(_)


_______________________________________________
NZLUG mailing list ***@linux.net.nz
http://www.linux.net.nz/cgi-bin/mailman/listinfo/nzlug
Bruce Clement
2010-09-25 07:13:58 UTC
Permalink
I suggest your next step is to double check what got downloaded by
your browser.

Mine wasn't friendly with this file. I just tried saving this file a
few minutes back and Chrome decided to name the file ~.bashDirB.html
which was just wrapping html and a badly munged copy of the script was
in ~.bashDirB_files/

I managed to get a copy on my disk by copying the page source from the
browser & pasting it into an edit window (vi .bashDirB in my case, but
use your favourite editor).

HTH

Bruce

On Sat, Sep 25, 2010 at 6:49 PM, Patrick Connolly
Post by Patrick Connolly
Has anyone tried DirB?
I read the article in Linux Journal.  It took me a while to work out
that I couldn't download it from www.DirB.info/bashDirB as was stated.
What I had to do was go to www.DirB.info itself and save that text as
~/.bashDirB.
source ~/.bashDirB
: command not found
bash: /home/pat/.bashDirB: line 81: syntax error near unexpected token `elif'
'ash: /home/pat/.bashDirB: line 81: `    elif [ "$1" == "-" ]
17:53:41 1014>
That last line is the ballsed up command prompt. Which wouldn't be so
bad except that the cursor blinks over at the beginning of the line,
and not where one traditionally sees a prompt.  It was easy enough to
deal with that by commenting out the line
PS1="\[\033]0;\w\007\]\t \!> "
There was a note in the comments to that effect (which I should have
taken as a warning) that line 18 could be commented out.  But even
avoiding that problem, there's still the error message mentioned above
   elif [ "$1" == "-" ]
Can somebody explain what that error message is telling us?  Could it
be that something has screwed up in the process of pasting the text
from a browser window into emacs?  I'm particularly puzzled by the
last line before the garbled prompt line.
Ideas gratefully accepted.
--
  ___     Patrick Connolly
 {~._.~}
 _( Y )_          Good judgment comes from experience
(:_~*~_:)         Experience comes from bad judgment
 (_)-(_)
_______________________________________________
http://www.linux.net.nz/cgi-bin/mailman/listinfo/nzlug
--
Bruce Clement

Home:    http://www.clement.co.nz/
Twitter:    http://twitter.com/Bruce_Clement
Google Buzz: http://www.google.com/profiles/aotearoanz

"Before attempting to create something new, it is vital to have a good
appreciation of everything that already exists in this field." Mikhail
Kalashnikov

_______________________________________________
NZLUG mailing list ***@linux.net.nz
http://www.linux.net.nz/cgi-bin/mailman/listinfo/nzlug
Hadley Rich
2010-09-25 07:17:33 UTC
Permalink
Post by Bruce Clement
Mine wasn't friendly with this file. I just tried saving this file a
few minutes back and Chrome decided to name the file ~.bashDirB.html
which was just wrapping html and a badly munged copy of the script was
in ~.bashDirB_files/
That's because the page is actually HTML with a frame which includes the
source from http://www.verilog.net/dirb.info/bashDirB

hads
--
http://nicegear.co.nz
New Zealand's Open Source Hardware Supplier


_______________________________________________
NZLUG mailing list ***@linux.net.nz
http://www.linux.net.nz/cgi-bin/mailman/listinfo/nzlug
Patrick Connolly
2010-09-25 07:34:42 UTC
Permalink
Somewhere about Sat, 25-Sep-2010 at 07:13PM +1200 (give or take), Bruce Clement wrote:

|> I suggest your next step is to double check what got downloaded by
|> your browser.
|>
|> Mine wasn't friendly with this file. I just tried saving this file a
|> few minutes back and Chrome decided to name the file ~.bashDirB.html
|> which was just wrapping html and a badly munged copy of the script was
|> in ~.bashDirB_files/
|>
|> I managed to get a copy on my disk by copying the page source from the
|> browser & pasting it into an edit window (vi .bashDirB in my case, but
|> use your favourite editor).

Yes, I had a similar experience and then I did the same sort of thing
with Emacs before I tried sourcing it.

Did you try sourcing it?




|>
|> HTH
|>
|> Bruce
|>
|> On Sat, Sep 25, 2010 at 6:49 PM, Patrick Connolly
|> <***@slingshot.co.nz> wrote:
|> > Has anyone tried DirB?
|> >
|> > I read the article in Linux Journal.  It took me a while to work out
|> > that I couldn't download it from www.DirB.info/bashDirB as was stated.
|> > What I had to do was go to www.DirB.info itself and save that text as
|> > ~/.bashDirB.
|> >
|> > But when I tried to source that file, I get a message like this:
|> >
|> > source ~/.bashDirB
|> > : command not found
|> > bash: /home/pat/.bashDirB: line 81: syntax error near unexpected token `elif'
|> > 'ash: /home/pat/.bashDirB: line 81: `    elif [ "$1" == "-" ]
|> > 17:53:41 1014>
|> >
|> > That last line is the ballsed up command prompt. Which wouldn't be so
|> > bad except that the cursor blinks over at the beginning of the line,
|> > and not where one traditionally sees a prompt.  It was easy enough to
|> > deal with that by commenting out the line
|> >
|> > PS1="\[\033]0;\w\007\]\t \!> "
|> >
|> > There was a note in the comments to that effect (which I should have
|> > taken as a warning) that line 18 could be commented out.  But even
|> > avoiding that problem, there's still the error message mentioned above
|> > with line 81 which looks like this:
|> >
|> >    elif [ "$1" == "-" ]
|> >
|> > Can somebody explain what that error message is telling us?  Could it
|> > be that something has screwed up in the process of pasting the text
|> > from a browser window into emacs?  I'm particularly puzzled by the
|> > last line before the garbled prompt line.
|> >
|> > Ideas gratefully accepted.
|> >
|> >
|> >
|> > --
|> >   ___     Patrick Connolly
|> >  {~._.~}
|> >  _( Y )_          Good judgment comes from experience
|> > (:_~*~_:)         Experience comes from bad judgment
|> >  (_)-(_)
|> >
|> >
|> > _______________________________________________
|> > NZLUG mailing list ***@linux.net.nz
|> > http://www.linux.net.nz/cgi-bin/mailman/listinfo/nzlug
|> >
|>
|>
|>
|> --
|> Bruce Clement
|>
|> Home:    http://www.clement.co.nz/
|> Twitter:    http://twitter.com/Bruce_Clement
|> Google Buzz: http://www.google.com/profiles/aotearoanz
|>
|> "Before attempting to create something new, it is vital to have a good
|> appreciation of everything that already exists in this field." Mikhail
|> Kalashnikov
|>
|> _______________________________________________
|> NZLUG mailing list ***@linux.net.nz
|> http://www.linux.net.nz/cgi-bin/mailman/listinfo/nzlug
--
___ Patrick Connolly
{~._.~}
_( Y )_ Good judgment comes from experience
(:_~*~_:) Experience comes from bad judgment
(_)-(_)


_______________________________________________
NZLUG mailing list ***@linux.net.nz
http://www.linux.net.nz/cgi-bin/mailman/listinfo/nzlug
Bruce Clement
2010-09-25 08:01:20 UTC
Permalink
Yes, manually and it changed my shell prompt. Looked ugly so I closed
that window ... I guess beauty is in the eye of the beholder :)



On Sat, Sep 25, 2010 at 7:34 PM, Patrick Connolly
Post by Patrick Connolly
|> I suggest your next step is to double check what got downloaded by
|> your browser.
|>
|> Mine wasn't friendly with this file. I just tried saving this file a
|> few minutes back and Chrome decided to name the file ~.bashDirB.html
|> which was just wrapping html and a badly munged copy of the script was
|> in ~.bashDirB_files/
|>
|> I managed to get a copy on my disk by copying the page source from the
|> browser & pasting it into an edit window (vi .bashDirB in my case, but
|> use your favourite editor).
Yes, I had a similar experience and then I did the same sort of thing
with Emacs before I tried sourcing it.
Did you try sourcing it?
|>
|> HTH
|>
|> Bruce
|>
|> On Sat, Sep 25, 2010 at 6:49 PM, Patrick Connolly
|> > Has anyone tried DirB?
|> >
|> > I read the article in Linux Journal.  It took me a while to work out
|> > that I couldn't download it from www.DirB.info/bashDirB as was stated.
|> > What I had to do was go to www.DirB.info itself and save that text as
|> > ~/.bashDirB.
|> >
|> >
|> > source ~/.bashDirB
|> > : command not found
|> > bash: /home/pat/.bashDirB: line 81: syntax error near unexpected token `elif'
|> > 'ash: /home/pat/.bashDirB: line 81: `    elif [ "$1" == "-" ]
|> > 17:53:41 1014>
|> >
|> > That last line is the ballsed up command prompt. Which wouldn't be so
|> > bad except that the cursor blinks over at the beginning of the line,
|> > and not where one traditionally sees a prompt.  It was easy enough to
|> > deal with that by commenting out the line
|> >
|> > PS1="\[\033]0;\w\007\]\t \!> "
|> >
|> > There was a note in the comments to that effect (which I should have
|> > taken as a warning) that line 18 could be commented out.  But even
|> > avoiding that problem, there's still the error message mentioned above
|> >
|> >    elif [ "$1" == "-" ]
|> >
|> > Can somebody explain what that error message is telling us?  Could it
|> > be that something has screwed up in the process of pasting the text
|> > from a browser window into emacs?  I'm particularly puzzled by the
|> > last line before the garbled prompt line.
|> >
|> > Ideas gratefully accepted.
|> >
|> >
|> >
|> > --
|> >   ___     Patrick Connolly
|> >  {~._.~}
|> >  _( Y )_          Good judgment comes from experience
|> > (:_~*~_:)         Experience comes from bad judgment
|> >  (_)-(_)
|> >
|> >
|> > _______________________________________________
|> > http://www.linux.net.nz/cgi-bin/mailman/listinfo/nzlug
|> >
|>
|>
|>
|> --
|> Bruce Clement
|>
|> Home:    http://www.clement.co.nz/
|> Twitter:    http://twitter.com/Bruce_Clement
|> Google Buzz: http://www.google.com/profiles/aotearoanz
|>
|> "Before attempting to create something new, it is vital to have a good
|> appreciation of everything that already exists in this field." Mikhail
|> Kalashnikov
|>
|> _______________________________________________
|> http://www.linux.net.nz/cgi-bin/mailman/listinfo/nzlug
--
  ___     Patrick Connolly
 {~._.~}
 _( Y )_          Good judgment comes from experience
(:_~*~_:)         Experience comes from bad judgment
 (_)-(_)
_______________________________________________
http://www.linux.net.nz/cgi-bin/mailman/listinfo/nzlug
--
Bruce Clement

Home:    http://www.clement.co.nz/
Twitter:    http://twitter.com/Bruce_Clement
Google Buzz: http://www.google.com/profiles/aotearoanz

"Before attempting to create something new, it is vital to have a good
appreciation of everything that already exists in this field." Mikhail
Kalashnikov

_______________________________________________
NZLUG mailing list ***@linux.net.nz
http://www.linux.net.nz/cgi-bin/mailman/listinfo/nzlug
Patrick Connolly
2010-09-25 09:11:09 UTC
Permalink
Somewhere about Sat, 25-Sep-2010 at 08:01PM +1200 (give or take), Bruce Clement wrote:

|> Yes, manually and it changed my shell prompt. Looked ugly so I closed
|> that window ... I guess beauty is in the eye of the beholder :)

My guess is that it's aimed at adding the current directory's name to
the title bar of an xterm window, but when it's a terminal window that
already has tabs for names, something gets screwed up. That theory
could easily be dismissed by someone who knows better than I.

I think I like the rest of DirB.


|>
|>
|>
|> On Sat, Sep 25, 2010 at 7:34 PM, Patrick Connolly
|> <***@slingshot.co.nz> wrote:
|> > Somewhere about Sat, 25-Sep-2010 at 07:13PM +1200 (give or take), Bruce Clement wrote:
|> >
|> > |> I suggest your next step is to double check what got downloaded by
|> > |> your browser.
|> > |>
|> > |> Mine wasn't friendly with this file. I just tried saving this file a
|> > |> few minutes back and Chrome decided to name the file ~.bashDirB.html
|> > |> which was just wrapping html and a badly munged copy of the script was
|> > |> in ~.bashDirB_files/
|> > |>
|> > |> I managed to get a copy on my disk by copying the page source from the
|> > |> browser & pasting it into an edit window (vi .bashDirB in my case, but
|> > |> use your favourite editor).
|> >
|> > Yes, I had a similar experience and then I did the same sort of thing
|> > with Emacs before I tried sourcing it.
|> >
|> > Did you try sourcing it?
|> >
|> >
|> >
|> >
|> > |>
|> > |> HTH
|> > |>
|> > |> Bruce
|> > |>
|> > |> On Sat, Sep 25, 2010 at 6:49 PM, Patrick Connolly
|> > |> <***@slingshot.co.nz> wrote:
|> > |> > Has anyone tried DirB?
|> > |> >
|> > |> > I read the article in Linux Journal.  It took me a while to work out
|> > |> > that I couldn't download it from www.DirB.info/bashDirB as was stated.
|> > |> > What I had to do was go to www.DirB.info itself and save that text as
|> > |> > ~/.bashDirB.
|> > |> >
|> > |> > But when I tried to source that file, I get a message like this:
|> > |> >
|> > |> > source ~/.bashDirB
|> > |> > : command not found
|> > |> > bash: /home/pat/.bashDirB: line 81: syntax error near unexpected token `elif'
|> > |> > 'ash: /home/pat/.bashDirB: line 81: `    elif [ "$1" == "-" ]
|> > |> > 17:53:41 1014>
|> > |> >
|> > |> > That last line is the ballsed up command prompt. Which wouldn't be so
|> > |> > bad except that the cursor blinks over at the beginning of the line,
|> > |> > and not where one traditionally sees a prompt.  It was easy enough to
|> > |> > deal with that by commenting out the line
|> > |> >
|> > |> > PS1="\[\033]0;\w\007\]\t \!> "
|> > |> >
|> > |> > There was a note in the comments to that effect (which I should have
|> > |> > taken as a warning) that line 18 could be commented out.  But even
|> > |> > avoiding that problem, there's still the error message mentioned above
|> > |> > with line 81 which looks like this:
|> > |> >
|> > |> >    elif [ "$1" == "-" ]
|> > |> >
|> > |> > Can somebody explain what that error message is telling us?  Could it
|> > |> > be that something has screwed up in the process of pasting the text
|> > |> > from a browser window into emacs?  I'm particularly puzzled by the
|> > |> > last line before the garbled prompt line.
|> > |> >
|> > |> > Ideas gratefully accepted.
|> > |> >
|> > |> >
|> > |> >
|> > |> > --
|> > |> >   ___     Patrick Connolly
|> > |> >  {~._.~}
|> > |> >  _( Y )_          Good judgment comes from experience
|> > |> > (:_~*~_:)         Experience comes from bad judgment
|> > |> >  (_)-(_)
|> > |> >
|> > |> >
|> > |> > _______________________________________________
|> > |> > NZLUG mailing list ***@linux.net.nz
|> > |> > http://www.linux.net.nz/cgi-bin/mailman/listinfo/nzlug
|> > |> >
|> > |>
|> > |>
|> > |>
|> > |> --
|> > |> Bruce Clement
|> > |>
|> > |> Home:    http://www.clement.co.nz/
|> > |> Twitter:    http://twitter.com/Bruce_Clement
|> > |> Google Buzz: http://www.google.com/profiles/aotearoanz
|> > |>
|> > |> "Before attempting to create something new, it is vital to have a good
|> > |> appreciation of everything that already exists in this field." Mikhail
|> > |> Kalashnikov
|> > |>
|> > |> _______________________________________________
|> > |> NZLUG mailing list ***@linux.net.nz
|> > |> http://www.linux.net.nz/cgi-bin/mailman/listinfo/nzlug
|> >
|> > --
|> >   ___     Patrick Connolly
|> >  {~._.~}
|> >  _( Y )_          Good judgment comes from experience
|> > (:_~*~_:)         Experience comes from bad judgment
|> >  (_)-(_)
|> >
|> >
|> > _______________________________________________
|> > NZLUG mailing list ***@linux.net.nz
|> > http://www.linux.net.nz/cgi-bin/mailman/listinfo/nzlug
|> >
|>
|>
|>
|> --
|> Bruce Clement
|>
|> Home:    http://www.clement.co.nz/
|> Twitter:    http://twitter.com/Bruce_Clement
|> Google Buzz: http://www.google.com/profiles/aotearoanz
|>
|> "Before attempting to create something new, it is vital to have a good
|> appreciation of everything that already exists in this field." Mikhail
|> Kalashnikov
|>
|> _______________________________________________
|> NZLUG mailing list ***@linux.net.nz
|> http://www.linux.net.nz/cgi-bin/mailman/listinfo/nzlug
--
___ Patrick Connolly
{~._.~}
_( Y )_ Good judgment comes from experience
(:_~*~_:) Experience comes from bad judgment
(_)-(_)


_______________________________________________
NZLUG mailing list ***@linux.net.nz
http://www.linux.net.nz/cgi-bin/mailman/listinfo/nzlug
Robin Sheat
2010-09-25 09:48:36 UTC
Permalink
Post by Patrick Connolly
I think I like the rest of DirB.
It's a bit different, but there is also the $CDPATH variable, that
automatically includes the subdirs of the directories listed in it as options
when you 'cd'. I use that for some things.

Robin.
Patrick Connolly
2010-09-25 08:14:09 UTC
Permalink
Somewhere about Sat, 25-Sep-2010 at 07:13PM +1200 (give or take),
Bruce Clement wrote:

|> I suggest your next step is to double check what got downloaded by
|> your browser.
|>
|> Mine wasn't friendly with this file. I just tried saving this file a
|> few minutes back and Chrome decided to name the file ~.bashDirB.html
|> which was just wrapping html and a badly munged copy of the script was
|> in ~.bashDirB_files/
|>
|> I managed to get a copy on my disk by copying the page source from the
|> browser & pasting it into an edit window (vi .bashDirB in my case, but
|> use your favourite editor).


My favourite editor is Emacs, but it seems to have tried to do
something too clever. It sees to have gotten the idea that it was a
DOS file when I pasted the text into it.

So I tried nano instead and that seems to have solved that problem
(after I commented out that line 18).

Looks pretty cool (except I had an alias for g which screwed things up
a bit).

best
--
___ Patrick Connolly
{~._.~}
_( Y )_ Good judgment comes from experience
(:_~*~_:) Experience comes from bad judgment
(_)-(_)


_______________________________________________
NZLUG mailing list ***@linux.net.nz
http://www.linux.net.nz/cgi-bin/mailman/listinfo/nzlug
Martin D Kealey
2010-09-27 06:54:15 UTC
Permalink
I had a look, and while the functionality is cool, the implementation is
rather clunky.

The main problem, its notion of how to store the tags is not well
thought-out: it creates little mini scripts, with the target directory
embedded in them, which would be fine if all you want to do is run the
scripts, and if it was done properly.

As a result, it needs to escape shell metacharacters, but it only escapes
spaces in directory names, and nothing else, so if you have any shell
metacharacters in your directory name, you're screwed. It also means that
anything other than changing to the directory it rather complicated.

A cleaner (and therefore much briefer) approach would be to use a directory
full of symlinks:

DirB=$HOME/.dirB
mkdir -m700 -p $DirB
[[ :$CDPATH: = *:$DirB:* ]] || CDPATH=$DirB:$CDPATH

function _DirB_tag_ok() { [[ -n $1 && $1 != .* && $1 != */* ]] ; }

function _DirB_save() {
_DirB_tag_ok "$1" &&
(
d="$HOME/.dirB/$1" ; shift # tag name
(($#)) && cd "$@" # path, if given
[[ ! -h "$d" ]] || rm -f "$d" # remove old tag
ln -sf "$(pwd -P)" "$d" # create new tag
)
}

function _DirB_remove() {
_DirB_tag_ok "$1" && rm -f "$HOME/.dirB/$1"
}

function _DirB_list() {
ls -lrt "$DirB"
}

alias g='cd -P'
alias p='pushd -P'
alias r=_DirB_remove
alias s=_DirB_save
alias sl=_DirB_list

Hmmm, have I missed any functionality?

-Martin

_______________________________________________
NZLUG mailing list ***@linux.net.nz
http://www.linux.net.nz/cgi-bin/mailman/listinfo/nzlug

Robin Sheat
2010-09-25 08:16:03 UTC
Permalink
Post by Patrick Connolly
Has anyone tried DirB?
Just now. Saved the file at www.DirB.info/bashDirB to /tmp/dirb.sh and removed
the prompt changing line:

***@dagobert:/tmp$ . ./dirb.sh
***@dagobert:/tmp$ cd
***@dagobert:~$ cd Documenten/
***@dagobert:~/Documenten$ s docs
***@dagobert:~/Documenten$ cd /tmp
***@dagobert:/tmp$ g docs
***@dagobert:~/Documenten$

Looks like it works fine.

Robin.
Loading...