Showing 125 to 128

Eshell

C-c RET🔗

This takes some getting used to. Suppose you type this:

mkdir /home/user/some-very-long-name

press C-c RET, then what you have on the prompt is this (I put in a vertical bar to represent the point/cursor):

mkdir /home/user/some-very-long-name ⋮ mkdir /home/user/some-very-long-name

so you can delete the second mkdir and type && cd or something.

Once you're used to this sort of feature, you'll always be looking for equivalents in other shells or feel handicapped. You could write your own Rosetta stone: a cheatsheet for equivalents in fish, oh-my-zsh, oh-my-bash, or whatever other shell you switch to in the future. All skills you learn in eshell are transferable.

The important thing is that you explore the most powerful features of whichever shell you're in so you know about them and know they're possible. That's how you grow your skill, and become able to exploit the potential of exotic shells like a riced-out Xonsh or Ambrevar's SLY-on-steroids. It builds up.

My best Eshell hotkeys🔗

  • C-c M-o – eshell-mark-output
  • C-c C-p – jump to previous prompt
  • C-M-l – eshell-show-output, almost the same, but jump to top of output
  • C-c RET – more on this later
  • C-c C-u – like C-u on a terminal obeying Bash hotkeys
  • C-c M-d – eshell-toggle-direct-send – lets you say y to y/n prompts without pressing enter, I think

Some of my really nice custom bindings:

  • C-M-j – my-insert-other-buffer-file-name
  • C-c C-l – my-counsel-eshell-history
  • <escape> – crux-switch-to-previous-buffer

The Eshell language🔗

You can type elisp expressions without outer parens, like

λ kbd "C-x f"

or

λ define-key

Try it! it returns

usage: define-key: (KEYMAP KEY DEF)

It's a bit like an alien fish. Oddly similar because in both shells, parens delineate nested function calls. The equivalent in Bash would be using grave accents, e.g. echo `concalc 1+2`. Try

λ echo (+ 1 2)
λ define-key $global-map (kbd "C-x t") #'crux-transpose-windows
λ list-timers

So cool! You really should try. If you don't have an Emacs open, open it and type M-x eshell. Type these commands out by hand.

More things to try:

λ concat a b
λ setq a 2
λ + a 3

Hear this:

Unlike regular system shells, Eshell never invokes kernel functions directly, such as ‘exec(3)’. Instead, it uses the Lisp functions available in the Emacs Lisp library. It does this by transforming the input line into a callable Lisp form.

[2024-04-08 Mon] That it just does lisp becomes obvious if you type a command that doesn't exist. Compare it in eshell versus shell.

To see the Lisp form that will be invoked, type:

λ eshell-parse-command "echo hello"
λ eshell-parse-command "echo hello; echo multiple words; setq a 2 b 3"

Also

λ which ls

One use I've for Eshell that's not possible in any other shell: after editing ~/.profile or ~/.xsessionrc or similar files, I can make it apply to the running emacs environment with simply

λ . ~/.profile

This is not possible in any other shell because they're external processes, whereas Eshell's "process" is the Emacs process.

May not seem important to source ~/.profile, but I feel there's something about the fact you can that proves there's no other sane shell choice. Emacs is supposed to be your HCI (human-computer interface). Why create roadblocks?

By the way, so you know, . .profile is is not the same as source .profile (in plain Bash, it is the same).

If you're looking for how to do something, try the info manual at C-h i d m Eshell <RET>. They tell you how to do for loops and whatever else you need.

Eshell with timestamped prompts, automatically timing commands, and backreferences!🔗

