Skip to main content
2 of 3
quote it, since it's also used in Bash
ilkkachu
  • 147.9k
  • 16
  • 268
  • 441

There are two easy ways to fix your problem:

use pushd/popd

Just change current folder inside the default-config files and restore afterwards:

pushd ~/.dot-files/bash/
source ./.alias
source ./.prompt
source ./.zsh-git-info
source ./.git-prompt.sh
popd

Of course, your default-config files would differ in this one line.

use variable

Define a variable inside .bashrc and .zshrc. The variable will point to where your sourced files are:

# .bashr
fdir=~/.dot-files/bash
source "${fdir}/default-config"

Do the same for .zshrc

And inside the default-config can be the same for both shells, just reuse this variable:

source "${fdir}/.alias"
source "${fdir}/.prompt"
source "${fdir}/.zsh-git-info"
source "${fdir}/.git-prompt.sh"
White Owl
  • 5.3k
  • 1
  • 9
  • 16