1

I have a script called gd and it's in a folder on my PATH, when trying to run it, I noticed it wasn't doing what it was supposed to. Then I tried type gd and it shows:

gd is an alias for git diff

I don't believe I set this alias, and I do not see it in my ~/.zshrc, is there a way to figure out where this alias is being set and remove it?

Edit:

Also I am on a Mac if that changes things

Edit 2:

So for now I just added a new alias to the bottom of my ~/.zshrc called gd that points to my script which is now overriding the other alias... though I'd still like to know where that alias is coming from

Quinn
  • 7,072
  • 7
  • 39
  • 61
  • ...that said, _in general_, for whichever shell you use, running it with `set -x` or the local equivalent to trace operations via startup is the right place to start for your current goal. – Charles Duffy Sep 18 '20 at 17:38
  • @CharlesDuffy I thought zsh may be checking certain bash files, it is also a bash script I'm trying to run just in a zsh shell so I thought the tag was okay – Quinn Sep 18 '20 at 17:38
  • _In general_, for whichever shell you use, running it with `set -x` or the local equivalent to trace operations via startup is the right place to start for your current goal. So, for bash, someone would run `PS4=':${BASH_SOURCE}:$LINENO+' bash -x -l -i` to start an interactive shell that logs its startup, showing each line that's run and which file that line of code came from. But for zsh that PS4 would need to be different, and I'm not the right person to tell you what it would be. – Charles Duffy Sep 18 '20 at 17:39
  • Maybe Apple's stock zsh _does_ check some dotfiles that are shared with bash, but only a person who's a zsh expert -- not a bash expert -- would know that; so the folks the bash tag pulls in aren't the right people to answer your question. – Charles Duffy Sep 18 '20 at 17:39
  • 1
    (Also, more generally, questions about interactive shell configuration are generally a better fit for our sister site [unix.se], which doesn't have the "unique to software development" requirement present here). – Charles Duffy Sep 18 '20 at 17:42
  • @CharlesDuffy well I just removed the bash tag – Quinn Sep 18 '20 at 17:45
  • @CharlesDuffy okay, I will ask it there – Quinn Sep 18 '20 at 17:46
  • 1
    Have you tried using `zsh -x -l -i`? You'll need to find a different PS4 to get the filenames and line numbers, but seeing the commands that are run should still give you a pretty good clue, just in terms of knowing what happens before and after the alias is set. – Charles Duffy Sep 18 '20 at 17:46
  • ...I suspect that `PS4=':${(%):-%x}+' zsh -x -l -i` might be the right thing, based on https://stackoverflow.com/questions/60782870, but that's very much a guess. – Charles Duffy Sep 18 '20 at 17:48
  • @CharlesDuffy thanks, `zsh -x -l -i` helped me find it, it was from a git plugin that I have enabled in my .zshrc – Quinn Sep 18 '20 at 17:58

0 Answers0