4

I use ZSH with Oh My Zsh and I am trying to define a function called git, as such:

function git() { echo "I'm happy because I am executed!" }

I have placed the function definition in $ZSH/custom/general.zsh.

Everything else in this file works (I have a bunch of aliases there) except this function.

Running which git outputs:

git () {
    case $1 in
        (commit|blame|add|log|rebase|merge) exec_scmb_expand_args "$_git_cmd" "$@" ;;
        (checkout|diff|rm|reset) exec_scmb_expand_args --relative "$_git_cmd" "$@" ;;
        (branch) _scmb_git_branch_shortcuts "${@:2}" ;;
        (*) "$_git_cmd" "$@" ;;
    esac
}

Removing git from plugins=( ... ) didn't work. Trying to find this function in Oh My Zsh yielded no results.

I read the source code of oh-my-zsh.sh, and it seems the custom directory is loaded after all of OMZ's files, so it didn't make any sense to me, that when I placed my function at the bottom of .zshrc it worked.

Any Ideas on how to keep the function in the custom folder? I would like to keep things organized.

2
  • Have you started a new login shell after you update the code?
    – number5
    Oct 29, 2013 at 2:02
  • Of course, I run ~ $ source .zshrc && git after each change.
    – wildeyes
    Oct 29, 2013 at 12:43

1 Answer 1

1

You probably installed scm_breeze, and my theory is that in your .zshrc the sourcing of scm_breeze.sh is preceeded by oh-my-zsh.sh. And if you put your git function definition at the very end of .zshrc, then you probably exceed the scm_breeze.sh, so that's the reason why it works.

  1. Try to move the line that sources oh-my-zsh.sh to the very end of your .zshrc or at least in a position where it exceeds the sourcing of scm_breeze.sh. Restart zsh and see if it works. (alternatively you can remove scm_breeze.sh completely)

  2. If it still doesn't work, then back up your .zshrc and all your oh-my-zsh stuffs, then create an empty .zshrc, delete and reinstall oh-my-zsh with curl -L https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh | sh and then put function git() { echo "I'm happy because I am executed!" } in $ZSH/custom/general.zs, I have tested this, it worked for me. After that you can gradually reapply your former settings, step-by-step checking what exactly breaks your configuration.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .