Or you might just use ZSH (particularly in combination with oh-my-zsh), keep the marks around as zsh vars and skip all the symbolic linkage.
Quickly navigate your filesystem from the command line
11–20 of 148 posts
this way they would all be lost at the end of each session, and would not be shared across concurrent sessions, no?
Re: Quickly navigate your filesystem from the command line
#12I had to modify Jeroen's code to get the `marks` shortcut working under Mac OS 10.8:
export MARKPATH=$HOME/.marks
function jump {
cd -P $MARKPATH/$1 2> /dev/null || echo "No such mark: $1"
}
function mark {
mkdir -p $MARKPATH; ln -s $(pwd) $MARKPATH/$1
}
function unmark {
rm -i $MARKPATH/$1
}
function marks {
ls -l $MARKPATH | sed 's/ / /g' | cut -d' ' -f9- && echo
}Re: Quickly navigate your filesystem from the command line
#13A handy alias I use:
alias ..='cd ..'
Moving up the file tree has never been easier!Re: Quickly navigate your filesystem from the command line
#14 brew install fasd
Thank me laterRe: Quickly navigate your filesystem from the command line
#15A handy alias I use: alias ..='cd ..' Moving up the file tree has never been easier!
Put the following in your .bashrc instead:
shopt -s autocd
If you type a directory in the command-line, it’ll cd into it, e.g.: $ .. # cd ..
$ ~ # cd ~
$ foo # cd foo
I can’t live without this.Re: Quickly navigate your filesystem from the command line
#16You can also use ranger [1] to change directories, especially if you want to explore the directory tree quickly when you don't know exactly where to jump to. Install it and add the following to ~/.bashrc:
function ranger-cd {
tempfile='/tmp/chosendir'
/usr/bin/ranger --choosedir="$tempfile" "${@:-$(pwd)}"
test -f "$tempfile" &&
if [ "$(cat -- "$tempfile")" != "$(echo -n `pwd`)" ]; then
cd -- "$(cat "$tempfile")"
fi
rm -f -- "$tempfile"
}
# This binds Ctrl-O to ranger-cd:
bind '"\C-o":"ranger-cd\C-m"'
(This script comes from the man page for ranger(1).)Edit: Modified the above script for use with zsh (and multiple users):
ranger-cd() {
tempfile=$(mktemp)
ranger --choosedir="$tempfile" "${@:-$(pwd)}"
[1] http://ranger.nongnu.org/.Re: Quickly navigate your filesystem from the command line
#17Interesting idea. I've the bash built-in "pushd" and "popd" for a long time for similar reasons, but those effectively limit you to treating the history as a stack rather than an arbitrary list.
Re: Quickly navigate your filesystem from the command line
#18I'm too lazy to type "jump" so I've modified it to automatically add a Bash alias for each one as well.
https://github.com/davejamesmiller/dotfiles/blob/master/.bas...
Re: Quickly navigate your filesystem from the command line
#19A handy alias I use: alias ..='cd ..' Moving up the file tree has never been easier!
Put the following in your .bashrc instead: shopt -s autocd If you type a directory in the command-line, it’ll cd into it, e.g.: $ .. # cd .. $ ~ # cd ~ $ foo # cd foo I can’t live without this.
Very cool, thanks! Although:
On OS X: "-bash: shopt: autocd: invalid shell option name"
Apple and their outdated tools... It gets annoying after a while.
Re: Quickly navigate your filesystem from the command line
#20I found this is a useful addition to his scripts... I can't live without my tab completion!
_jump()
{
local cur=${COMP_WORDS[COMP_CWORD]}
COMPREPLY=( $(compgen -W "$( ls $MARKPATH )" -- $cur) )
}
complete -F _jump jump