shell
BOM
Byte Order Marks are heading a file to determine Endianness. Unfortunately BOM inhibits the interpretation of the #!SHEBANG line in shell scripts and therefore need to be removed. Make sure to configure your editor (like kate) to not use BOM (default=no) when saving shell scripts.
Simple way to remove BOM
1 % hexdump -C /usr/local/bin/pdf_minify.sh | head -n1
2 00000000 ef bb bf 23 21 2f 62 69 6e 2f 62 61 73 68 0a 0a |...#!/bin/bash..|
3 % vim /usr/local/bin/pdf_minify.sh
4 ### :set nobomb
5 ### :wq
6 % hexdump -C /usr/local/bin/pdf_minify.sh | head -n1
7 00000000 23 21 2f 62 69 6e 2f 62 61 73 68 0a 0a 23 23 23 |#!/bin/bash..###|
8
Terminal keyboard shortcuts
Emacs mode vs Vi Mode
All the following commands assume that bash is running in the default Emacs setting, if you prefer this can be switched to Vi shortcuts instead.
Set Vi mode in bash
1 $ set -o vi
Set Emacs mode in bash
1 $ set -o emacs
Current terminal configuration
Incredibly informative write-up
linusakesson.net Linus Åkesson - The TTY demystified
Show current terminal configuration
1 # stty -a|fold -s
2 speed 38400 baud; rows 59; columns 238; line = 0;
3 intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>;
4 eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R;
5 werase = ^W; lnext = ^V; discard = ^O; min = 1; time = 0;
6 -parenb -parodd -cmspar cs8 -hupcl -cstopb cread -clocal -crtscts
7 -ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon ixoff
8 -iuclc -ixany -imaxbel iutf8
9 opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
10 isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt
11 echoctl echoke -flusho -extproc
Bash readline features
Please see man bash and take a look at the section "READLINE".
Standard bash keyboard shortcuts EMACS mode
1 ### MAYBE MAPPED BY SCREEN AS PREFIX
2 ^a START OF LINE (HOME)
3 ### MAYBE MAPPED BY TMUX AS PREFIX
4 ^b BACK ONE CHAR
5 ^c KEYBOARD INTERRUPT
6 ^d DELETE CHARACTER UNDER CURSOR OR IF LINE EMPTY AND CURSOR AT START OF LINE: SEND EOF -> HANG OFF
7 ^e END OF LINE (END)
8 ^f FORWARD ONE CHAR
9 ^g ESCAPE FROM HISTORY SEARCHING MODE
10 ^h DELETE CHARACTER BEFORE CURSOR (BACKSPACE)
11 ^i HORIZONTAL TAB
12 ^j NEWLINE
13 ^k CUT EVERYTHING TILL END OF LINE INTO CLIPBOARD
14 ^l clear screen
15 ^m RETURN
16 ^n NEXT COMMAND IN HISTORY
17 ^o RETURN AND SHOW NEXT COMMAND OF HISTORY
18 ^o PREVIOUS COMMAND IN HISTORY
19 ^q SCROLL UNLOCK
20 ^r SEARCH HISTORY
21 ^s SCROLL LOCK
22 ^t SWITCH LAST TWO CHARS
23 ^u CUT EVERYTHING TILL START OF LINE TO CLIPBOARD
24 ^v VERBATIM INPUT
25 ^w CUT WORD BACKWARDS INTO CLIPBOARD
26 ^x^x JUMP BETWEEN CURRENT CURSOR POSITION AND START OF LINE
27 ^y PASTE CLIPBOARD (CUTTED BY ^k/^u/^w)
28 ^z SEND SIGTSTP TO PROCESS -> SUSPEND
29 ^\ KILL PROCESS BRUTALLY
30 ^[ ESCAPE
31 ^_ UNDO
32
33
34 ### MAPPINGS
35 ^1
36 ^2 ^@
37 ^3 ^[ (ESCAPE)
38 ^4 ^\ (KILL)
39 ^5 ^]
40 ^6 ^^
41 ^7 ^_ (UNDO)
42 ^8 ^? (BACKSPACE)
43 ^9
44 ^0
45
46 ### ALT IS THE META KEY
47 M-b BACK (LEFT) ONE WORD
48 M-c CAPITALIZE THE CHARACTER UNDER THE CURSOR AND MOVE TO THE END OF THE WORD
49 M-d DELETE ONE WORD
50 M-f FORWARD (RIGHT) ONE WORD
51 M-l LOWERCASE ALL CHARS FROM CURSOR TO END OF WORD AFTER CURSOR
52 M-r CANCEL THE CHANGES AND PUT BACK THE LINE AS IT WAS IN THE HISTORY (REVERT)
53 M-t SWAP WORD WITH PREVIOUS WORD
54 M-u CAPITALIZE ALL CHARS FROM CURSOR TO END OF WORD AFTER CURSOR
55 M-< START OF HISTORY
56 M-> END OF HISTORY
57 …
58
59
60 ### WORD MANIPULATION
61 ESC-c CAPITALIZE WORD AFTER CURSOR
62 ESC-u CAPITALIZE ALL CHARS OF WORD AFTER CURSOR
63 ESC-l LOWER CASE ALL CHARS OF WORD AFTER CURSOR
64 ESC-t SWAP LAST TWO WORDS BEFORE THE CURSOR
65 ESC-. INSET LAST WORD OF PREVIOUS COMMAND IN HISTORY
66 ESC-_ SAME AS ESC-.
67
68 ### COMPLETIONS
69 TAB Attempt general completion
70 ESC-TAB Attempt completion from previous commands in history
71 ESC-? List possible completions
72 ESC-/ Attempt filename completion
73 ^x / List possible filename completion
74 ESC-~ Attempt username completion
75 ^x ~ List possible username completion
76 ESC-$ Attempt variable completion
77 ^x $ List possible variable completion
78 ESC-@ Attempt hostname completion
79 ^x @ List possible hostname completion
80 ESC-! Attempt command completion
81 ^x ! List possible command completion