vscode: macOS Mojave: code command line generate duplicate "recently opened" icons in dock
Issue Type: Bug
$ code
$ code
$ code
VS Code version: Code 1.28.0 (431ef9da3cf88a7e164f9d33bf62695e07c6c2a9, 2018-10-04T16:40:40.180Z) OS version: Darwin x64 18.0.0 (10.14)

About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 105
- Comments: 85 (33 by maintainers)
Commits related to this issue
- Adding alias for `code` Fixes https://github.com/microsoft/vscode/issues/60579 — committed to theunraveler/dotfiles by theunraveler 2 years ago
This issue has been closed automatically because it needs more information and has not had recent activity. See also our issue reporting guidelines.
Happy Coding!
According to #62536, a temporary solution is this (for quick reference):
Looked into this a bit deeper. Calling the executable of any application from the terminal while that application is already running will result in the observed behavior, even for stock macOS apps. The solution would seem to be to rewrite
code.shso that it opens VSCode without calling the application executable or hope it gets patched in a future macOS version.The former should be possible as Sublime Text’s similar
sublcommand does not exhibit the behavior.Yes, I can confirm that this is fixed in macOS Big Sur.
This issue is about seeing multiple Code icons in the recent portion of the dock:
Only reproduces when you enable this setting:
@bpasero I’m pretty sure that’s just an optical illusion. Change your background to a non-gradient and try it again
@bpasero I have tried on 10.14.1, it still reproduces
Below script save as
codecommand, work fine for meThis issue is still reproducible on mac Os Big Sur Version 11.2.3
I can confirm the problem with a fresh install of
Mojave 10.14.3. This only happens when starting code from terminal and it’s already running, and if that option is activated in the Dock preferences (if it’s not, macOS does not add recent apps at the right of the dock so it’s not a problem of course):code --list-extensionsdoes not trigger this issue.open -b com.microsoft.VSCodedoes not trigger this issue./usr/local/bin/codedoes trigger this issue.@MikeMcQuaid’s workaround works for me:
This issue still exists:
mac mojava 1.14.5 Same problem here.
Having those multiple VS Code icons showing up in recents is helpful and we can easily switch between different opened workspaces.
It does not show the name of the workspace in the title or the active opened file, that way at-least we can distinguish between different VS Code instances.
Thank you!
And for zsh,
alias code='open -b com.microsoft.VSCode "$@"'do not work, whilealias code='open -b com.microsoft.VSCode'worked for me.Can confirm adding
alias code='open -b com.microsoft.VSCode "$@"'in.bashrcand reload terminal will work on Big Sur.Code .will no longer brings up multiple icon Not sure about Mojaveaha, I see - this problem occurs only if VS Code is launched from the command line.
Has anyone found any updated answers to this problem?
I did a slightly modified version of this workaround - because it doesn’t seem to work if you try to call
codeon a nonexistent file (in order to create said file and edit it) -+1 on macOS Mojave 10.14.6
Same problem on macOS Catalina 10.15
Could the
codescript that ships with VSCode be updated to do something similar?I’m seeing this on Mojave (yes I’ll update to Big Sur soon). I have disabled the “recent applications” area of my Dock so I only see it in the main area, which is for saved and running applications. It is triggered by running
code --wait, e.g. for interactive git operations.This workaround doesn’t work with the
--waitoption, nor does adding the-Wflag toopen.Can also reproduce on Big Sur. Reproduction steps:
code .in the Terminalcode .in the Terminal again@yiminghe It works for me:
What are you exact steps?
All the information pointing to “Show recent applications in Dock” being the issue seems to be very wrong to me. I do not, and never have, liked having that checked. Even without it, it still dupes up the VSCode icon on my dock when I type
code .in the terminal. I have tried using “alt-click, options, Remove from Dock” on the original icon, and then “alt-click, options, Keep in Dock” on the new one. That will fix it for the current terminal session, however, opening a new terminal tab and typingcode .gives me a brand new duplicate. I never get more than one extra though. I’m on Mojave 10.14.4.I’d be much more interested in finding out why it is that macOS creates separate icons for Code and fix that problem at the root. Have you tried Atom? Does it have the same issue?
@fourcels That’s good, but you lose most command line powers (–install-extension, for example).
Really no idea why this duplicate icon happens. 🤔