(defun my-eshell-timestamp-update ()
    "When added to `eshell-pre-command-hook', the first string --:-- in the
  prompt becomes a timestamp like 13:59 after you run a command."
    (save-excursion
      (forward-line -1)
      (when-let* ((unfilled-timestamp "--:--")
                  (end (search-forward unfilled-timestamp nil t))
                  (beg (- end (length unfilled-timestamp)))
                  (inhibit-read-only t))
        (delete-region beg end)
        (insert (format-time-string "%H:%M"))
        (add-text-properties beg (point) '(font-lock-face eshell-prompt)))))

(defvar my-eshell-last-cmd-start nil)

(after! eshell
  ;; Always time commands that take longer than 1 second.
  (add-hook 'eshell-pre-command-hook
            (defun my-eshell-time-cmd-1 ()
              (require 'ts)
              (setq my-eshell-last-cmd-start (ts-now))))
  (add-hook 'eshell-post-command-hook
            (defun my-eshell-time-cmd-2 ()
              (when my-eshell-last-cmd-start
                (let ((n (ts-diff (ts-now) my-eshell-last-cmd-start)))
                  ;; Workaround for bug(?) that makes post-command-hook run
                  ;; after noops but pre-command hook doesn't run before. By
                  ;; nulling this we'll know next time if a real command did
                  ;; run, since it won't be nil anymore.
                  (setq my-eshell-last-cmd-start nil)
                  (when (> n 1)
                    (let ((inhibit-read-only t)
                          (beg (line-beginning-position)))
                      ;; TODO: position point correctly regardless
                      ;; of other post-command-hooks that may have run
                      (goto-char beg)
                      (insert
                       "Command finished, "
                       (if (> n 100)
                           (number-to-string (round n))
                         (let ((s (number-to-string n)))
                           (string-match (rx (* digit) "." digit) s)
                           (match-string 0 s)))
                       " s elapsed.\n")
                      (add-text-properties beg (point) '(font-lock-face eshell-prompt))
                      (goto-char (line-end-position))))))))

  ;; Custom prompt
  (add-hook 'eshell-pre-command-hook #'my-eshell-timestamp-update)
  (setq eshell-prompt-regexp
        (rx (or (seq bol "Command finished " (* nonl) eol
                     (* nonl) "] λ ")
                (seq bol (* nonl) "] λ ")))
        eshell-prompt-function (lambda () (concat "[--:--] λ ")))

  ;; Backrefs!
  (defvar my-eshell-backref-counter 0)
  (make-variable-buffer-local 'my-eshell-backref-counter)
  (add-hook 'eshell-post-command-hook
            ;; NOTE: bizarrely, variables made this way won't show up in
            ;; describe-variable, but echo $vX still works.
            (defun my-eshell-save-output-into-backref ()
              (let ((output (buffer-substring (eshell-beginning-of-output)
                                              (eshell-end-of-output))))
                (set (make-local-variable
                      (intern (format "v%d" (cl-incf my-eshell-backref-counter))))
                     output))
              (eshell-previous-prompt 1)
              (goto-char (line-beginning-position))
              (let ((beg (point))
                    (inhibit-read-only t))
                (insert "v" (number-to-string my-eshell-backref-counter) " ")
                (add-text-properties beg (point) '(font-lock-face eshell-prompt)))
              (eshell-next-prompt 1)))

What links here

Created (3 years ago)

Potential of slipboxes

My beliefs:

  • ([2022-01-21 Fri] 80% confidence): this will massively improve my life

My feelings:

  • [2022-01-21 Fri] I feel very good about it.

I see potential for slipboxes to help the owner with the following things and more

  • Internal Double Crux
  • Goal Factoring
    • when fleshing out a node, add how I feel about the topic
  • halos / affect heuristic
  • ugh fields
  • confirmation bias
  • keeping beliefs cruxy (The purpose of my personal wiki is Cruxiness)
  • beliefs not paying rent
  • circular belief networks
  • rationalization
  • Chesterton's Fences
  • cached thoughts
  • Help find semantic stopsigns
    • When you have no interest in fleshing out a node because it feels obvious or basic, at least write a blurb about your belief and its Epistemic status. This could help you detect a semantic stopsign or some such error, so you're at least aware of it. Such nodes aren't uninteresting extremities of your belief system – they are the underpinnings that justify it! Having access to these statements could also help you later if you want to explore these underpinnings more deeply.
  • bucket errors
    • automatically prevented by the nature of slipboxes, I think
  • inside/outside view (reference class forecasting)
    • Part of recipe
  • calibration / inner sim training / countering the availability heuristic
    • whenever possible, on every topic, present both data and examples on it
      • ideally, data is visualized according to good principles of data visualization
      • this can take so many forms, but for example when you write a node about bicycle tires, you can add an example about what products you might find in your local store and how to interpret the descriptions on those products
  • gears-level understanding
    • The slipbox confronts us with our lack of understanding
    • When a node links to another with an implication of causality, state the causal connection explicitly, and the how or why (if possible).
      • Instead of writing "Free market capitalism may lead to eco-collapse", you'd write "Free market capitalism may, by motivating selfish behavior, lead to eco-collapse". The idea is to make it easy to realize later on that you don't think this way anymore and reverse the conclusion. This requirement also naturally leads to asking "What do I know and why do I think I know it?", which is always good.
  • humility

Prosocial potential

Techno-optimism is unfashionable at the moment, but I suspect we still haven’t come close to realizing the potential of even the internet technology of the 1990s. When thousands of people converge on a topic, the collective knowledge far exceeds any one person, but our current interaction models don’t do a great job of synthesizing it. It’s a difficult problem, but it’s hard to imagine that in a hundred years we won’t have more effective ways to interact.

www.greaterwrong.com/posts/8mjoPYdeESB7ZcZvB/observations-about-writing-and-commenting-on-the-internet

See also The Garden and the Stream

What links here

Created (3 years ago)

Perceptually uniform colormap

This can be considered a form of honesty, Transparent language.

Graphing colors - for example, area charts showing intensity using the rainbow: not good. Intensity should be shown with luminance, not hue.

IBM did research on this back in the day. There is a collection of perceptually uniform maps at colorcet.com/. Also, Matplotlib adopted a new set of defaults in 2015. Lecture at www.youtube.com/watch?v=xAoljeRJ3lU.

Cool guide: seaborn.pydata.org/tutorial/color_palettes.html

What links here

Created (3 years ago)

Akaike Information Criterion

Bayesian methods, #statistics

Reasons for information criteria can be found in a book Information Theory and Statistics by Kullback. Explains well.

True model yi = 1 + x0.1 - x2 0.2 …

Various models (hundreds, thousands) ∑ …

Choose model by best (smallest) AIC/BIC/DIC/WAIC.

AIC = D train + 2p

AIC is an approximation that is reliable only when: (1) The priors are flat or overwhelmed by the likelihood. (2) The posterior distribution is approximately multivariate Gaussian. (3) The sample size N is much greater than the number of parameters k.

Watanabe-Akaike Information Criterion

Like AIC, you can rank models by WAIC. But a more interpretable measure is an Akaike weight. The weight for a model i in a set of m models is given by

wi=exp12dWAICij=1mexp12dWAICj w_i = \frac{ \exp{\frac12 \textrm{dWAIC}_i} }{ \sum^m_{j=1} \exp{\frac12 \textrm{dWAIC}_j} }

where dWAIC is the difference between each WAIC and the lowest WAIC, i.e. dWAIC = WAICi - WAICmin.

Leave-one-out cross-validation (LOO-CV)

New kid on the block, around 2020 it was the best (for which situations?).

Created (3 years ago)
Showing 125 to 128