"code" Does not work on the command line for Visual Studio code on OSX / Mac

Code command. not working in this guide ?

All other steps worked before. How can I call Visual Studio code in an OSX terminal?

Monas-MacBook-Pro:myExpressApp mona$ pwd
/Users/mona/nodejs/myExpressApp
Monas-MacBook-Pro:myExpressApp mona$ code .
-bash: code: command not found

UPDATE: I ended up opening it from Visual Code Studio by changing the workspace, but I wonder why this command is “code”. won't work? enter image description here

+234
source share
19 answers

Make sure you drag the Visual Studio Code application into the -Applications- folder

Otherwise (as noted in the comments) you will have to go through this process again after rebooting


Now open the visual studio code

(⇧⌘P) shell command, :

'code' PATH **.

! [Command Palette

$ PATH , . "". , . "." " "

(: VS Code code)

+664

:

~/.bash_profile

export PATH="$PATH:/Applications/Visual Studio Code.app/Contents/Resources/app/bin"

: https://code.visualstudio.com/docs/setup/mac

+36

~/.bashrc, vi/vim $ vi ~/.bashrc

, i, :

code () { VSCODE_CWD="$PWD" open -n -b "com.microsoft.VSCode" --args $* ;}

, :wq

~/.bashrc, :

source ~/.bashrc
+16

https://code.visualstudio.com/Docs/setup

. VSCode , .bashrc

code () {
if [[ $# = 0 ]]
then
    open -a "Visual Studio Code"
else
    [[ $1 = /* ]] && F="$1" || F="$PWD/${1#./}"
    open -a "Visual Studio Code" --args "$F"
fi
}

$source ~/.bashrc

+10

, ZShell Iterm2, ~/.zshrc.

alias code="/Applications/Visual\ Studio\ Code.app/Contents/Resources/app/bin/code"
+6

"" PATH, .

, .

(⇧⌘P)

Shell Command: Uninstall 'code' command in PATH command.

.

Shell Command: Install 'code' command in PATH command.

, PATH.

+4

bash 'code', , , -, . /usr/local/bin. , .

ln -s "/Path/To/Visual Studio Code" "/usr/local/bin/code"

, , sudo , .

+3

MAC :

.bash_profile

code() {
   open -a Visual\ Studio\ Code.app $1
}

'source.bash_profile'

index.html( - ) VS-.

+3

/usr/local/bin/code . A brew :

brew cask reinstall visual-studio-code

:

/usr/local/bin/code ->
'/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code'
+2

, VS $PATH :

cat << EOF >> ~/.bash_profile
# Add Visual Studio Code (code)
export PATH="$PATH:/Applications/Visual Studio 
Code.app/Contents/Resources/app/bin"
EOF
+1

Mac OSX: Visual Studio Brew-Cask.

  1. "Homebrew" .
  2. , Visual Studio Mac.

    $> Visual-Studio-

Visual Studio, Visual Studio.

, . Microsoft Visual Studio, .

+1

:

Mac OS X. , Visual Studio. , "". , Finder. :

  • Automator . ( Spotlight).
  • " ", .
  • "" .
  • " " " ".
  • " ".
  • .
  • "Visual Studio Code.app" " ".
  • "command + s", . . . " VSCode". Automator. .

enter image description here

, :

  • Finder.
  • .
  • " VSCode".
  • " VSCode".
  • Visual Studio Code. .

enter image description here

+1

"". OSX- , https://code.visualstudio.com/Docs/setup, , ".bashrc", OSX ".profile", .

0

: Mint/Ubuntu, , vscode . . , .deb vscode.

, :

find / -name code 2>/dev/null . /extra/vscode/bin/code

mint, , :

".../ /7a22830d9e8fbbdc9627e43e072005eef66c14d2a4dd19992427ef4de060186a/..."

"/active/"

, sym:

ln -s path_you_found/extra/vscode/bin/code/usr/local/bin/code

, , .bashrc/.zshrc:

export PATH="$PATH:path_you_found/extra/vscode/bin/

, "code"

0

'code', : '/usr/local/bin'

0

Visual Studio ~/.bash_profile

export PATH = "$ PATH: /Applications/Visual Studio Code.app/Contents/Resources/app/bin"

0

VS Code , :

Launch VS Code.
Open the Command Palette (Ctrl+Shift+P) and type 'shell command' to find the Shell Command: Install 'code' command in PATH command.
macOS shell commands

, $ PATH . "". , . : .bash_profile ( ) VS, , Shell: code PATH.

VS , :

cat << EOF >> ~/.bash_profile
# Add Visual Studio Code (code)
export PATH="\$PATH:/Applications/Visual Studio Code.app/Contents/Resources/app/bin"
EOF

, .bash_profile.

. \ $ PATH . , .

0

Windows , @Inazense fooobar.com/questions/1689947/....

Visual Studio " : " " PATH.", .

  1. Open the environment variables (System> Advanced system settings> Advanced tab> environment variables) in the system variables, click "Path", click "Edit" and add a new path with the name

. "C: \ Users \ Your_username \ AppData \ Local \ Programs \ Microsoft VS Code \ bin"

Now you are done! restart the command line and try again

0
source

Source: https://habr.com/ru/post/1689948/


All Articles