Skip to main content
added 180 characters in body
Source Link
Stéphane Chazelas
  • 584.6k
  • 96
  • 1.1k
  • 1.7k

There are two easy ways to fix your problem:

use pushd/popd

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

if pushd ~/.dot-files/bash/ > /dev/null; then
  source ./.alias
  source ./.prompt
  source ./.zsh-git-info
  source ./.git-prompt.sh
  popd > /dev/null
fi

(in zsh, you can use -q instead of redirecting stdout to /dev/null to avoid the dump of the directory stack, but not in bash).

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:

# .bashrbashrc
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"

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"

There are two easy ways to fix your problem:

use pushd/popd

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

if pushd ~/.dot-files/bash/ > /dev/null; then
  source ./.alias
  source ./.prompt
  source ./.zsh-git-info
  source ./.git-prompt.sh
  popd > /dev/null
fi

(in zsh, you can use -q instead of redirecting stdout to /dev/null to avoid the dump of the directory stack, but not in bash).

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:

# .bashrc
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"
quote it, since it's also used in Bash
Source Link
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-configconfig"

Do the same for .zshrc

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

source $"${fdir}/.aliasalias"
source $"${fdir}/.promptprompt"
source $"${fdir}/.zsh-git-infoinfo"
source $"${fdir}/.git-prompt.shsh"

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

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"
Source Link
White Owl
  • 5.3k
  • 1
  • 9
  • 16

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