Keyboard shortcuts

/ or ⌘/Ctrl K
Find a note
j / k
Next / previous section or linked note
h / l
Collapse or go to parent / expand or enter
e or Alt-click
Read a linked note here
o
Open focused note on its own
g g / G
First / last section or linked note
g h / g a
Home / all notes
g b / g t
Backlinks / table of contents
t
Cycle System, Light, Dark
? / Esc
Show / close this reference

Search: ↑/↓ or Ctrl N/P, Enter to open. Shortcuts pause while typing.

shell [9a7e312d]

Tags: computers

  • shell uses the readline2 lib
  • ^string1^string2 does word replace

    • Note that this doesn't work in fish
  • !^ and !$ map to the first and last arguments of the latest command, respectively

1. Redirects

  • Shells processes redirects in POSIX by left to right: pubs.opengroup.org/onlinepubs/9799919799/utilities/V3_chap02.html#:~:text=The%20shell%20performs%20redirection%20(see,operands%20from%20the%20parameter%20list.
  • Which means orders do matter
  • When the shell sees Wjhe, it doesn't create a symbolic link or dynamic reference call, it calls dup2(1,2)

    • dup2(oldfd, newfd) copies the file description (internal kernel pointer to open file) from oldfd ot newfd. Once it's copied,. it doesn't change the oldfd.
  • so ls > file 2>&1 works because

    • > file opens, file, kernel assigns it a fd, X, and then calls dup2(X, 1), so now FD 1 points to file
    • 2>&1 shell calls dup2(1, 2), which looks at what 1 has
  • but ls 2>&1 > file doesn't work because it duplicates 1,FD 1 to 2, and then still remains it TTY. But > file then redirects back to file