Home » Archives for 2023 » Page 4

2023

  • Setting up a GPG Key with git to sign your commits

    Setting up a GPG Key with git to sign your commits

    Signing your git commits with GPG is really easy to set up and I’m always surprised by how many developers I meet that don’t do this.

    Of course it’s not required to push commits and has no baring on quality of code. But that green verified message next to your commits does feel good.

    Essentially there are three parts to this:

    1. Create your GPG key
    2. Tell git to use your GPG key to sign your commits
    3. Upload the public part of your GPG key to Gitlab / Github / etc

    Creating the GPG key if needed

    gpg --full-generate-key
    

    In the interactive guide, I choose:

    1. (1) RSA and RSA (default)
    2. 4096 bits long
    3. Does not expire
    4. Fill in Name, Email, Comment and Confirm.
    5. Enter passphrase when prompted.

    Getting the Key ID

    This will list all of your keys:

    gpg --list-secret-keys --keyid-format=long
    

    Example of the output:

    sec   rsa4096/THIS0IS0YOUR0KEY0ID 2020-12-25 [SC]
          KGHJ64GHG6HJGH5J4G6H5465HJGHJGHJG56HJ5GY
    uid                 [ultimate] Bob GPG Key<mail@your-domain.co.uk>
    

    In that example, the key id that you would need next is “THIS0IS0YOUR0KEY0ID” from the first line, after the forward slash.

    Tell your local git about the signing key

    To set the gpg key as the signing key for all of your git projects, run the following global git command:

    git config --global user.signingkey THIS0IS0YOUR0KEY0ID
    

    If you want to do it on a repository by repository basis, you can run it from within each project, and omit the --global flag:

    git config user.signingkey THIS0IS0YOUR0KEY0ID
    

    Signing your commits

    You can either set commit signing to true for all projects as the default, or by a repo by repo basis.

    # global
    git config --global commit.gpgsign true
    
    # local
    git config commit.gpgsign true
    

    If you wanted to, you could even decide to sign commits per each commit, by not setting it as a config setting, but passing a flag on every commit:

    git commit -S -m "My signed commit message"
    

    Adding your public key to gitlab / github / wherever

    Firstly export the public part of your key using your key id. Again, using the example key id from above:

    # Show your public key in terminal
    gpg --armor --export THIS0IS0YOUR0KEY0ID
    
    # Copy straight to your system clipboard using "xclip"
    gpg --armor --export THIS0IS0YOUR0KEY0ID | xclip -sel clipboard
    

    This will spit out a large key text block begining and ending with comments. Copy all of the text that it gives you and paste it into the gpg textbox in your git forge of choice – gitlab / github / gitea / etc.

    📂

  • Proficient Agent – Resident Evil 4

    Complete the main story on Hardcore mode or higher.

    📂 ,

  • Promising Agent – Resident Evil 4

    Complete the main story on Standard mode or higher.

    📂 ,

  • Astute Appraiser – Resident Evil 4

    Sell a single treasure for at least 100000 ptas.

    📂 ,

  • Shield Your Eyes – Resident Evil 4

    Defeat 3 enemies at once with a flash grenade.

    📂 ,

  • Talk About Near-Death Experience! – Resident Evil 4

    Rescue Ashley as she’s being carried away by the enemy.

    📂 ,

  • How I use vimwiki in neovim

    This post is currently in-progress, and is more of a brain-dump right now. But I like to share as often as I can otherwise I’d never share anything 🙂

    Please view the official Vimwiki Github repository for up-to-date details of Vimwiki usage and installation. This page just documents my own processes at the time.

    Installation

    Add the following to plugins.lua

    use "vimwiki/vimwiki"

    Run the following two commands separately in the neovim command line:

    :PackerSync
    :PackerInstall

    Close and re-open Neovim.

    How I configure Vimwiki

    I have 2 separate wikis set up in my Neovim.

    One for my personal homepage and one for my commonplace site.

    I set these up by adding the following in my dotfiles, at the following position: $NEOVIM_CONFIG_ROOT/after/plugin/vimwiki.lua. So for me that would be ~/.config/nvim/after/plugin/vimwiki.lua.

    You could also put this command inside the config function in your plugins.lua file, where you require the vimwiki plugin. I just tend to put all my plugin-specific settings in their own “after/plugin” files for organisation.

    vim.cmd([[
      let wiki_1 = {}
      let wiki_1.path = '~/vimwiki/website/'
      let wiki_1.html_template = '~/vimwiki/website_html/'
      let wiki_2 = {}
      let wiki_2.path = '~/vimwiki/commonplace/'
      let wiki_2.html_template = '~/vimwiki/commonplace_html/'
      let g:vimwiki_list = [wiki_1, wiki_2]
      call vimwiki#vars#init()
    ]])

    The path keys tell vimwiki where to plave the root index.wiki file for each wiki you configure.

    The html_template keys tell vimwiki where to place the compiled html files (when running the :VimwikiAll2HTML command).

    I keep them separate as I am deploying them to separate domains on my server.

    When I want to open and edit my website wiki, I enter 1<leader>ww.

    When I want to open and edit my commonplace wiki, I enter 2<leader>ww.

    Pressing those key bindings for the first time will ask you if you want the directories creating.

    How I use vimwiki

    At the moment, my usage is standard to what is described in the Github repository linked at the top of this page.

    When I develop any custom workflows I’ll add them here.

    Deployment

    Setting up a server to deploy to is outside the scope of this post, but hope to write up a quick guide soon.

    I run the following command from within vim on one of my wiki index pages, to export that entire wiki to html files:

    :VimwikiAll2HTML

    I then SCP the compiled HTML files to my server. Here is an example scp command that you can modify with your own paths:

    scp -r ~/vimwiki/website_html/* your_user@your-domain.test:/var/www/website/public_html

    For the best deployment experience, I recommend setting up ssh key authentication to your server.

    For bonus points I also add a bash / zsh alias to wrap that scp command.

    📂

Explore

If you want to search, or just get an overview of my stuff, the explore page is a good place to start.

Any interesting websites and/or people I have found online, I link them on my blogroll page.

I keep a record of things i use on my… well… my “uses” page.

Album on repeat

All of my collected posts, grouped by year.