Add a “New file” to the Windows 10 Context Menu

Have you ever thought that life would be made easier and more productive if you had a quick way of creating a file at your fingertips?

Windows has always been very picky about file extensions, and non-standard Microsoft file types can be a pain to create quickly, but there’s a neat trick to add these to the “New” menu.

First you need to open up the Windows Registry Editor application and expand HKEY_CLASSES_ROOT

Within this list, you will need to search for your desired file extension.

In my case, I want to add Python files to the Context Menu. I will need to find a folder in this list named .py as this is the file extension used for python files.

Similarly, if you wanted to quickly create a new html file, you would look for .html

You will need to add a new Key named : ShellNew.
Right click on your desired file extension and click New -> Key.
Name it : ShellNew

You should now see a new “Folder” called ShellNew:

The last step will be to add a new String Value to the ShellNew key, named NullFile.
Right Click on ShellNew : New -> String Value

Name this : NullFile.
Your Registry Editor should now look something like this:

You can now check your Context Menu to see if your changes worked!

Enjoy your productivity!

Linux vs Windows: Python Virtualenv

Although Virtualenv is available on both Linux and Windows, there are some differences that you may find useful to understand.

Is there a difference to creating virtualenvs?

No, creating virtualenvs in Windows and Linux is exactly the same.

Can I use the same venv folder on both systems?

No. You will need to create 2 separate virtual environments. I suggest creating folders named winvenv and linvenv to tell them apart. You will have access to the same packages through pip, although you will need to use pip freeze if you wanted to replicate the packages exactly.

Do I activate the venvs in the same way?

No, but you CAN activate, and the differences are subtle. After creating the virtualenv, follow these steps:

Windows

\winvenv\Scripts> activate

Navigate to Scripts within the venv root. Type activate to use your venv in the current prompt

Linux

$ source linvenv/bin/activate

In the terminal, type source followed by the path to /bin/activate within the viretualenv folder

Windows, VS Code, Git and SSH Authentication with passphrases

Have you spent the past several hours frantically searching the web for a solution of integrating Git with VSCode? Are you tempted to remove passphrases from your SSH Key just to get around Permission denied (publickey) errors every time you try and clone a repo?

Yes, it is disappointing that there is no clear documentation for this.
Hopefully, this will fill the gap.

Pre-requisites

Windows 10
Git installed
VSCode installed
Created an SSH key using the Git terminal and is passphrase protected.
Added your SSH public key to your chosen Git Service.

Solution

Before starting VSCode, open up a new Windows CMD window.
Enter the command: start-ssh-agent and you will be prompted to provide the passphrase to your SSH Key.

cmd start-ssh-agent
start-ssh-agent

Now you will be able to open VSCode and clone into your repository.

Automation

If you wanted to automate start-ssh-agent and open VSCode at the same time, I have built a batch script that will do just this.

Open text editor and paste in the code below. Save file as VSCode_ssh-agent.bat

I decided to place this file in my Windows home directory. On the Desktop, I created a shortcut to the .bat file and set the icon to point to:

C:\Users\[USER]\AppData\Local\Programs\Microsoft VS Code\Code.exe

The final result:

  1. Check if SSH-AGENT is running.
    If not, start SSH-AGENT and ask for the passphrase for your key.
  2. Start VSCode