Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save JAlbertoGonzalez/1cd25f9a2d8ed0e78c036a0e4b6f5b82 to your computer and use it in GitHub Desktop.

Select an option

Save JAlbertoGonzalez/1cd25f9a2d8ed0e78c036a0e4b6f5b82 to your computer and use it in GitHub Desktop.
“Open in Visual Studio Code” in macOS context-menu

Open in Visual Studio Code

Una vez instalado VSCode en Windows se registra en el menú contextual (click derecho) de cualquier fichero o directorio la opción "Open with Visual Code". Pero esto no ocurre en Mac. Para disponer de esta opción en Mac hay que:

  • Abrir Automator

  • Crear nuevo documento

  • Selecciona Acción Rápida

  • Pon “el flujo de trabajo recibe el actual” con el valor archivos o carpetas en cualquier aplicación

  • Añade la acción Ejecutar script de shell

    • Tu terminal por defecto estará ya seleccionada, sino usa /bin/zsh para macOS 10.15 ("Catalina") o superior
    • Versiones antiguas de MacOS usan /bin/bash
    • Si usas cualquier otro, probablemente ya sabes qué hacer 😉
  • Escribe el siguiente script

    for f in "$@"; do
      open -a 'Visual Studio Code' "$@"
    done
    
  • Pon "Pasar datos de entrada" a "como argumentos".

  • Guarda (Command + S) como Open in Visual Studio Code

Atajos de teclado

Puedes asignar atajos de teclado para ejecutar los servicios que acabas de crear

  • Open “System Preferences”
  • Select “Keyboard” then the “Shortcuts” tab
  • In the left pane, click on “Services”
  • In the right pane, scroll to “Files and Folders”
  • Select “Open in Visual Studio Code” click “add shortcut”
  • Select a shortcut

Edit Context Menu items

Si quieres poner otro nombre/texto a los elementos que acabas de crear:

  • Activate Finder
  • Click on “Finder” in the Apple menu, select “Services” then “Services Preferences”
  • In the right pane, scroll to “Files and Folders” and scroll to the item you want to edit
  • Right click the item and select “Open in Visual Studio Code”
  • Edit and save

Alternatively, you can edit the workflow (e.g. ~/Library/Services/Open in Visual Studio Code.workflow) in your preferred text editor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment