A couple of days ago I read a very cool blog post by Scott Hanselman about Monospaced Programming Fonts with Ligatures.

I had never heard about the word ligatures, but he explains it quite well. They are ‘characters’ which are made up by combining multiple individual characters as one. Apparently this is quite common in the Arabic languages. Well, no matter, the thing that does matter is the fact you can use this inside your development environment also!

In order to use ligatures, just install the Fira Code font (or any other font which supports ligatures) on your development machine and you are ready to go! It might be a good idea to place the zip file in your OneDrive folder, so it’s available on all of your machines.

Visual Studio automatically supports ligatures, you just have to select a font which has them. So, head down to the Fonts and Colors setting and change the Plain Text font to `Fira Code Retina`.

image

Note, I had to use the `Fira Code Retina` font. I first tried the `Fira Code` font, but I didn’t see any ligatures pop up. There aren’t many differences between the non-retina and the retina version, so just use the one which works best for you.

After configuring this you will be able to see the ligatures be automatically applied to your codebase (restarting Visual Studio may be required)

image image imageimage

Keep in mind, this is just a representation of characters. Your actual code doesn’t change!

For Visual Studio Code you have to enable ligatures specifically. Change the following settings in your User Settings file.

    "editor.fontFamily": "'Fira Code Retina', Consolas",
    "editor.fontLigatures": true

After saving the file you should see the changes directly. If not, restart Code also.

image

Pretty slick, right?


Are there any other font suggestions I might have to look at? I’m currently quite happy with Fira Code, but open to other great suggestions!


Sidenote: people wondering which color scheme I’m using in Visual Studio, it’s theXamarin Studio style.

The past couple of days I’ve had the pleasure to start using a Git server as the new version control system at my customer. I’ve already had the pleasure to use GitHub and BitBucket in the past, which works like a charm with tools like GitHub for Windows and SourceTree. Because I’m used to using these tools, I really wanted to use them on my day job also.

Because we chose to use SSH keys as a validation mechanism I had to create one. Once you know how to do this it’s quite easy, but till 2 days ago I didn’t had a clue.

Lucky for me there’s a nice tutorial on how to create SSH keys on the GitHub help pages. Also Atlassian has provided an extensive help document with a couple of steps. In retrospect I think the Atlassian help page is the most useful for helping out with local Git servers. However, these help documents don’t take into account the usage of SourceTree and you will need to do some extra steps to get this working.

For future reference, I’ll describe the steps I had to take below.

First thing you want to do is install Git, the Git Extensions and if you haven’t already, SourceTree.

After doing so you can start Git Bash from the Windows context menu in Windows Explorer.

image

By default your SSH keys are stored in the ~/.ssh directory. For Windows users, the ~-sign means your home directory, so C:\Users\Jan\.ssh

To create a new SSH key you can type the following in Git Bash.

ssh-keygen -t rsa -C "your_email@example.com"

After running this command, the tool will ask you for a filename to save the SSH key in. I didn’t go with the default name because I thought it would probably be wise to use a different SSH key for every customer I’m working with. Also because I will probably use different e-mail addresses per customer. So I went for id_rsa_customer.

The tool will also prompt you for entering a passphrase. If you want to be secure, please do provide a passphrase over here. I didn’t (it also accepts blanks), because you have to provide this passphrase every time you want to do something with the server (pull, push) via the Git Bash. My solution might not be very secure, so I will not advise in doing the same.

Your new SSH private key will now be created in the .ssh folder on your system.

Now you have to add this new SSH key to the SSH Agent of your system. In Git Bash you can do this by executing the following command.

ssh-agent -s
ssh-add ~/.ssh/id_rsa_customer

This works some of the times, but not always. Next time I started Git Bash I received an error when adding the key to the SSH Agent, “Could not open a connection to your authentication agent.

A Stack Overflow post helped me out here. If this also happens to you, you have to execute the following

eval `ssh-agent -s`
ssh-add ~/.ssh/id_rsa_customer

This will make sure the SSH agent is started. On the Stack Overflow post’s answer are a couple of links which provide some more in-depth detail about this issue.

Once you are done setting up your private key and the SSH agent, it’s time to get the public key which you will be able to add on your account on the Git server.

The public key is saved in a file on the same location as the private key, but has the extension .pub added to it. In my case it’s id_rsa_customer.pub. Copy this key to the clipboard like so:

clip < ~/.ssh/id_rsa.pub

Or open it in your favorite text editor and copy it from over there. Now add this key to your profile and you are set to start using Git via Git Bash.

Next time you’ll start Git Bash you will have to add the private key to the SSH agent again. This isn’t very user friendly and there’s also a way around this. The Atlassian help page (step 5) provides a script which can help you out.

Create (or modify) a .bashrc file in your user director (~/ or C:\Users\[username]\).

Add the following to the file via your favorite text editor.

SSH_ENV=$HOME/.ssh/environment
# start the ssh-agent
function start_agent {
    echo "Initializing new SSH agent..."
    # spawn ssh-agent
    /usr/bin/ssh-agent | sed 's/^echo/#echo/' > "${SSH_ENV}"
    echo succeeded
    chmod 600 "${SSH_ENV}"
    . "${SSH_ENV}" > /dev/null
    /usr/bin/ssh-add ~/.ssh/id_rsa_customer
}

if [ -f "${SSH_ENV}" ]; then
     . "${SSH_ENV}" > /dev/null
     ps -ef | grep ${SSH_AGENT_PID} | grep ssh-agent$ > /dev/null || {
        start_agent;
    }
else
    start_agent;
fi

I don’t really understand everything which happens on this script, but I do know it automatically starts the SSH Agent and registers the provided SSH key when I’m starting Git Bash. If you want to ‘reset’ these settings, just delete the .ssh/environment file and this script will create it once again.

We still haven’t talked about SourceTree yet. That’s because I first wanted to have Git Bash set up to work properly.

The SSH key we have created with Git Bash doesn’t work with SourceTree out of the box, you’ll have to convert them first. Choose to import SSH Keys in the Tools menu option.

image

A PuTTY Key Generator screen will pop up.

image

Load your existing private key into this and save it again with the Save private key button. Make sure not to overwrite the original file, because Git Bash still uses this one. Just save it to something like id_rsa_customer.ppk.

Now you are able to add this ppk SSH key to SourceTree.

In SourceTree you’ll have to start the SSH Agent before using SSH keys.

image

You’ll notice a small icon appears in your taskbar

image

Press the View Keys option and a small window will appear. You will probably haven’t got any keys added, yet, so press the Add Key option and choose your newly created ppk key file.

If everything happened successfully, you are now able to connect to your Git server using Git Bash and SourceTree as well.

After closing down and starting SourceTree again, the SSH Agent is stopped and your key isn’t added automatically once you start it again. Lucky for us developers, Atlassian has added a nice option for us. By filling out the SSH Client Configuration in the Options screen you are able to automatically start the SSH Agent and load your default SSH key.

image

Now you are all set to start working with Git.

There are some cool features available in Linux. In an earlier post I already mentioned the apt-get functionality which is now also offered in Windows via Chocolatey. One of the other cool features is being able to execute something in the terminal as an Administrator by specifying sudo in the command.

Lucky for us Windows people, someone has created a tool which is able to do something similar as the Linux sudo-command. The tool is called Elevate and can be downloaded from over here: http://code.kliu.org/misc/elevate/

After you have downloaded the zip-file from the website, copy the appropriate executable to your System32-folder and you are good to go!

By specifying the Elevate command in the command prompt, PowerShell window, Windows Search or Run-window the command will now be executed as an Administrator.

clip_image002

image

clip_image002[6]

Depending on your UAC settings, you are still prompted with the question if you really want to run the application (Notepad) as an Administrator.

I think this functionality could be extremely useful if you want to run specific commands of a script as an Administrator.

Even though the Windows operating system is one of the best in my opinion, there are always something which is only available in a different OS. For example the apt-get functionality in Linux. I don’t know how this works exactly, but from my basic understanding it’s some kind of repository with a lot of software and libraries which you can download to your device by typing something like the following in a terminal window:

apt-get SomeSoftware

Why this feature isn’t available by default in Windows is a mystery to me.

Quite some time ago, Scott Hanselman blogged about Chocolatey. Chocolatey is something similar to the apt-get feature from Linux, but now available on a Windows machine. (disclaimer: it’s not really the same, but works for me)

Ever since reading this post I wanted to use this awesome piece of software, but all my systems were already up-to-date and never needed it. As of this week, I’ve started working on a new project. Therefore, a new virtual machine had to be installed and configured. An awesome excuse to start using Chocolatey!

With Chocolatey you can install all kinds of software, just by typing a command in your Command Prompt or PowerShell window. It will automatically download and install the software for you. The only thing you need to do is wait for the command to finish.

Installing Chocolatey is easy also, just open up a command prompt window and copy-paste the install text from the homepage to your window. After the installation has finished, the window will look something like this.

image

Now you are ready for the real fun, installing software via scipting!

Visual Studio 2010 was already installed on my development machine, so I had to think of something else which is necessary. My choice was ReSharper. If you are unfamiliar with the Chocolatey commands for installing this software, just head up to the website, search for the software in the search box and everything is explained as the search results show the exact commands you need to install the software.

image

Installing ReSharper can be done by just typing the following in the command prompt window:

cinst resharper

Hit [Enter] and wait.

image

When finished, the gods are thanked appropriately and the software is good to go.

image

Of course, you don’t want to install all your development software manually via the prompt window. Therefore, it’s also possible to script it!

I’ve created a small Install.ps1 and placed it in a DropBox folder, so I can use it everywhere. The contents look like this.

# Install Visual Studio 2012 Ultimate
cinst VisualStudio2012Ultimate
# Install Visual Studio 2012 Update 4
cinst VS2012.4
# Install Visual Studio 2013 Ultimate
cinst VisualStudio2013Ultimate
# Install ReSharper
cinst resharper
# Install Notepad++
cinst notepadplusplus
# Install Fiddler
cinst fiddler
# Install FileZilla
cinst filezilla
# Install SQL Server 2012 Express
cinst SqlServer2012Express
# Install KeePass
cinst keepass
# Install Spotify
cinst spotify
# Install GitHub for Windows
cinst githubforwindows
# Install VLC Player
cinst vlc
# Install Beyond Compare
cinst beyondcompare
# Install dotPeek
cinst dotPeek
# Install dotTrace
cinst dotTrace
# Install Remote Desktop Connection Manager
cinst rdcman
# Install Sublime Text 2
cinst sublimetext2
# Install PowerGUI
cinst PowerGUI
# Install TreeSize
cinst treesizefree
# Install DropBox
cinst dropbox
# Install Google Drive
cinst googledrive
# Install SkyDrive
cinst SkyDrive
# Install Google Chrome
cinst GoogleChrome
# Install Mozilla Firefox
cinst Firefox

There’s probably much more to Chocolatey, but this what I’ve figured out so far. It’s too bad not all software is supported for Chocolatey yet, but it’s a great start. Most software you need is already in the repository and you can add new packages yourself on the website.

On some installations of Visual Studio 2010, 2012 or 2013 I’m confronted with strange behavior. One of these strange things are the black lines in the Watch Window of Visual Studio. Just like the screenshot below (this isn’t my screenshot, I’ve ‘borrowed’ it from someone else)

187351

Normally this has something to do with the graphics driver, but updating these drivers doesn’t work all the times. There’s also a work around for this problem, described on the MSDN forum.

The work around is:

  1. Go to Tools > Options >  Environment > Font and Colors
  2. Search for the settings for [Watch, Locals, and Autos Tool Windows]
  3. For Text select the Default for Item Foreground

The options will look something like the image below.

image

After you’ve set this option you’ll be able to see the text in your watch window again. The lines will be white again with black text.