Saturday 28 November 2015

emacs motion

emacs motion

C-f: forward one char
C-b: backward one char
C-p: previous line
C-n: next line

C-a: beginning of line
C-e: end of line
M-f: forward one word
M-b: backward one word

C-v: forward one screen
M-v: backward one screen
M-a: beginning of sentence
M-e: end of sentence
C-l: center the screen
M-r: cycle point through top, middle and bottom of the screen
M-<: jump to the top of the buffer
M->: jump to the end of the buffer
M-g c: jump to the nth character
M-g l: jump to the nth line

C-M-f: forward over balanced expression (eg: braces in C++ code)
C-M-b: backward over balanced expression
C-M-k: delete balanced expression
C-M-<SPC> or C-M-@: mark balanced expression

emacs ibuffer

ibuffer

In ~/.emacs.d/init.el:

;; replace `list-buffers` with `ibuffer`
(global-set-key (kbd "C-x C-b") 'ibuffer)

Open ibuffer by C-x C-b

Create filters:

/m: filter by a major mode
/n: filter by buffer name.
/c: filter by buffer content.
/f: filter by filename
/>: filter by buffer size
/<: filter by buffer size
//: remove all filters in effect

Filtered groups:

/g: create a filter group from filters
TAB: move to next filter group
M-p: move to previous filter group
/\: remove all active filter groups
/S: save the current groups with a name
/R: restore previously saved groups
/X: delete previously saved groups

Every time you open a file which matches a filter it will appear under the group

o on a file will open that file and switch focus to it
C-o on a file will open that file and leave focus in ibuffer
C-x o switches focus to the other window

Saturday 7 November 2015

Create a bootable USB from an ISO using dd on the Linux command line

Install syslinux, a suite of utilities which ensures the iso image is in SYSLINUX format rather than ISOLINUX

    $ sudo apt-get install syslinux

Convert the iso image to SYSLINUX format

    $ isohybrid /path/image.iso 

Locate the USB device 

    $ lsblk
    sdb         8:16   1   3.8G  0 disk 
    └─sdb1      8:17   1   3.8G  0 part /media/user/usb_disk

Unmount the USB device

    $ sudo umount /dev/sdb1

Ensure it is indeed unmounted

    $ lsblk
    sdb         8:16   1   3.8G  0 disk 
    └─sdb1      8:17   1   3.8G  0 part 

Copy the ISO image onto the USB deisk

    $ sudo dd if=/path/image.iso of=/dev/sdb1