Useful snippets

    Oh my bash adding missing code completions

    Sun 22. October 2023 | 2023-10-22

    source /usr/share/bash-completion/completions/git
    __git_complete gco _git_checkout
    __git_complete gb _git_branch
    __git_complete gbs _git_bisect
    __git_complete ga _git_add
    __git_complete gcmsg _git_commit
    __git_complete gcs _git_commit
    __git_complete gd _git_diff
    __git_complete gl _git_pull
    __git_complete gp _git_push
    __git_complete gm _git_merge

    Syntax highlighting i Nano commit diff

    Sun 22. October 2023 | 2023-10-22

    nano ~/.nanorc

    sett inn

    https://gist.github.com/keithamus/736220/5e069767b22841610ee18fd2f92bd6026f5eb41d

    syntax "gitcommit" "COMMIT_EDITMSG$"
    color white "#.*"
    color green "#.(modified|added|deleted|unmerged|copy-edit|rename).*"
    color yellow start="# Changes.*" end="# Changed.*"
    color brightgreen "^\+.*"
    color brightred "^-.*"
    color brightyellow "(diff|index|---|\+\+\+).*"
    color brightmagenta "@@.*"
    color white "# Changes .*"
    color white "# Changed .*"
    color white "#.*\(use .*"
    color white "#$"
    

    =

    farger i git commit vinduet!

    Links

    Sun 22. October 2023 | 2023-10-22

    Links

    Ivareta git historikk ved file renaming

    Sun 22. October 2023 | 2023-10-22

    Ifølge https://koukia.ca/rename-or-move-files-in-git-e7259bf5a0b7

    Hvis du vil være sikker på at file history blir ivaretatt i en fil om du renamer den (eller flytter den), så må du bruke commando-linja og kjøre

    git mv mycoolclass.cs myCoolClass.cs
    

    eller

    git mv layout/CardList common/List
    

    Hvis du renamer direkte i editor-en, så kan du ikke være sikker på at git skjønner at det er samme fil.

    Når du ivaretar git history så kan du bruke ting som git log -p --follow -- path/to/filename. Se gist: https://gist.github.com/paalss/7127b421ff7f3a862ae8d76c772aeb6a

    Kommentarer:

    Mulig det er unødvendig å bruke mv. Da jeg renamet og flyttet layout/CardList til common/List så skjønte git at disse to filene var 74% like.

    git log -p --follow components/common/List/List.tsx funker fjell. Historikken strekker seg tilbake til før renamingen

    i18next

    Sun 22. October 2023 | 2023-10-22

    Usage with long nested keys

    const { t } = useTranslation("translation", {
      keyPrefix: "long.nested.keys",
    });

    eleventy stuff

    Sun 22. October 2023 | 2023-10-22

    Eleventy stuff

    eleventy.js

    Return specific post

    module.exports = function (eleventyConfig) {
      eleventyConfig.addPassthroughCopy("bundle.css");
      eleventyConfig.addPlugin(syntaxHighlight);
      eleventyConfig.addCollection("post", function (collection) {
        const coll = collection.getFilteredByTag("post");
        console.log(coll);
        return [coll[20]];
      });
    };

    Return first 5 posts

    module.exports = function (eleventyConfig) {
      eleventyConfig.addPassthroughCopy("bundle.css");
      eleventyConfig.addPlugin(syntaxHighlight);
      eleventyConfig.addCollection("post", function (collection) {
        const coll = collection.getFilteredByTag("post");
        console.log(coll);
        return coll.slice(0, 5);
      });
    };

    Kule porteføljer

    Sun 22. October 2023 | 2023-10-22

    MEST UKONVENSJONELLE PORTEFØLJER