#+TITLE: Commands I wish I knew earlier

* Introduction                                                       :ignore:

This is a collection of simple shortcuts and tricks that I was
surprised existed (both in a good and a bad way) and (sometimes) wish
I had known about earlier. Everyone's going to have a different set,
YMMV.

Obviously not exhaustive; I also plan to keep updating this list over time.

* Custom Styling                                                     :ignore:
#+BEGIN_EXPORT html
<style type='text/css'>
  .tag {
    background: none;
    font-family: inherit;
    color: #aaa;
  }
  .tag:before {
    color: #777;
    content: "(";
  }
  .tag:after {
    color: #777;
    content: ")";
  }
</style>
#+END_EXPORT

* Shell
** Process Substitution                                               :like:
Create a fd for a piped process: this can be useful for piping in the
output of multiple programs into a single one, etc.

A nonsensical example to show what  I mean
#+BEGIN_SRC bash
  vimdiff <(cat file1) <(cat file2)
#+END_SRC

** SSH Escape Sequences                                               :like:
Before I found out about ~. I would consistently kill and open new
terminal windows while waiting for SSH to disconnect.

Note that ~ is only recognized as an escape sequence after a newline:
that would frequently trip me up before I RTFM'd.

#+BEGIN_EXAMPLE
  Supported escape sequences:
   ~.   - terminate connection (and any multiplexed sessions)
   ~B   - send a BREAK to the remote system
   ~C   - open a command line
   ~R   - request rekey
   ~V/v - decrease/increase verbosity (LogLevel)
   ~^Z  - suspend ssh
   ~#   - list forwarded connections
   ~&   - background ssh (when waiting for connections to terminate)
   ~?   - this message
   ~~   - send the escape character by typing it twice
  (Note that escapes are only recognized immediately after newline.)
#+END_EXAMPLE

** Android Shell: Toolbox                                           :dislike:
Toolbox's chmod doesn't support characters: in other words, chmod +x
doesn't actually do anything meaningful.

* Emacs
** Winner Mode                                                        :like:
After wasting a lot of time recreating my perfect window
configurations only to have them decimated by a help command, an
accidental agenda command, etc. — I found out about winner mode to
quickly restore previous configurations.

#+BEGIN_EXAMPLE
C-c left: Undo window changes
C-c right: Redo window changes
#+END_EXAMPLE

** Lexical Binding                                                    :like:
I've never really written much code in languages that don't support
Lexical Binding — and finding that my SICP inspired stateful closures
weren’t working in elisp definitely threw me off.

I’m going to find out the hard way how this behaves in conjunction
with org-babel.

#+BEGIN_SRC emacs-lisp
  (setq lexical-binding ’t) ; buffer local by default
#+END_SRC