Skip to main content
The 2024 Developer Survey results are live! See the results
added 49 characters in body
Source Link

To replace all calls to git with git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME, you can use a function:

git() {
  command git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME "$@"
}

However, you don’t actually have to do that for this case. Instead of passing those option flags to git, you can just specify them through environment variables instead:

export GIT_DIR=$HOME/.dotfiles/
export GIT_WORK_TREE=$HOME

See https://www.git-scm.com/docs/git#Documentation/git.txt---git-dirltpathgt


As an aside, instead of maintaining and trying to remember a large amount of aliases, you could instead just use zsh-autocomplete’s history completion mode. (Disclaimer: I’m the maintainer of this plugin.)

enter image description here

To replace all calls to git with git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME, you can use a function:

git() {
  command git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME "$@"
}

However, you don’t actually have to do that for this case. Instead of passing those option flags to git, you can just specify them through environment variables instead:

export GIT_DIR=$HOME/.dotfiles/
export GIT_WORK_TREE=$HOME

See https://www.git-scm.com/docs/git#Documentation/git.txt---git-dirltpathgt


As an aside, instead of maintaining and trying to remember a large amount of aliases, you could instead just use zsh-autocomplete’s history completion mode.

enter image description here

To replace all calls to git with git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME, you can use a function:

git() {
  command git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME "$@"
}

However, you don’t actually have to do that for this case. Instead of passing those option flags to git, you can just specify them through environment variables instead:

export GIT_DIR=$HOME/.dotfiles/
export GIT_WORK_TREE=$HOME

See https://www.git-scm.com/docs/git#Documentation/git.txt---git-dirltpathgt


As an aside, instead of maintaining and trying to remember a large amount of aliases, you could instead just use zsh-autocomplete’s history completion mode. (Disclaimer: I’m the maintainer of this plugin.)

enter image description here

added 10 characters in body
Source Link

To replace all calls to git with git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME, you can use a function:

git() {
  command git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME "$@"
}

However, you don’t actually have to do that for this case. Instead of passing those option flags to git, you can just specify them through environment variables instead:

export GIT_DIR=$HOME/.dotfiles/
export GIT_WORK_TREE=$HOME

See https://www.git-scm.com/docs/git#Documentation/git.txt---git-dirltpathgt


As an aside, instead of maintaining and trying to remember a large amount of aliases, you cancould instead just use zsh-autocomplete’s history completion mode.

enter image description here

To replace all calls to git with git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME, you can use a function:

git() {
  command git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME "$@"
}

However, you don’t actually have to do that for this case. Instead of passing those option flags to git, you can just specify them through environment variables instead:

export GIT_DIR=$HOME/.dotfiles/
export GIT_WORK_TREE=$HOME

See https://www.git-scm.com/docs/git#Documentation/git.txt---git-dirltpathgt


As an aside, instead of maintaining and trying to remember a large amount of aliases, you can just use zsh-autocomplete’s history completion mode.

enter image description here

To replace all calls to git with git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME, you can use a function:

git() {
  command git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME "$@"
}

However, you don’t actually have to do that for this case. Instead of passing those option flags to git, you can just specify them through environment variables instead:

export GIT_DIR=$HOME/.dotfiles/
export GIT_WORK_TREE=$HOME

See https://www.git-scm.com/docs/git#Documentation/git.txt---git-dirltpathgt


As an aside, instead of maintaining and trying to remember a large amount of aliases, you could instead just use zsh-autocomplete’s history completion mode.

enter image description here

added 284 characters in body
Source Link

To replace all calls to git with git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME, you can use a function:

git() {
  command git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME "$@"
}

However, you don’t actually have to do that for this case. Instead of passing those option flags to git, you can just specify them through environment variables instead:

export GIT_DIR=$HOME/.dotfiles/
export GIT_WORK_TREE=$HOME

See https://www.git-scm.com/docs/git#Documentation/git.txt---git-dirltpathgt


As an aside, instead of maintaining and trying to remember a large amount of aliases, you can just use zsh-autocomplete’s history completion mode.

enter image description here

To replace all calls to git with git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME, you can use a function:

git() {
  command git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME "$@"
}

However, you don’t actually have to do that for this case. Instead of passing those option flags to git, you can just specify them through environment variables instead:

export GIT_DIR=$HOME/.dotfiles/
export GIT_WORK_TREE=$HOME

See https://www.git-scm.com/docs/git#Documentation/git.txt---git-dirltpathgt

To replace all calls to git with git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME, you can use a function:

git() {
  command git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME "$@"
}

However, you don’t actually have to do that for this case. Instead of passing those option flags to git, you can just specify them through environment variables instead:

export GIT_DIR=$HOME/.dotfiles/
export GIT_WORK_TREE=$HOME

See https://www.git-scm.com/docs/git#Documentation/git.txt---git-dirltpathgt


As an aside, instead of maintaining and trying to remember a large amount of aliases, you can just use zsh-autocomplete’s history completion mode.

enter image description here

Source Link
Loading