Put this in your config.fish
run
code path/to/project
function code | |
set location "$PWD/$argv" | |
open -n -b "com.microsoft.VSCode" --args $location | |
end |
Added this to my ~/.config/fish/config.fish file and works like a charm. Thanks!
What problem is this solving? On Linux, code
will automatically be in your PATH when you install VS Code, and on a Mac you can Install 'code' command in PATH
via the command palette.
this wont support flags like --disable-extensions
! any solution?
better to use official launcher, it resolves relative urls
code /etc/hosts code ../hosts
https://code.visualstudio.com/docs/setup/mac#_launching-from-the-command-line
if you already have an alias named 'code', like I do, I think this is a great alternative. I don't find any option to use the official launcher under a different alias
This would be closer to the way it works in BASH and ZSH:
function code --wraps='/Applications/Visual Studio Code 2.app/Contents/Resources/app/bin/code' --description 'alias code /Applications/Visual Studio Code 2.app/Contents/Resources/app/bin/code'
/Applications/Visual\ Studio\ Code\ 2.app/Contents/Resources/app/bin/code $argv;
end
I used FISH's "alias" command to generate the function, and then I edited the function to add the escape characters for the spaces in the path.
Visual code has a new way to add code into your PATH env, if you're not already using code as a command for other thing ....
⌘
+ SHIFT
+ P
(mac) or ALT
+SHIFT
+P
(windows/linux);ENTER
;This should add code
command into your PATH
Thanks for this! Was struggling with figuring out how to pass the correct args. :)