Cookie Consent by Free Privacy Policy Generator ๐Ÿ“Œ VS Code - Custom workflows and project configuration with profiles

๐Ÿ  Team IT Security News ist eine Online-Plattform, die sich auf die Bereitstellung von Informationen,alle 15 Minuten neuste Nachrichten, Bildungsressourcen und Dienstleistungen rund um das Thema IT-Sicherheit spezialisiert hat.
Ob es sich um aktuelle Nachrichten, Fachartikel, Blogbeitrรคge, Webinare, Tutorials, oder Tipps & Tricks handelt, bietet seinen Nutzern einen umfassenden รœberblick รผber die wichtigsten Aspekte der IT-Sicherheit in einer sich stรคndig verรคndernden digitalen Welt.

16.12.2023 - TIP: Wer den Cookie Consent Banner akzeptiert, kann z.B. von Englisch nach Deutsch รผbersetzen, erst Englisch auswรคhlen dann wieder Deutsch!

Google Android Playstore Download Button fรผr Team IT Security

๐Ÿ“š VS Code - Custom workflows and project configuration with profiles

๐Ÿ’ก Newskategorie: Programmierung
๐Ÿ”— Quelle:

Have you ever wanted a custom setup in VS Code for a particular workflow or environment?

Well, you're in luck! Today, I will show you how to do this inside VS Code with profiles. โœจ

Profiles were added to VS Code in February 2023 (v1.7.6). Previously, people did this configuration outside of VS Code and had to do some command-line wrangling to make their own system. For example, Joe Previte created a teaching workflow for his egghead courses. This method can get messy if you are not careful! โš™๏ธ๐Ÿค•โš™๏ธ

What is a profile?

Profiles enable a user to save a configuration set including ui state,settings, and extensions. It can capture preferences that can help you switch between contexts. You can switch between profiles easily. ๐Ÿ”„

Profiles can be synced across machines. You can export them and share them with colleagues to coordinate your work.

This was a missing piece of the setup for VS Code for a long time in my opinion.

What can a profile include?

A profile can include:

  • UI state: View layout, visible views, and actions.
  • Settings: A profile-specific settings.json file.
  • Extensions: You can add or remove extensions from a profile.
  • Keybindings: A profile-specific keybindings.json file is created.
  • Snippets: A profile-specific <<language>>.json file is created.
  • User Tasks: A profile-specific tasks.json file is created.

When a profile is created, it is creating a separate set of configuration files. It creates a folder in your user configuration folder named after your profile. Depending on your platform, the folder will be located in:

  • Windows: %APPDATA%\Code\User/profiles
  • MacOS: $HOME/Library/Application/Support/Code/User/profiles
  • Linux: $HOME/.config/Code/User/profiles

Use cases for profiles

The primary use case is for work modes, in my opinion. If you find yourself doing a particular type of work, you could benefit from this. Activity such as demonstrations, screencasting, reviewing pull requests, or writing docs have different requirements.

A secondary use case is for particular environments. If you have a fullstack project, it may be useful to have a frontend and backend profile to switch to a different UI layout and have certain actions more prominently available. Maybe you want your Ruby on Rails projects to be set-up differently than other Ruby projects.

I would issue some caution with creating profiles for languages and frameworks that you use, you could quickly get into a habit of overspecializing. Remember, it is possible to have language-specific settings in your global settings file! If some configuration is tied to a language, it may be better to put the configuration in there. I spoke about this in a previous article, Customize your VS Code setup for a project, or for a language if you want to learn more about that. It is something that people often are not familiar with.

A good rule of thumb is to only create a profile if you find yourself wanting to have the same configuration between projects, and it is not tied to a particular language.

One exception to the rule of thumb is that some extensions can always be loaded and you may not want this. This is not common because extensions are conditionally loaded, usually only when they are needed. It is usually only extensible extensions such as linters that are always loaded because they can be configured to be used by more languages or file types. I spoke about this in a previous article, VS Code - How many extensions should I use? if you want to learn more about the topic.

If you want tighter control, a profile can gives you that power. I would try to avoid micromanaging though!

Creaing a "Teaching" profile

Let's return to Joe Previte's "Teaching" workflow that he created outside of VS Code. It should be instructive (pardon the pun) to do this with a profile, and compare my efforts and the outcome with what Joe did. Joe made his custom configuration in 5 steps. Let's see how we fare!

Essentially, we want a minimal configuration. We want to be close to stock installation to be as simple and distraction-free as possible for students. We want to make text bigger and hide the minimap. We will have a short set of settings like so:

    "editor.fontSize": 18,
    "terminal.integrated.fontSize": 16,
    "window.zoomLevel": 1.25,
    "editor.minimap.enabled": false

You have 3 choices for creating a profile:

  1. Create a profile based on the current profile with the command Profiles: Create from Current Profiles. This is a duplicated copy of your current configuration.
  2. Create an empty profile with the command Profiles: Create Empty Profile... This is like a clean slate.
  3. Create a temporary profile with the command Profiles: Create Temporary Profile. A temporary profile is useful for experimentation. It creates an empty profile with an automatically generated name such as Temp 1. You can use the profile for the lifetime of your VS Code session. It will be deleted once you close VS Code.

