Go to gtk bookmarks in your shell

Gnome (I mean the FileChooser, Nautilus, etc) supports for a few time Bookmarks/Places. You can go back to your favorite folders in a single click. Very usefull in Gedit for example.

But when you’re in your shell ? I use a lot the Ctrl+R search in my zsh history, but it’s a bit tiring to search always the same thing.

First step : a small ruby script to find the wanted path in the gtk boorkmark.

Second step : because a script can’t change the current path of your shell, a function called by an alias is needed. Under zsh, you can make it like that (into your .zshrc) :

function go_impl() {
  target_name=$1
  target=`go-path $target_name`

  if [ -d "$target" ]; then
    cd $target
  else
    echo "target not found : $target_name" 2>&1
  fi
}

alias go='go_impl'

And then ?

[hyppo:~] go freecast
[hyppo:..g/freecast/trunk]

:-)

For the moment, I didn’t manage to setup the zsh completion … The following code :

function go_targets { reply=(`go-path --all`); }
compctl -K go_targets go

… doesn’t nothing

Tags: , , , , , ,

Leave a Reply