question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using OS user name / git user name inside code snippets

See original GitHub issue

I’d like to add the following code snippet and share it with the whole team:

{
  "Comment todo": {
    "prefix": "//",
    "body": [
        "// TODO (${MY_NAME}) [${CURRENT_YEAR}-${CURRENT_MONTH}-${CURRENT_DATE}]: $1"
    ]
  }
}

This should produce // TODO (Alexander Kachkaev) [2018-12-07]: ... on my computer and // TODO (John Smith) [2018-12-07]: ... on John Smith’s.

Looking at VSCode snippet docs and VSCode variable reference does not suggest that there is any variable like MY_NAME. Could it be added? The value can either be taken from the OS user name or from the git user name. Similarly, there could be a variable for the current user’s email address (possibly taken from the git config).

WDYT?

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:22
  • Comments:7

github_iconTop GitHub Comments

1reaction
Gruntfugglycommented, Mar 18, 2022

If environment variables could be inserted into snippets, there would at least be a work around. Feels like it shouldn’t be a difficult update?

1reaction
azra1lcommented, Oct 16, 2020

i’d also like to use git user values (specifically author / email) to include those in my changelog snippet. if not possible/wanted with git, at least let use store those values in vscode settings and use those.

but in the long run, support for extension settings values would be neat anyways. like ${git:username} or ${myext:sourcedir}

everything else i need is already in place and that’s so awesome =)

Read more comments on GitHub >

github_iconTop Results From Across the Web

git config - How to know the git username and email saved ...
The command git config --list will list the settings. There you should also find user.name and user.email .
Read more >
How to Set Git Username and Password in GitBash?
This is how you set git username and password in git bash. To check the inputs, type the below command as depicted:
Read more >
gitcredentials Documentation - Git
Git will sometimes need credentials from the user in order to perform operations; for example, it may need to ask for a username...
Read more >
Storing username and password in Git - Unix Stack Exchange
If you want the config to be specific of a website (e.g. only for github.com, but not gitlab), you have to use git...
Read more >
How to Configure Git Username and Email Address - Linuxize
Git allows you to set a global and per-project username and email address. You can set or change your git identity using the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found