기본 콘텐츠로 건너뛰기

[Terminal HotKey] Emacs key bindings.(set -o emacs)

source: myself
Useful Keyboard shortcuts in Vim

Find next: Shift+3(which is #)
Find previous:  Shift+8(which is *)

source: http://en.wikipedia.org/wiki/Bash_%28Unix_shell%29

Keyboard shortcuts[edit]

The following shortcuts work when using default (Emacs) key bindings. Vi-bindings can be enabled by running set -o vi.[23]
Note: For shortcuts involving  Alt, you may be able to use  Esc instead.
Note: Sometimes, you must use  Esc instead of  Alt, because the  Alt shortcut conflicts with another shortcut. For example, in Trisquel 5.0 (a distribution of Linux), pressing  Alt+f will not move the cursor forward one word, but will activate "File" in the menu of the terminal window.
  • Tab  : Autocompletes from the cursor position.
  • ^ Ctrl+a : Moves the cursor to the line start (equivalent to the key  Home).
  • ^ Ctrl+b : Moves the cursor back one character (equivalent to the key ).
  • ^ Ctrl+c : Sends the signal SIGINT to the current task, which aborts and closes it.
  • ^ Ctrl+d
    • Sends an EOF marker, which (unless disabled by an option) closes the current shell (equivalent to the command exit). (Only if there is no text on the current line)
    • If there is text on the current line, deletes the current character (then equivalent to the key Delete).
  • ^ Ctrl+e : (end) moves the cursor to the line end (equivalent to the key  End).
  • ^ Ctrl+f : Moves the cursor forward one character (equivalent to the key ).
  • ^ Ctrl+g : Abort the research and restore the original line.
  • ^ Ctrl+h : Deletes the previous character (same as backspace).
  • ^ Ctrl+i : Equivalent to the tab key.
  • ^ Ctrl+j : Equivalent to the enter key.
  • ^ Ctrl+k : Clears the line content after the cursor and copies it into the clipboard.
  • ^ Ctrl+l : Clears the screen content (equivalent to the command clear).
  • ^ Ctrl+n : (next) recalls the next command (equivalent to the key ).
  • ^ Ctrl+o : Executes the found command from history, and fetch the next line relative to the current line from the history for editing.
  • ^ Ctrl+p : (previous) recalls the prior command (equivalent to the key ).
  • ^ Ctrl+r : (research) recalls the last command including the specified character(s). A second ^ Ctrl+r recalls the next anterior command which corresponds to the research
  • ^ Ctrl+s : Go back to the next more recent command of the research (beware to not execute it from a terminal because this command also launches its XOFF). If you changed that XOFF setting, use^ Ctrl+q to return.
  • ^ Ctrl+t : Transpose the previous two characters.
  • esc+t : Swap the last two words before the cursor
  • ^ Ctrl+u : Clears the line content before the cursor and copies it into the clipboard.
  • ^ Ctrl+v : If the next input is also a control sequence, type it literally (e. g. * ^ Ctrl+v ^ Ctrl+h types "^H", a literal backspace.)

  • ^ Ctrl+w : Clears the word before the cursor and copies it into the clipboard.
  •  Alt+d : Cuts the word after the cursor.

  • ^ Ctrl+x ^ Ctrl+e : Edits the current line in the $EDITOR program, or vi if undefined.
  • ^ Ctrl+x ^ Ctrl+r : Read in the contents of the inputrc file, and incorporate any bindings or variable assignments found there.
  • ^ Ctrl+x ^ Ctrl+u : Incremental undo, separately remembered for each line.
  • ^ Ctrl+x ^ Ctrl+v : Display version information about the current instance of bash.
  • ^ Ctrl+x ^ Ctrl+x : Alternates the cursor with its old position. (C-x, because x has a crossing shape).
  • ^ Ctrl+y : (yank) adds the clipboard content from the cursor position.
  • ^ Ctrl+z : Sends the signal SIGTSTP to the current task, which suspends it. To execute it in background one can enter bg. To bring it back from background or suspension fg ['process name or job id'](foreground) can be issued.
  • ^ Ctrl+_ : Incremental undo, separately remembered for each line.
  •  Alt+b : (backward) moves the cursor backward one word.
  •  Alt+c : Capitalizes the character under the cursor and moves to the end of the word.

  •  Alt+f : (forward) moves the cursor forward one word.
  •  Alt+r : Cancels the changes and puts back the line as it was in the history.

  •  Alt+u : Capitalizes every character from the cursor's position to the end of the current word.
  •  Alt+l : Lowers the case of every character from the cursor's position to the end of the current word.

  •  Alt+. : Insert the last argument to the previous command (the last word of the previous history entry).
You can also highlight text and use Ctrl-Shift-c to copy, and Ctrl-Shift v to paste (at least in GNOME Terminal in Ubuntu).

Bash is very common shell, for example. It uses Readline library to implement command line input. And so to say, it is very convenient to know Readline bindings since it is used not only in bash. For example, gdb also uses Readline to process input.
In Readline documentation you can find all navigation related bindings (and more):http://www.gnu.org/software/bash/manual/bash.html#Readline-Interaction
Short copy-paste if the link above goes down:
Bare Essentials
  • C-b Move back one character.
  • C-f Move forward one character.
  • [DEL] or [Backspace] Delete the character to the left of the cursor.
  • C-d Delete the character underneath the cursor.
  • C-_ or C-x C-u Undo the last editing command. You can undo all the way back to an empty line.
Movement
  • C-a Move to the start of the line.
  • C-e Move to the end of the line.
  • M-f Move forward a word, where a word is composed of letters and digits.
  • M-b Move backward a word.
  • C-l Clear the screen, reprinting the current line at the top.
Kill and yank
  • C-k Kill the text from the current cursor position to the end of the line.
  • M-d Kill from the cursor to the end of the current word, or, if between words, to the end of the next word. Word boundaries are the same as those used by M-f.
  • M-[DEL] Kill from the cursor the start of the current word, or, if between words, to the start of the previous word. Word boundaries are the same as those used by M-b.
  • C-w Kill from the cursor to the previous whitespace. This is different than M- because the word boundaries differ.
  • C-y Yank the most recently killed text back into the buffer at the cursor.
  • M-y Rotate the kill-ring, and yank the new top. You can only do this if the prior command is C-y or M-y.
M is Meta key. For Max OS X Terminal you can enable "Use option as meta key" in Settings/Keyboard for that. For Linux its more complicated.
Update
Also note, that Readline can operate in two modes:
  • emacs mode (which is the default)
  • vi mode
To switch Bash to use vi mode:
$ set -o vi
Personaly I prefer vi mode since I use vim for text editing.
In the standard Ubuntu terminal, Meta (M) is Alt+Shift, unless you disable the menu access keyboard shortcuts in which case it is just Alt. (THIS IS IT!!!)

댓글

이 블로그의 인기 게시물

[맞춤법] 안돼(o) vs 안되(x); 안돼요(o) 안되요(x); 안되지(o) vs 안돼지(x);

source:  http://k.daum.net/qna/view.html?qid=0FKVD&l_cid=Q&l_st=1 쉽게 구분하는 방법만 말씀드리겠습니다.   안돼요는 안되어요가 줄어든 말입니다. 예를 들어보겠습니다.   당신이 그러면 안되지. 당신이 그러면 안돼지.   첫번째 문장이 맞고 두번째 문장이 틀립니다. 두번째 문장을 '당신이 그러면 안되어지'로 바꾸면 말이 이상하지요. '안돼지'로 쓸 수 있는 것은 '안되어지'로 쓸 수 있는 것입니다.   요즘 사업이 잘 안(돼서 되서) 죄송합니다. '돼서'와 '되서' 가운데 어떤 것이 맞을까요? 사업이 잘 '안되어서'가 말이 되니까 '안돼서'가 맞습니다.   즉, 이 두가지를 쉽게 구분하는 방법은 '돼' 자리에 '되어'를 넣어봐서 말이 되면 '돼'고 말이 안되면 '되'를 쓰면 됩니다.   아니면   되 자리에 하를 넣어보고   돼 자리에 해를 넣어서 어색하지 않으면 그대로 쓰면 됩니다.   안되요는 안하요가 되니 틀린 말이고   안돼요는 안해요가 되니 맞는 말입니다.   결국 안돼요가 표준어입니다.

[인코딩] MS949부터 유니코드까지

UHC = Unified Hangul Code = 통합형 한글 코드 = ks_c_5601-1987 이는 MS사가 기존 한글 2,350자밖에 지원하지 않던 KS X 1001이라는 한국 산업 표준 문자세트를 확장해 만든 것으로, 원래 문자세트의 기존 내용은 보존한 상태로 앞뒤에 부족한 부분을 채워넣었다. (따라서 KS X 1001에 대한 하위 호환성을 가짐) 그럼, cp949는 무엇일까? cp949는 본래 코드 페이지(code page)라는 뜻이라 문자세트라 생각하기 십상이지만, 실제로는 인코딩 방식이다. 즉, MS사가 만든 "확장 완성형 한글 ( 공식명칭 ks_c_5601-1987 ) "이라는 문자세트를 인코딩하는 MS사 만의 방식인 셈이다. cp949 인코딩은 표준 인코딩이 아니라, 인터넷 상의 문자 송수신에 사용되지는 않는다. 하지만, "확장 완성형 한글" 자체가 "완성형 한글"에 대한 하위 호환성을 고려해 고안됐듯, cp949는 euc-kr에 대해 (하위) 호환성을 가진다. 즉 cp949는 euc-kr을 포괄한다. 따라서, 윈도우즈에서 작성되어 cp949로 인코딩 되어있는 한글 문서들(txt, jsp 등등)은 사실, euc-kr 인코딩 방식으로 인터넷 전송이 가능하다. 아니, euc-kr로 전송해야만 한다.(UTF-8 인코딩도 있는데 이것은 엄밀히 말해서 한국어 인코딩은 아니고 전세계의 모든 문자들을 한꺼번에 인코딩하는 것이므로 euc-kr이 한국어 문자세트를 인코딩할 수 있는 유일한 방식임은 변하지 않는 사실이다.) 물론 이를 받아보는 사람도 euc-kr로 디코딩을 해야만 문자가 깨지지 않을 것이다. KS X 1001을 인코딩하는 표준 방식은 euc-kr이며 인터넷 상에서 사용 가능하며, 또한 인터넷상에서 문자를 송수신할때만 사용.(로컬하드에 저장하는데 사용하는 인코딩방식으로는 쓰이지 않는 듯하나, *nix계열의 운영체제에서는 LANG을 euc-kr로 설정 가능하기도 한걸...

한글 인코딩의 이해 : 한글 인코딩의 역사와 유니코드, 그리고 유니코드와 Java를 이용한 한글 처리

출처 : http://helloworld.naver.com/helloworld/76650 NHN Business Platform 쇼핑서비스개발팀 오영은 분명 제대로 보이는 한글 이름의 파일을 내려받았는데 읽을 수 없는 이상한 이름으로 저장된 파일을 받아본 경험이 있을 것입니다. 보통 '인코딩이 깨졌다.'라고 말하는 이런 상황은 왜 발생하는 것일까요? 그 이유는 컴퓨터에서 한글을 표현하는 다양한 방식이 있는데 해당 방식이 서로 맞지 않기 때문입니다. 최초로 컴퓨터가 발명되고 오랜 기간 동안 발전되어 온 지역이 미국이기에 해당 지역에서 사용하는 언어의 문자 집합인 영어 알파벳과 이와 비슷한 문자 체계를 지닌 유럽어 알파벳 처리에 대한 연구가 가장 먼저 시작되었습니다. 이 외의 다른 문자 집합(character set)은 기존에 수립된 인코딩(영어 및 유럽어 문자 집합용)으로 표현하기에는 한계가 있었기 때문에 이들을 처리하기 위한 연구가 추가로 진행되었습니다. 요즘은 어느 전자 기기에서나 한글을 제대로 입력할 수 있고 일부 소형 기기에서는 한글을 더 빠르게 입력할 수도 있어 컴퓨터에서 한글을 처리하는 작업이 너무나 쉽고 당연하게 받아들여지고 있습니다. 하지만 한글을 제대로 표현하기 위한 한글 인코딩 체계가 수립되기까지는 수십 년의 세월이 걸렸습니다. 현재 우리나라에서 주로 사용하고 있는 CP949 또는 EUC-KR(둘은 엄밀히 다릅니다) 인코딩과 유니코드를 제대로 이해하기 위해서는 한글을 표현하기 위한 그간의 역사를 알 필요가 있습니다. 2편 연작으로 기획된 이 기사의 1편에서는 한글 인코딩의 역사를 다루고, 2편에서는 'Java 언어를 기준으로 한글을 처리하는 방법'을 다루도록 하겠습니다. 문자 집합과 인코딩 컴퓨터는 수치 연산을 위해 설계되었다. 컴퓨터 발명 초기에는 문자를 표현해야 하는 요구가 없었다. 영어 단어 'compute'는 단순히 '계산하다'라는 ...