Pages

Saturday, 13 July 2013

Linux - emacs cheat sheet

Basic emacs

C denotes the Ctrl key, so C-x means press Ctrl and x together. M denotes the Alt key in the same way.

Launch emacs:
emacs -nw -Q

Display interactive tutorial:
M-x help-with-tutorial

Full reference card can be found here.

Emacs and the node.JS REPL

Launch emacs:
emacs -nw file.js

C-x 3           Split the window vertically
C-c !            Launch node.js REPL within emacs
M-o             Toggle to the other window
C-c C-j        Send current line of code to REPL and execute it
C-c C-r        Send the marked region of code to REPL and execute it (see reference card for how to mark)

Tuesday, 9 July 2013

Linux - screen cheat sheet

Notes from this tutorial. The tutorial also includes info on sharing screens, which is not here.

Command Description
sudo apt-get install screen Install screen
screen Launch screen
Ctrl-t, then d Detach screen
screen -list Show all available screen sessions
screen -r
screen -r -t name
Reattach to an existing screen session
Reattach to the specific window name
Ctrl-t, then c
screen
screen -t name
Create a new window
The last command will create a window and give it a name
Ctrl-t, then " (double quotation)
Ctrl-t, then 0 to 9
Ctrl-t, then Ctrl-t again
Navigate windows by pressing up and down arrow keys, and enter to choose
Jump to the window number specified
Toggle between current and previous windows
exit
Ctrl-t, then K
Ctrl-t, then Ctrl-\
Kill the current window
Kill the current window
Kill all windows and exit
Ctrl-t, then A Annotate (name) the current window
Make a .screenrc file in home directory, with the following:
hardstatus on
hardstatus alwayslastline
hardstatus string "%{.bW}%-w%{.rW}%n %t%{-}%+w %=%{..G} %H %{..Y} %m/%d %C%a
Each new window will display a status line, which will include the window's name
Ctrl-t, then ? Help
screen -L

Ctrl-t, then H
Log the output from the current window to a file named ~/screenlog.n, where n is the window number
Toggle logging on and off
Ctrl-t, then C Clear a window

If screen stopped responding:

List screens:
screen -list

Output:
There is a screen on: 
   23536.pts-0.wdzee (10/04/2012 08:40:45 AM) (Detached) 
1 Socket in /var/run/screen/S-root.

Kill screen session:
screen -S 23536 -X quit