Before we create a new profile, let me show you my default configuration for reference. Below is a screenshot of editing a markdown file, this post, with my current config.

Editing a markdown file with my current config

We will create an empty profile because we want to start from zero.

Open the Command Palette ([[Ctrl]]+[[Shift]]+[[P]]) and run the Create Empty Profile.. command. You will be promoted for a name. I will name the profile as "Teaching".

You will see the UI flash and we are now in our new profile.

Editing a markdown file with the new teaching profile active

Everything looks different now because we have reverted back to the base settings!

VS Code identifies the current custom profile by showing the first two letters of the profile name as a badge on the gear icon on the sidebar. This is the Manage Activity item according to the VS Code docs. It is positioned at the bottom of the sidebar by default, I have circled it in yellow in the screenshot below.

Highlighting the profile badge on the manage activity item on the sidebar. Since I am using my Teaching profile, it has the text 'TE' in the badge.

You can see "TE" for my teaching profile.

The profile badge on the manage activity item. It features the first 2 letters of the profile you are using. It has the text 'TE' in the badge since I am using the Teaching profile.

Let's edit our profile by changing the settings. Run the command Preferences: Open Current Profile Settings (JSON) to open the settings.json for the "Teaching" profile. Paste in the aforementioned settings and save. You will see the text increase in size and everything is zoomed in now.

My teaching profile configuration with settings changed to increase the size of everything.

Mission accomplished for our simple use case! ๐Ÿ™Œ

We did it in just 2 steps! Although, Joe uses the command-line for opening a project with his configuration. You can do this too without any extra effort!

If you want to open a project direct from the command-line with your "Teaching" profile, you can use the code command with the --profile option. You supply the name of the profile as an argument, just like this:

# open a project with a profile
code ~/projects/teaching/website-tutorial --profile "Teaching"

Switching profiles

You can quickly switch between profiles with the Profiles: Switch Profile command. The command will presents a dropdown listing your available profiles. Pick one and it will change your configuration.

Switching profile in VS Code through the 'Profiles: Switch Profile' command. The dropdown shows the profiles to choose from. In my case, it is: default and teaching.

The current profile is associated with the current workspace. When you open that folder again, it will open with the profile from your last session.

Editing a profile

One thing to keep in mind when you want to edit the settings of a profile is that there are multiple settings.json files. There is: default, user, current profile, and project. There is a command for each of these in the command palette.

There are 4 setting.json files that you can edit. The screenshot show the 4 command options from the command palette dropdown filtered by the text 'settings jso'.

Make sure you run the Preferences: Open Current Profile Settings (JSON) command to open the settings.json for the current profile. If you are in your default profile, you will not see this command in the list.

You can open the profiles view to review the customizations for a profile with the Profiles: Show Contents command.

Profile view of teaching profile. This is opened with the 'profiles:show contents' command.

Since I only edited the setteing, my "Teaching" profile has just Settings and UI State listed. You will see entries for keybindings, tasks, and extensions listed here if you customised them!

If you expand the UI State node, there is a globalState.json entry. This is an in-memory JSON representation of your profile's UI State. This file does not actually exist on disk. Just in case you were wondering -- I wondered!

You can rename an existing profile via the Profiles: Rename.. command in the Profiles menu.

You can delete a profile via the Profiles: Delete command.

You can import and export profiles with the Profiles: Import.. and Profiles: Export.. commands respectively. A profile can be exported as a GitHub gist or as file. If you chose to save the profile as a local file, a Save Profile dialog lets you place the file on your local machine. A profile is persisted in a file with the extension .code-profile.

Syncing profiles

You can use the builtin Settings Sync feature to use your profiles across machines.

To add profiles to your sync, run the Settings Sync: Configure command. A drop down will appear showing configuration items to include in the sync, check the Profiles item.

'Settings Sync: Configure' command dropdown with all configuration items selected to be synced such as: Settings, Keyboard Shortcuts, User Snippets, and so on.

Don't forget to enable syncing, otherwise nothing will be synced! ๐Ÿ˜‰

Final thoughts

Profiles are a great addition to VS Code and can help you tailor your editor experience to work in different contexts and environments. You no longer need to go outside VS Code to create your own configuration sets. The editor integration means you can switch between contexts with ease, and benefit from other builtin features such as syncing and sharing. That's a signficant win in my book!

Further reading


๐Ÿ“Œ ๐ŸŸข GitHub Workflows reimagined - A visual node system for GitHub workflows

๐Ÿ“ˆ 30.13 Punkte

๐Ÿ“Œ ๐ŸŸข GitHub Workflows reimagined - A visual node system for GitHub workflows

๐Ÿ“ˆ 30.13 Punkte

๐Ÿ“Œ CircleCI Visual Configuration Editor allows teams to visualize and streamline complex workflows

๐Ÿ“ˆ 26.13 Punkte

๐Ÿ“Œ iMazing Profile Editor 1.7.4 - Create, Edit, and Sign Apple Configuration Profiles.

๐Ÿ“ˆ 25.45 Punkte

๐Ÿ“Œ CVE-2015-7062 | Apple Mac OS X up to 10.11.1 Configuration Profiles access control (HT205637 / BID-78733)

๐Ÿ“ˆ 23.55 Punkte

๐Ÿ“Œ Improve Host Lifecycle Management With vSphere Configuration Profiles | Breakroom Chats Episode 16

๐Ÿ“ˆ 23.55 Punkte

๐Ÿ“Œ Simplifying Microsoft Edge configuration profiles for Jamf Pro

๐Ÿ“ˆ 23.55 Punkte

๐Ÿ“Œ Configuration as Code Plugin up to 1.24 on Jenkins Configuration Import Environment Variable information disclosure

๐Ÿ“ˆ 22.36 Punkte

๐Ÿ“Œ Code Churn: An Analysis of Troublesome Workflows and Possible Countermeasures

๐Ÿ“ˆ 21 Punkte

๐Ÿ“Œ power-profiles-daemon: new project announcement

๐Ÿ“ˆ 20.55 Punkte

๐Ÿ“Œ ProfileGrid โ€“ User Profiles, Groups and Communities <= 2.8.5 - Authenticated Code Execution

๐Ÿ“ˆ 20.31 Punkte

๐Ÿ“Œ Stop us if you've heard this one: Facebook and Twitter profiles silently slurped by shady code

๐Ÿ“ˆ 20.31 Punkte

๐Ÿ“Œ Which of the most popular DEs (GNOME, KDE, xfce, other?) has the best support for configuration management and/or declarative configuration

๐Ÿ“ˆ 20.23 Punkte

๐Ÿ“Œ CVE-2023-28677 | Convert To Pipeline Plugin up to 1.0 on Jenkins Freestyle Project Configuration code injection

๐Ÿ“ˆ 19.36 Punkte

๐Ÿ“Œ Red Hat OpenShift, a foundation for building AI and ML workflows and AI-powered intelligent apps

๐Ÿ“ˆ 18.87 Punkte

๐Ÿ“Œ Armorblox Vendor and Supply Chain Attack Protection monitors vendors and business workflows

๐Ÿ“ˆ 18.87 Punkte

๐Ÿ“Œ Integrate apps and workflows with Google Meet APIs and SDKs

๐Ÿ“ˆ 18.87 Punkte

๐Ÿ“Œ [PRODSECBUG-2262] Arbitrary code execution by importing malicious dataflow profiles - CVE-2019-7884

๐Ÿ“ˆ 18.41 Punkte

๐Ÿ“Œ Azure App Configuration - Making Centralized Configuration Easy

๐Ÿ“ˆ 18.33 Punkte

๐Ÿ“Œ Piwigo 2.9.2 Configuration admin/configuration.php order_by sql injection

๐Ÿ“ˆ 18.33 Punkte

๐Ÿ“Œ Samba up to 4.9.12/4.10.7/4.11.0rc2 Configuration Configuration File directory traversal

๐Ÿ“ˆ 18.33 Punkte

๐Ÿ“Œ Huawei Honor 20 Pro Configuration Parameter configuration buffer overflow

๐Ÿ“ˆ 18.33 Punkte

๐Ÿ“Œ VoIPmonitor up to 24.60 Configuration config/configuration.php SPOOLDIR injection

๐Ÿ“ˆ 18.33 Punkte

๐Ÿ“Œ CVE-2022-38664 | Job Configuration History Plugin up to 1165.v8cc9fd1f4597 on Jenkins System Configuration History Page cross site scripting

๐Ÿ“ˆ 18.33 Punkte

๐Ÿ“Œ Piwigo 2.9.2 Configuration admin/configuration.php order_by SQL Injection

๐Ÿ“ˆ 18.33 Punkte

๐Ÿ“Œ Redesigning Configuration Refresh for Azure App Configuration

๐Ÿ“ˆ 18.33 Punkte

๐Ÿ“Œ CVE-2019-2965 | Oracle Siebel Core - DB Deployment/Configuration up to 19.8 Install Configuration information disclosure

๐Ÿ“ˆ 18.33 Punkte

๐Ÿ“Œ Identifying a Person Based on a Photo, LinkedIn and Etsy Profiles, and Other Internet Bread Crumbs

๐Ÿ“ˆ 18.19 Punkte

๐Ÿ“Œ Terminal FM nnn v2.7 released! A massive update with simplified workflows, image, video thumbnails, previews and more...

๐Ÿ“ˆ 16.97 Punkte

๐Ÿ“Œ ServiceNow, Qualtrics partner, aim to meld sentiment data and workflows

๐Ÿ“ˆ 16.97 Punkte