Settings

Theme

I've been writing TILs for 5 years

github.com

558 points by jbranchaud 6 years ago · 139 comments

Reader

weiming 6 years ago

TIL Alt-clicking in the Terminal prompt lets me move the cursor to that position. How had I not discovered this over many years?

  • crazygringo 6 years ago

    Not having this has been my #1 Terminal frustration for years... and it's been there this whole time?!?!

    This type of thing has actually happened to me several times in the past year or so, where I'd be frustrated an obviously good feature doesn't exist, I'd Google it to see if other people complain about the same thing... only to find it exists after all.

    There needs to be a word for this...

    • schasse 6 years ago

      It's been one of my #1 terminal frustrations, too!!! But instead of relying on GUIs and the mouse, I started to use terminal tools and wrote a plugin for tmux that helped me. https://github.com/schasse/tmux-jump Maybe it's useful for you.

    • Kaiyou 6 years ago

      There's an initialism for it, used by the people who know about the feature to describe the people who didn't: RTFM.

      • crazygringo 6 years ago

        Very funny.

        If I read the manual for everything I've ever used, I'm not sure I'd have time to actually accomplish anything in the end.

        Sure, let me spend a day reading through the lists of keyboard/mouse shortcuts for every piece of software I use just to see if there's anything useful in there? No thanks...

        Good UX would pop up a balloon informing me of the feature after the first time I held down my left-arrow key for more than, say, keypresses.

        • Kaiyou 6 years ago

          CLIs are like that. On the bright side, things rarely change. So the stuff you read in the manual 30 years ago still likely works. I prefer it over relearning GUIs with every update.

          Of course, you might as well disregard the manual and discover things on your own as you need them. Nevertheless, it helps to go at this with a mindset of "this feature surely already exists" lest you're compelled to develop a worse version of the feature yourself.

  • shrimp_emoji 6 years ago

    Which terminal? In Linux, Alt+Left Click is the "move window around" idiom, while Alt+Right Click is "resize window with the mouse".

    • tommyage 6 years ago

      How can you know that this is a common idiom? Is there an (prob. GNU)-document for these things? Two reasons I am asking: 1) I feel terrible reading this, since my last post was preaching for XCFE for this exact functionality. 2) It would be awesome to have these things bundled and discover many things which are yet not discovered by me.

      • fiddlerwoaroof 6 years ago

        The major Linux desktops have had this sort of thing for like 15 years. It’s usually only discovered by people who obsessively tweak their settings, though.

      • nougatbyte 6 years ago

        Dont think that its a standart of some kind, but KDE does the same thing

    • zimpenfish 6 years ago

      I'd imagine it was Terminal on MacOS from the capitalisation (and that does what he says, just checked.)

      • weiming 6 years ago

        Yes. That would be Mac iTerm/Terminal, should have mentioned.

      • akiselev 6 years ago

        Do people usually use "Alt" to describe the Option key on Macs? I was really confused for a second trying to find it on my Macbook

        • OJFord 6 years ago

          Yes.

          Anyone that hasn't been exclusively using macOS for their entire digital life, or at least years, anyway.

          'Command' (resp. 'Windows', resp. 'Super') is a different story. You can't say 'Super' with a straight face without also marking yourself out as someone who borders on saying 'GNU with Linux', or 'I run Arch'.

          (For what it's worth, I do run Arch. ;))

          IIRC Option is dually labelled as Alt on some Apple keyboards anyway.

          • franga2000 6 years ago

            > You can't say 'Super' with a straight face without also marking yourself out as someone who borders on saying 'GNU with Linux', or 'I run Arch'.

            Since basically nobody knows the historical difference these days, I just call it the Meta key to avoid the above situation. When non-techy people ask me what the hell I mean, I just explain that's the technical term for the key and that I use it so both Mac and Windows people understand me. I've even heard one of them start using the term themselves, presumably to appear smarter in front of their boss.

            • Zarel 6 years ago

              While it's not wrong to refer to the Super key as "Meta", I don't like calling it that, because in some contexts (like emacs), "Meta" means the Alt key.

        • vangelis 6 years ago

          I use a USB mechanical keyboard with my Mac, Ubuntu at home, so I tend to think of command and option as super and alt.

    • 1998v2 6 years ago

      I want this badly on gnome-terminal. If anyone has this type if thing on a linux plz. advise.

      • jchook 6 years ago

        I agree, but also can recommend a few good shortcuts...

        <c-a> = go to beginning of line

        <c-e> = go to end of line

        !! = repeat last command

        <esc> b = move "back" one word (also <c-b> and <c-left>)

        <esc> f = move "forward" one word (also <c-f> and <c-right>)

        Many others exist. See `man bash` under READLINE.

        • rtpg 6 years ago

          By the way, recently discovered you can get some of these shortcuts in all input boxes by activating “emacs shortcuts” inside of gnome-tweaks! Was one of the final blockers for getting me from Mac to Linux

        • Too 6 years ago

          You can also use the more standard Home/End/Ctrl+Left/Ctrl+Right to do all of the above. Much easier to remember and works in any other editor also.

        • dylan604 6 years ago

          !cmd = repeat last usage of that command

          !!enter which is 3 buttons where as up-arrow enter is the same thing.

          • Something1234 6 years ago

            !! is more useful than you think. It's substitute last command here, not just up-arrow enter.

            See sudo !!.

        • chrisweekly 6 years ago

          Yes! I use c-u to clear the line all the time.

          • neetfreek 6 years ago

            And <c-w> clears the previous word :) Also <c-y> pastes the line/word back in (so you cant think of it like cut-copy).

      • Kaiyou 6 years ago

        Shift+click works for me.

  • noisy_boy 6 years ago

    I tried this in vim but didn't work. TIL "set mouse=a" enables moving cursor by mouse click in vim.

    • wabain 6 years ago

      To add what was an essential follow-up for me when I discovered this: Once you’ve enabled mouse=a, use the alt key to select text in vim for your system clipboard, rather than vim’s visual mode.

      • wazoox 6 years ago

        I don't understand this part. How do you select using Alt?

        Typically with mouse enabled, you can select text with the mouse, but this doesn't go to the X clipboard. While with mouse disabled, text selected with the mouse goes to the X clipboard.

        • wabain 6 years ago

          What I had meant was that when using vim configured with mouse=a, selecting with the mouse while holding down the Alt key would disable the terminal emulator's mouse reporting and allow the selection to be copied to the system clipboard.

          But actually this depends entirely on the terminal emulator. The Alt/Option key works with the default preferences for iTerm2 on MacOS, but with GNOME terminal I reproduced the same behavior using Shift instead.

      • noisy_boy 6 years ago

        Found another interesting problem. mouse=a works great on my Ubuntu laptop; however, it has no impact when connected to Linux servers via Putty - when I click somewhere in the vim window, the cursor doesn't jump to that spot.

  • hank_z 6 years ago

    wow, this is very handy.

hhsuey 6 years ago

Forgive me for my ignorance, but I haven't contributed to open source much yet. What is the reason for forking this repo. I see a lot of people have done it. Wouldn't that be akin to cloning someone else's personal blog? I just don't see the point of that.

  • baby 6 years ago

    It's weird, but two potential reasons:

    * in case the repo gets deleted, at least you still have a copy

    * some github apps on tablet might give you an easier access to your own list of repos

    • EduardoBautista 6 years ago

      Doesn't GitHub delete forks if the original is deleted? Of course, actually cloning the fork onto your computer and pushing it to a new repository without using GitHub's "fork" feature should get around this easily.

      • hhsuey 6 years ago

        Deleting a private repository

        When you delete a private repository, all of its private forks are also deleted.

        Deleting a public repository

        When you delete a public repository, one of the existing public forks is chosen to be the new parent repository. All other repositories are forked off of this new parent and subsequent pull requests go to this new parent.

    • hhsuey 6 years ago

      Makes sense. I thought about it a little more and came to the same two potential reasons.

  • saghm 6 years ago

    Ive noticed some people use github almost like a social network. A rough analogy to Twitter would be that starring a repo is similar to liking a tweet, and forking it is almost like a retweet.

  • dcminter 6 years ago

    Possibly in order to raise Pull Requests against the repo?

    https://github.com/jbranchaud/til/pulls?q=is%3Apr

    • hhsuey 6 years ago

      25 closed merges, of which half of them are closed and half merged. Compare that to 330 forks and 6.7k stars. This is still an overwhelmingly read-only parent fork that is basically the author's personal TIL blog. https://github.com/jbranchaud/til/pull/24

      • londons_explore 6 years ago

        I usually click 'fork' with the intention of making some minor change, and maybe committing it back.

        90 percent of the time, that minor change either isn't suitable for being committed back to the project (it's badly hacked in, it's too specific to my usecase, etc.), Or the change ends up being harder to make or test than I had imagined, so I give up but don't bother deleting the fork.

        That could explain the large number of forks and small number of PR's

  • MoOmer 6 years ago

    One of the benefits of open-source is that you can ensure a copy of the source exists, in the event that something makes the original source disappear.

  • klibertp 6 years ago

    Staring at an empty sheet of paper (or a text file) can be daunting, and can suck all of your enthusiasm out of you in short order. It's much, much easier to start with some content and append your thoughts to it.

saagarjha 6 years ago

> Chrome Supports Many Unix Keyboard Shortcuts

These are actually Emacs-style editing shortcuts that come are part of Cocoa's text controls. If this doesn't work in an app on macOS, that app has broken them or is trying (evidently poorly) to reimplement their own text editing widget.

  • bdd 6 years ago

    You can further Emacsify or customize text controls to your heart with a `DefaultKeyBinding.dict` file.

    This what I've been using for ~8 years. Apple removed a few functions here and there but still plenty are available. Reference URL in the file comments.

        {
            /* Additional Emacs bindings:
             *
             * "<key combination>" = "functionName:";
             *
             * Key Modifiers:
             *   ^: ctrl
             *   ~: option
             *   $: shift
             *   @: command
             *
             * Instance Methods of "NSStandardKeyBindingResponding":
             * https://developer.apple.com/documentation/appkit/nsstandardkeybindingresponding
             *
             * Install under ~/Library/KeyBindings/DefaultKeyBinding.dict
             *
             * Download directly:
             * curl --create-dirs -o ~/Library/KeyBindings/DefaultKeyBinding.dict THIS_URL
             */
    
    
            "^l"  = "centerSelectionInVisibleArea:";
            "^/"  = "undo:";
            "^ "  = "setMark:";
    
            "~f" = "moveWordForward:";
            "~b" = "moveWordBackward:";
            "~<" = "moveToBeginningOfDocument:";
            "~>" = "moveToEndOfDocument:";
            "~v" = "pageUp:";
            "~d" = "deleteWordForward:";
            "^w" = "deleteWordBackward:";
            "~/" = "complete:";
            "~t" = "transposeWords:";
    
            "^x" = {
                "h"  = "selectAll:";
                "k"  = "performClose:";
                "^x" = "swapWithMark:";
                "^m" = "selectToMark:";
            };
        }
  • kehrin 6 years ago

    I only recently found out that you can use C-n and C-p to move around the suggestions in the url bar. Good stuff.

  • ygra 6 years ago

    That explains why they don't work on Windows. I'd have been mildly surprised by them breaking many established shortcuts like Ctrl+A for Select All, and Ctrl+E for search

  • macintux 6 years ago

    I still remember when I discovered that Emacs-style editing shortcuts worked in Netscape Navigator for Windows, over 20 (sigh) years ago.

    Do Windows browsers no longer support them?

eatonphil 6 years ago

This is awesome! Twitter has been my goto for posting TILs for about as long. Now I regret not collecting them in a more coherent format like this.

Sara Soueidan has a similar log oriented toward UI work:

https://www.sarasoueidan.com/today-i-learned/

jbranchaudOP 6 years ago

Vim is by far my most TIL-ed topic. I recently started gathering a lot of that learning into a screencast series: https://www.youtube.com/playlist?list=PL46-cKSxMYYCMpzXo6p0C...

jblock 6 years ago

TIL that I'd been using items in this list for reference without realizing that I had been working with Josh (OP) at my day-job the whole time!

theodorton 6 years ago

I've started collecting these myself and I try to summarize them every month. I encourage everyone to do the same, it's a great way to build a reference of stuff you learn that you can and reviewing them monthly makes it stick.

https://theodorton.github.io/categories/til/

dchuk 6 years ago

Seems like a really simple web app concept someone should pursue. I feel like being able to browse other people’s TILs and save them/search them would be a really valuable thing.

EDIT: Just like this: https://til.hashrocket.com/ but open to anyone to sign up

  • hhsuey 6 years ago

    Isn't that just a blog or a subreddit? And couldn't you find all the TIL blogs by Googling for "TIL" or something?

    • dchuk 6 years ago

      Would be closer to a subreddit I guess. But purpose built.

      I think there’s lots of room for simple, purpose built web apps for stuff like this.

      • hhsuey 6 years ago

        True. I think that's the way the world is moving towards. I also see the 5000+ custom alarm clock apps out there as essentially forks of "deployed apps" for just alarms. But that was already predated by the explosion of websites doing the same XYZ thing (calorie trackers, photo storing apps, etc...) specifically before the mobile era. I think we're just seeing the same with the open source world as we've seen occur in more mature worlds.

  • lhenk 6 years ago

    We've built something similar to hashrockets TIL, https://til.cybertec-postgresql.com

  • elbear 6 years ago

    I was thinking of using Tiddlywiki for this.

  • neillyons 6 years ago

    Yeah, does anyone know of a hosted solution?

  • bboreham 6 years ago

    TILboard!

swaggyBoatswain 6 years ago

ive been doing this mostly on stackoverflow (where I answer my own question, or answer questions to something I couldn't find an answer too). It does take a bit longer than a repo where I just dump information, so I might try that instead

My thought process is I'll google something and find something I wrote

There's also the bonus that you might get an expert answering your topic

EDIT: related story - I wrote an answer to a question about programming a financial calculator, and one of my dev friends had the same exact problem/found my solution the next day on stackoverflow

  • lostphilosopher 6 years ago

    I have at least two things I consistently forget, and then relearn from my own Stackoverflow answer. Comes up rarely enough that I chuckle at myself everytime it happens. :-)

laddng 6 years ago

The VIM ones are my favorite - I'm always blown away with the simple keyboard shortcuts that could have saved me hours had I known them 2 years ago.

TIL just typing "=" in Vim fixes all my indentation

Just subscribed to his newsletter so I can get these and not forget about this cool repo!

  • IngoBlechschmid 6 years ago

    The absolute best Vim command of all times is "ciw", or its variants "ci(", "cip", ... You use this command when your cursor is in the middle of a word (or parenthetical expression or paragraph or ...) and you want to replace that word by a new one.

    Maybe it's too well-known, but this command changed my life and I haven't found in the linked list of TILs.

  • simonmales 6 years ago

    Sweet find.

    If you want to change a single line without doing a visual selection, '==' does the trick.

palijer 6 years ago

Reading through theses makes me wish I started this 5 years ago.

Guess I better start today!

LeonB 6 years ago

I was inspired by Josh’s TIL previously and have been storing TILs at https://TIL.secretGeek.net for years now too.

Just last night I rebuilt the site using a new static site generator I built for it (called Clowncar) so I can cut gitbook out of my life.

einpoklum 6 years ago

Suggestion: If you have an especially good TIL about programming, look for an appropriate public forum to post it.

mkchoi212 6 years ago

TIL macOS doesn't ship with `ack`. Found this out when trying the first thing on the list `ack --bar`.

:(

  • sdenton4 6 years ago

    Indeed... the MacOS command line tools often are missing or have some different defaults and hotkeys (I'm looking at you, 'top') than the versions I'm used to on my linux systems, which, sure, ecosystem diversity is cool and all, but... Every time I try to rearrange the processor usage in TOP, I open it up and think 'IT'S A TRAP!'

    (admittedly, this was all just an attempt at making a sufficiently substantive comment so I could make the joke about 'ack --bar')

    • oneplane 6 years ago

      I think top in macOS is the BSD version where top in most linux distributions is the GNU version. Same with tar.

  • chrismorgan 6 years ago

    Does any platform ship with ack? I wouldn’t expect any mainstream one to. (And for any platform inclined to add useful utilities, I’d suggest ripgrep rather than ack, as it’s way faster, and superior in almost every regard.)

  • cpach 6 years ago

    You can probably install it via Homebrew.

oneplane 6 years ago

This is great. I've been collecting 'things' I learned and links to pages, like a reading list etc. but none of that sticks out long term because the resources might move, the data might not be searchable or the thing you wanted to get out of a larger article is actually much smaller than the 20 pages it came with. And then when you collect links and a reading list you end up not really going back to it anyway.

This approach makes it much easier to just add the thing you actually wanted to learn and learned in a small concise way with a reference back to where you found it. So simple, yet as so many others I hadn't thought of it.

  • hhsuey 6 years ago

    Why would you need to create notes and go back to it though? Isn't searching for it much faster? Say you learned a nifty hotkey to backup text using a shortcut on OSX (or whatever). Why not simply search "hotkey backup osx"? And say that page you found it on shows up, but like you said, it's very long text page. Then just just bring up the search-in-page feature in your browser, and you're there!

    • oneplane 6 years ago

      Because sometimes you find an article on hacker news that you didn't search for but did stumble upon. Then you can't search for it because you weren't searching for it in the first place.

  • bobbydreamer 6 years ago

    You are absolutely right, I wrote a app for myself to note down links and texts and some webpages as design would look good. After a while everything would have changed.

kbr2000 6 years ago

Ha, you got me confused there for a bit, because of: https://wiki.c2.com/?ThreadedInterpretiveLanguage

Anyway, thanks for sharing your tips!

superasn 6 years ago

In a similar fashion I've been working on a snippet library for php and js, though it's definitely not this frequent or intentional.

It's quite useful when I stumble upon things like how do I format this date, or match balanced brackets in a string.

Battle tested code ready for my taking. Quite useful when I'm in a hurry! Do you guys do this too?

dotmanish 6 years ago

In case folks are interested in other "non-tech" TILs, I occasionally visit this blog to see what's been added recently - https://alearningaday.blog/ - by a Product Manager who currently works at LinkedIn.

ramshandilya 6 years ago

This is amazing. Curious how you search or go back to refer them? Have you considered porting this to a doc generator like mdBook(https://github.com/rust-lang/mdBook).

  • jbranchaudOP 6 years ago

    I usually remember when I've written on something even if I've forgotten the details. I tend to be able to do a Cmd-f search of the README for a keyword to turn up what I'm looking for.

    All that said, I've been contemplating moving all of this into a Gatsby-powered site with either a custom search backend or Algolia to make it all a bit more accessible.

  • elbear 6 years ago

    I use the same format, but I write everything in Tiddlywiki which has a search function.

alphachloride 6 years ago

A lot of the TILs could be put in a single readme instead of a file of their own.

  • closed 6 years ago

    I agree there are ways to organize this that would benefit outside readers, but am guessing the simple, consistent structure probably helped the author get to 5 years of TILs!

    It's interesting they chose to alphabetize and start many entries w/ verbs.

  • mnunez 6 years ago

    I found myself wanting to read the Javascript section in one go after opening the first few entries, so I did:

      u="https://raw.githubusercontent.com/jbranchaud/til/master/"; curl "${u}README.md" | sed -e '/### JavaScript/,/### /!d;//d' | awk -F'[()]' '{print $2}' | xargs -n1 -I{} curl "$u{}" >> til-javascript.md
littke 6 years ago

I am actually building a site specifically for this use case:

https://todayilearned.co

It allows both private and shared insights, so people can learn together. Check it out

simonw 6 years ago

This inspired me to start doing this myself. I made a start here: https://github.com/simonw/til

simonw 6 years ago

I really like this format. It's an interesting mid-point between a tweet and a blog, but optimized for "evergreen" content as opposed to content where the date is key.

cellularmitosis 6 years ago

This would make a great set of flashcards for a spaced-repetition system! Thanks for publishing these.

feralsky 6 years ago

Great effort! Often thought about creating a blog for such things but never progressed further.

mekster 6 years ago

Referencing the selected element in Chrome with $0 certainly saves quite a few typing.

  • BenjiWiebe 6 years ago

    This is the biggest takeaway from this whole HN post/thread. And it works the same on Firefox! Thanks so much!

lebuffon 6 years ago

I'm so old I remember when TIL meant Threaded Interpreted Language.

:)

chrisweekly 6 years ago

Thanks for sharing! This is awesome.

jbverschoor 6 years ago

Great list

apl002 6 years ago

ive saved this...super cool!

layoutIfNeeded 6 years ago

“On Mac, you can insert a non-breaking space character by hitting option-space.”

Does anyone know how to turn this OFF? I accidentally type non-breaking spaces in the terminal all the time and then have to meticulously try re-entering each space from the end backwards until bash finally groks it...

johnghanks 6 years ago

github is not a blog.

  • CharlesW 6 years ago
    • yesenadam 6 years ago

      I clicked the link on that page to "go see for myself" and got a 404..

      • RMPR 6 years ago

        > I have a habit of changing my blog URL and software a lot and I’ve lost a great many posts over the years.

        • yesenadam 6 years ago

          From the amasci.com FAQ:

          NEVER EVER move one single html file or change an URL. Don't you hate it when you click on a link and it says "404 file not found"? Well, I've been here since 1994, and all the links to my site still work!

          He's full of what seems to me good advice, e.g. from the same page:

          Make your website be your filing cabinet. If you have little projects underway, put them on your website while working on them. Reject the paper-publishing traditions of polishing an article to perfection before publication. DO NOT ELEVATE IMAGE OVER CONTENT. (Perhaps even keep yourself honest by cultivating a deep revulsion for "image.") Instead, let all your flaws hang out, and type things directly into your site in rough draft form (label them UNDER CONSTRUCTION if you really must).

          Expunge the fear of embarassment from your life, and instead practice making foolish mistakes in front of thousands of strangers. Stop using your PC to store files, instead use your website as your main storage. Let people poke through your filing cabinet. It will contain far more than a perfectly polished website does.

          http://amasci.com/faq.html

hhsuey 6 years ago

I don't really see the point of this, except that it helps the author stay consistent to make updates and learn things. I'm not really sure why anyone would consume this, except for curiosity into what they could do for implementing their own consistency forcing function.

  • hhsuey 6 years ago

    Sorry, good work to the author. I'm kind of a downer, and personally struggling to find motivation to work on projects, but often shoot myself down first. I don't see the point in a lot of projects out there.

    • recursive 6 years ago

      Sometimes I do projects before I find a purpose for them. Often, I never do.

      • hhsuey 6 years ago

        Would you say you've done a lot of projects though and that was the win itself? And that despite not being able to find a purpose to most of the projects, the benefit has been the learning/growth/experience/fun/etc...?

        • recursive 6 years ago

          Fun, learning, an occasional surprise practical applications have all happened.

  • simonw 6 years ago

    It's fantastic food for search engines. I write a lot online, and a few times a year I'll type something into Google and find the answer in something I wrote years ago and forgot about!

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection