Hacker News new | past | comments | ask | show | jobs | submit login
I've been writing TILs for 5 years (github.com/jbranchaud)
558 points by jbranchaud on April 18, 2020 | hide | past | favorite | 135 comments



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


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...


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.


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


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.


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.


[flagged]


While technically true, I tend to forget what I read after some time, especially tips and tricks that did not seem that useful when I first read them. So RTFM is not the silver bullet unless you somehow have a system that reminds you to re-read every manual every x months.


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


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.


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.


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


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


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


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


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.


> 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.


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.


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.


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


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.


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


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.


!cmd = repeat last usage of that command

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


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

See sudo !!.


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


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).


Shift+click works for me.


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


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.


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.


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.


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.


You might need something beyond mouse=a to get Putty to report the mouse through to vim—maybe this option? https://superuser.com/questions/513014/moving-cursor-in-putt...


wow, this is very handy.


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.


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


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.


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.


> 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.

Yikes, is this a random process?


Apparently the oldest fork wins, or the author of the repo can decide. https://webapps.stackexchange.com/questions/86769/which-fork...


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


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.


Good analogy


what is the biggest same-sex dating website in the world. Github -_-!


Possibly in order to raise Pull Requests against the repo?

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


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


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


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.


Gotcha. So the motivating factor was for individuals to get a copy for themselves, perhaps even use it as a form of bookmark overloaded as a backup feature. They'll need to keep pulling if they want to keep it up to date, but I suppose that could be automated.


https://probot.github.io/apps/pull/ to keep forks up to date automatically.


This is pretty good, now I can ditch my little script

    #!/bin/sh
    git pull upstream master
    git push origin master


TIL...


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.


> 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.


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:";
        };
    }


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.


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


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?


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/


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...


Fun fact: I keep my Vim's TIL in a org file.


I was there when it all began!


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!


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/


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


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


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.


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.


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


I was thinking of using Tiddlywiki for this.


Yeah, does anyone know of a hosted solution?


TILboard!


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


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. :-)


The time for concern is when you find yourself asking, "WTF was that idiot talking about?"


* reads answer

[wow whoever wrote this was an idio... oh nevermind ^I'll just walk out now]


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!


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.


I got that one from Drew Neil's book: Practical Vim


Sweet find.

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


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

Guess I better start today!


No better time than today to start building your own learning machine

https://dev.to/jbranchaud/how-i-built-a-learning-machine-45k...


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.


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


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

:(


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')


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


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.)


You can probably install it via Homebrew.


Yep!

  brew install ack


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.


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!


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.


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.



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

Anyway, thanks for sharing your tips!


I am still confused. Does TIL stand for Technical Information Library?


Today I Learned.


Yes, I did.


I read it as Tumor Infiltrating Lymphocytes. Too much immunology


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?


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.


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).


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.


Got it. I've been trying to solve a similar problem as well. I also stumbled upon this Gatsby theme for such a scenario (https://github.com/aengusmcmillin/gatsby-theme-brain). It's inspired from Roam Research's bidirectional links to notes.


A script that smushed them all together would make them easier to browse and read and enable control+f search.


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


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


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.


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


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


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


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.


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


You should check this out https://github.com/ashlinchak/mdanki


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


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


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


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

:)


Thanks for sharing! This is awesome.


Great list


ive saved this...super cool!


“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...



github is not a blog.



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


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


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


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.


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.


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


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...?


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


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!




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: