13

I have made a some bookmarks in Nautilus, i.e. shortcut links to some directories.

I would like to cd to a directory which has been bookmarked in Nautilus. I was wondering if that is possible?

2
  • Do you really want the bookmarks, or do you want mounted network locations?
    – jordanm
    Mar 8, 2013 at 21:44
  • The bookmarks point to some directories on my local file system. THere is no network involved.
    – Tim
    Mar 8, 2013 at 21:54

3 Answers 3

21

Nautilus saves its bookmarks in a file named .gtk-bookmarks in your home (from Ubuntu 13.04 on, it's located in .config/gtk-3.0/bookmarks). The bookmarks are stored in clear text, one bookmark per line. With a bit of shell scripting it should be possible to parse the file and configure your shell to allow something like: cd somebookmarkname.

1
  • 3
    add this to your shell's startup files (bash, zsh and similar): function cdbm { cd $(grep $1 ~/.gtk-bookmarks | awk '-F//' '{print $2}') }
    – SuperMagic
    Mar 8, 2013 at 23:04
2

Old thread, but in case it helps someone, the helpful comment by @SuperMagic didn't work for me in ksh, so instead I put this in .kshrc:

function cdbm { 
   ENTRY=$(grep "$1" $HOME/.config/gtk-3.0/bookmarks) 
   DIR=$(echo "$ENTRY" | sed 's|file://||g' | cut -d' ' -f1)
   cd $DIR
}
1
  • This also works in bash (./bashrc). Nov 10, 2017 at 7:03
0

As others have mentioned, you can access Nautilus bookmarks at ${HOME}/.config/gtk-3.0/bookmarks with the format file://${PATH}. However, this is the wrong approach for what you are trying to do. Simply create a BASH/ZSH variable or alias for the paths in your RC file so that they are automatically loaded. If you want to write a script, write one that automatically populates your RC file with data from your bookmarks file:

$ awk -F 'file://' '{ split($2, i, "/"); print i[4] "=" "\""$2"\""; }' "${HOME}/.config/gtk-3.0/bookmarks" | tee -a "${HOME}/.bashrc"

$ cat "${HOME}/.bashrc"
Documents="${HOME}/Documents"
Music="${HOME}/Music"
Pictures="${HOME}/Pictures"
Videos="${HOME}/Videos"
Downloads="${HOME}/Downloads"

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .