loading...

re: Bash: How To Teleport In The Terminal VIEW POST

FULL DISCUSSION
 

Supercharge your cd command with something like this:

function goto() { eval "$(~/bin/goto "$@")"; clear; ls; }

Then in ~/bin/goto you can put extended logic that will find where you want to go, for example

#!/bin/bash
GO() {
  if test -d "$1" ; then
    echo "builtin cd $1";
    exit 0;
  fi
}

case "$1" in
somehost) echo "ssh adf@somehost.somedomain.com" ; exit 0 ;;
work) echo "builtin cd /path/to/work/Projects"; exit 0 ;;
esac

GO "$HOME/$1"
GO "/d/dev/$1"
GO "/c/GAMES/$1"

exit 0

Finally, if you prefer to use cd rather than goto add an extra alias:

alias cd=goto

Example Usage:

cd somehost
cd myproject
code of conduct - report abuse