VS Code Profiles - Know what profile you are using, no doubt
Tags: showdev, vscode, tooling, javascript
Published: 2023-05-17 09:05:00


[Profiles](https://www.roboleary.net/vscode/2023/03/29/vscode-workflow-environment-configuration-profile.html) greatly simplify managing configurations for different contexts you want to work in. One major weak point with profiles is that **it is hard to identify what profile you are using.**

## How do I know what is the current profile?

The primary means of identification is via the settings icon on the Activity Bar (the bar on the side). It has a badge with an abbreviation of the profile name.

![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.](https://www.roboleary.net/assets/img/blog/2023-05-16-vscode-what-profile-i-am-using/profile-gear-notification-status.jpg)

"TE" stands for what exactly?

The abbreviation takes the first 2 letters of the profile name. In the screenshot above, it is for my "Teaching" profile.

There are some shortcomings with this approach:
1. All profiles starting with same letters look the same. This steers you towards avoiding names that share the same 2 starting letters.
1. If you have a pending update for a new version of VS Code -- the badge loses the profile abbreviation. Instead it displays the number 1 inside.
1. When you are using the default profile -- there is no badge.
1. You may want to hide the Activity Bar. Do you keep it just for this information?

## A solution - clearly identify the current profile

My preference is to have the profile name stated as a complete word on the status bar.

![The status bar item provided by the Profile Status extension says 'Profile: Teaching'.](https://www.roboleary.net/assets/img/blog/2023-05-16-vscode-what-profile-i-am-using/profile-status-extension.jpg)

I wrote the [***Profile Status* extension**](https://marketplace.visualstudio.com/items?itemName=robole.profile-status) to do just that. **Give it a try!**

<a href="https://marketplace.visualstudio.com/items?itemName=robole.profile-status">
	<img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ypaxroyn1x7s7qtxoiaj.png" alt="The status bar item provided by the Profile Status extension says 'Profile: Teaching'.">
</a>

Also, you can click the status bar item to switch to another profile.

<video src="https://www.roboleary.net/assets/img/blog/2023-05-16-vscode-what-profile-i-am-using/demo.mp4" controls></video>

## The bones of the extension

It required some detective work to get the profile name! 🕵️

The [VS Code Extension API](https://code.visualstudio.com/api/references/vscode-api) does *not* expose the profile name. I had to go snooping in the user files produced by VS Code to dig it out. It turned out that the information is contained in a file called *globalStorage.json*.

This is the format of the data in *globalStorage.json* if you are curious:

```javascript
{
  "profileAssociations": {
    "workspaces": {
      "file:///home/rob/programming/workspace/js/vscode/vscode-profile-status": "6c702312",
      "file:///home/rob/programming/workspace/web/artifice": "__default__profile__"
    },
    "emptyWindows": {}
  },
  "userDataProfiles": [
    {
      "location": "6c702312",
      "name": "Teaching"
    }
  ]
}
```

There is a cross reference between the `profileAssociations`  and `userDataProfiles` objects to associate a profile with a workspace.

The extension will work on Windows, Linux, Mac, and as a portable installation. I don't use Windows Subsystem for Linux, but I guess that should work.

Remote development is probably not going to work as it needs to find a local system file. I don't use remote development in VS Code. You can contribute to the extension if you think you can add that as an enhancement.

## The effort required - a note for my future self

I want to make myself more accountable for side projects. In the past, I did not release much of what I built for myself. I would like to change this. However, it is important to recognize that it does take considerably more time, and it has potential to require additional time to maintain.

It took me close to a day to get a version that I could use myself on Linux. The code was sloppy and it was going to fall over if used on Windows.

It probably took 4 days worth of effort to:
- (re)write the extension to work everywhere,
- test the extension including covering different operating systems,
- create a good-looking logo and README,
- add the `alignment` setting,
- bundle extension with latest version of webpack,
- set CI/CD to publish it to the VS Code and Open VSX marketplaces,
- write this post

In general, I have to restrict myself to doing at most a project like this a once a quarter. I have to consider this a gift to an anonymous audience and expect absolutely nothing in return. 🎁

I have to weigh up starting a project if it takes me away from paid work.

## Final word

I hope that this extension can help you work with profiles in a smoother fashion. It solved a pain point for me.

I was glad to see that there is at least one more happy user, Alexander Schumacher left [the following review in the VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=robole.profile-status&ssr=false#review-details):

> perfect. just what i was looking for.
>
> i have my activity bar disabled and could not see my profile and needed to toggle the bar just for that (which was annoying).
>
> saved my day.

Saving days - thats how I roll! 🦸

Thanks for reading!