i realized this via direnv and a shell script what is called via an alias
~/folder_a/.envrc
export GO_TO_DIR="./subdir_a"
~/folder_b/.envrc
export GO_TO_DIR="~/another_dir"
my go_to.sh
#!/bin/sh
value="${GO_TO_DIR}"
if [ -z $value ]
then
exit 0
fi
cd $value
don't forget to make this file executeable
chmod u+x /path/to/script/go_to.sh
now i've set an alias to this script in my ~/.bashrc and ~/.zshrc and it works
alias goto="sh /path/to/script/go_to.sh"
bonus:
i can sat a global env to change to a standard destination until it is overwritten with the directory specific env
if no env is defined, nothing will happen
__
a second way to execute thewithout a script is to change the alias directly test if the env exists
alias goto='sh -c "if [ ! -z ${GO_TO_DIR} ]; then cd ${GO_TO_DIR}; fi;"'