復ç¿ãã¦ãã¾ã¨ãã¦ã¿ããä»ããæãã£ã·ãã§ãã¶ã100çªç ããããã ãã©ããã£ããã¯åèªåä½ã§ã«ã¼ã½ã«ã移åããã(M-f,M-b)æ¹æ³ãç¥ãããã£ãã ããªãã ãã©ããã£ãããªã®ã§ã©ãã§ãã©ããã風ã«ãã¼ãã¤ã³ããå²ãå½ã¦ããã¦ãããã調ã¹ãã
versionã¯debian4ã®bash 3.1.17ã
readlineã¨bind(çµã¿è¾¼ã¿ã³ãã³ã)
man bashã®readlineã¨bindã®é
ç®åç
§ãreadlineã¯ã·ã§ã«ã®å
¥åãå¦çããã©ã¤ãã©ãªãbashã¯çµã¿è¾¼ã¿ã®ã³ãã³ãã§readlineã®å²ãå½ã¦è¨å®ç¢ºèª/è¨å®å¤æ´ãåºæ¥ãã
端æ«ã©ã¤ã³ã®ãã¼ãã¤ã³ã
ãã¦ããã£ããbashã®ãã¼ãã¤ã³ãâ¦ã®åã«ãã·ã§ã«ã¨ã¯å¥ã®ç«¯æ«ã®ãã¼ãã¤ã³ããã¾ã¨ãã¦ãããbashã¨ã¯ç´æ¥é¢ä¿ãªããã©ã端æ«ãCLIã®æä½ããã¼ãã¤ã³ãã§è¡ãã¨ããæå³ã§ã¯ãã»ã¼åããªã®ã§ã
æåãªã®ã¯ããã»ã¹ãå²ãè¾¼ãC-c(interrupt)ããä¸æããC-z(suspend)ãåºåãåæ¢ããC-s(stop)ãªã©ãªã©ãã·ã§ã«ã®æ©è½ã§ã¯ãªãã®ã§ãbashã ãã§ãªãä»ã®ã·ã§ã«(shãcshãzshãªã©)ã§ãåãããã«åããã¯ãã
è¨å®ç¢ºèª
$ stty -a
詳細ã¯man 1 sttyã
主ãªãã¼ãã¤ã³ã
ãã¼ãã¤ã³ã | name | 説æ |
---|---|---|
C-c | intr | å²è¾¼ã¿ã·ã°ãã«ãéã(ããã»ã¹çµäº) # kill -2, kill -INT |
C-\ | quit | ä¸æ¢ã·ã°ãã«ãéã(ããã»ã¹ä¸æ¢) # kill -3, kill -QUIT |
C-z | susp | åæ¢ã·ã°ãã«ãéã(ããã»ã¹ä¸æ) => fgãbgã§åéã§ãã # kill -STOP |
C-d | eof | EOFãå ¥åãã(ãã¡ã¤ã«ã®çµãã) |
C-u | erase | ã«ã¼ã½ã«ããåã«ããæåãåé¤ |
C-w | werase | ç´åã®åèªãåé¤ |
C-s | stop | ç»é¢ã¸ã®åºåãåæ¢ãã |
C-q | start | C-sã§åæ¢ãã¦ããç»é¢ã¸ã®åºåãåéãã |
C-sã®åºååæ¢
ä¸è¦ããã¨ç«¯æ«ããã³ã°ããããã«è¦ãããããåºåãæ¢ã¾ã£ã¦ããã ãã§ç«¯æ«ã¸ã®å ¥åã¯çãã¦ãããã³ãã³ãããã¡ããå®è¡ããããbashã§ã¯C-sã¯å±¥æ´ã®ã¤ã³ã¯ãªã¡ã³ã¿ã«ãµã¼ãã«å²ãå½ã¦ããã¦ãããã©ãsttyã§ã¯ç»é¢ã®åæ¢ã«å²ãå½ã¦ããã¦ããã®ã§ããã¡ããåªå ããããå人çã«ã¯ãã®åæ¢ã®æ©è½ããã£ããæ··ä¹±ãã¦ãã¾ãã ãã®ãããªãåã ã¨æã£ã¦ããã®ã§ç¡å¹ã«ãã¦ãã¾ããWindowsã®çã§ãã¡ã¤ã«ãä¸æ¸ããããã¨ãã¦ããã£ãããããæ¼ãã¦ã¾ãã¾ãããããããã
C-sã«ããç»é¢ã®åæ¢ãç¡å¹ã«ãã
åè: http://www.itmedia.co.jp/help/tips/linux/l0612.html.bashrcãããã«
stty stop undef
ã¨æ¸ãã¦ããã¨ã次åãã°ã¤ã³æããèªåçã«åæ ã
bashã®ãã¼ãã¤ã³ã
é話ä¼é¡ãkeymapã¯ããã©ã«ãã®emacsã¨ãã(ãªã®ã§emacs使ãã®äººã«ã¨ã£ã¦ã¯å¤§åã¯å¸¸èã®å 容)ãã¡ãªã¿ã«man bashã®ä¸ã§ã¯ãã¼ãã¤ã³ãã§ã¯ãªãã¦ãã¼ã·ã¼ã±ã³ã¹ã¨èª¬æããã¦ããã
çµã¿è¾¼ã¿ã³ãã³ãã®bind -sã§readlineã®ãã¯ããbind -pã§readlineã®é¢æ°ã表示ãããããã®ãã¡ãè¯ã使ããã®/é ã«å ¥ãã¦ããã°ä¾¿å©ãããããªããã®ãã¾ã¨ãã¦ã¿ããè¤æ°ã®ãã¼ãã¤ã³ããå²ãå½ã¦ããã¦ããé¢æ°ã¯ãåºæ¬çã«ç°¡åãªãã®ã ãæ¸ããä¾ãã°ã1ã¤åã®åèªã«æ»ããã¼ãã¤ã³ãã¯M-d以å¤ã«ãM-[1;5Dã¨ããåªæã®ãããªãã®ããããã©ããã¯çãã
$ bind -p | egrep -v '^#|self-insert|do-lowercase-version|digit-argument'
ã®çµæããæ½åºãCtrlã¯æåãMeta(AltãEsc)ã¯åèªåä½ã«ãªã£ã¦ããã¨ãå¤ãï¼
ã³ãã³ãå®è¡
ãã¼ãã¤ã³ã | readlineã®é¢æ°å | 説æ |
C-g | abort | CtrlãAltãEscãªã©ã®å ¥åãä¸æ¢ |
C-j | accept-line | Enter |
C-m | accept-line | Enter |
C-o | operate-and-get-next | Enterãã¦ãç¾å¨ã®å ¥åå 容ã次ã®å ¥åã«å©ç¨ãé£ç¶ãã¦åãã³ãã³ãå®è¡ããã¨ãã¨ã |
C-x C-e | edit-and-execute-command | ã¨ãã£ã¿ãèµ·åãã¦å®è¡ããã³ãã³ããå ¥å *1 |
ã«ã¼ã½ã«ç§»åç³»
ãã¼ãã¤ã³ã | readlineã®é¢æ°å | 説æ | |
C-a | beginning-of-line | è¡é ã«ç§»å # Home | |
C-e | end-of-line | è¡æ«ã«ç§»å # End | |
C-b | backward-char | 1æåæ»ã # â | |
C-f | forward-char | 1æåé²ã # â | |
C-n | next-history | 次ã®å±¥æ´ã表示 # â | |
C-p | previous-history | åã®å±¥æ´ # â | |
M-f | forward-word | 次ã®åèªã«ç§»å | |
M-b | backward-word | åã®åèªã«ç§»å | |
M-< | beginning-of-history | å±¥æ´ã®å é ã表示 | |
M-> | end-of-history | å±¥æ´ã®æå¾ã表示 |
æåå ¥åãåé¤ãè²¼ãä»ã
ãã¼ãã¤ã³ã | readlineã®é¢æ°å | 説æ |
C-h | backward-delete-char | ç´åã®1æåãåé¤ # BackSpace |
C-d | delete-char | ç´å¾ã®1æåãåé¤ # Delete |
C-w | unix-word-rubout | ç´åã®1åèªãåé¤(åèªå¢çã¯ç©ºç½é¡) |
MC-h | backward-kill-word | ç´åã®1åèªãåé¤ |
M-d | kill-word | ç´å¾ã®1åèªãåé¤ |
C-u | unix-line-discard | ã«ã¼ã½ã«ä»¥åã®æåãåé¤ # ãã¹ã¯ã¼ãééã£ãã¨ããªã©ã« |
C-k | kill-line | ã«ã¼ã½ã«ä»¥éã®æåãåé¤ |
C-y | yank | åé¤,killããåèªãè²¼ãä»ã |
C-t | transpose-chars | ç´åã®æåã¨ããã®åã®æåãå ¥ãæ¿ãã |
æ¤ç´¢ãè£å®
ãã¼ãã¤ã³ã | readlineã®é¢æ°å | 説æ |
C-r | reverse-search-history | å±¥æ´ãå¾æ¹ã«(é¡ã£ã¦)ã¤ã³ã¯ãªã¡ã³ã¿ã«ãµã¼ã |
C-s | forward-search-history | å±¥æ´ãåæ¹ã«ã¤ã³ã¯ãªã¡ã³ã¿ã«ãµã¼ã *2 |
C-i | complete | ã³ãã³ããå¼æ°ãªã©ãé©ããåèªãè£å® # Tab |
M-! | complete-command | ã³ãã³ããè£å® |
M-/ | complete-filename | filenameãè£å® |
M-@ | complete-hostname | hostnameãè£å® # /etc/hosts ãã? |
M-~ | complete-username | usernameãè£å® # /etc/passwd ãã? |
M-$ | complete-variable | ã·ã§ã«å¤æ°ãè£å® |
M-. | insert-last-argument | ç´åã®ã³ãã³ãã®æå¾ã®å¼æ°ãæ¿å ¥ |
C-x* | glob-expand-word | globãå±éãã |
M-* | insert-completions | è£å®å¯¾è±¡ã®åèªãå¼æ°ã«æ¿å ¥ |
ãã®ä»
ãã¼ãã¤ã³ã | readlineã®é¢æ°å | 説æ |
C-l | clear-screen | ã¿ã¼ããã«ãã¯ãªã¢ # clearã³ãã³ã |
M-l | downcase-word | ç´å¾ã®åèªã大æåã«å¤æ |
M-u | upcase-word | ç´å¾ã®åèªã大æåã«å¤æ |
C-xC-r | re-read-init-file | .inpurtc?ãreload |
C-xC-v | display-shell-version | version表示 |
ãããªããï¼
readlineã®å²ãå½ã¦ãå¤æ´ãã
- .inputrcã«æ¸ãã¦ãã
- bindã³ãã³ãã§å²ãå½ã¦ã
- bind -f filename (.inputrcæ¸å¼) ããèªã¿è¾¼ã
man bashããã
bind [-m keymap] -x keyseq:shell-command bind [-m keymap] [-q function] [-u function] [-r keyseq] bind [-m keymap] -f filename bind [-m keymap] keyseq:function-name (ä¸ç¥) -l readlineé¢æ°ã®ååãå ¨ã¦ãªã¹ã表示ãã¾ãã -p readlineã®é¢æ°ã®ååã¨å²ãå½ã¦ã表示ãã¾ãã表示ã¯ãåã³èªã¿è¾¼ã¿ã§ããå½¢å¼ã§åºåããã¾ãã -P readlineã®é¢æ°ã®ç¾å¨ã®ååã¨å²ãå½ã¦ããªã¹ã表示ãã¾ãã -v readlineã®å¤æ°åã¨å¤ã表示ãã¾ãã表示ã¯ãåã³èªã¿è¾¼ã¿ã§ããå½¢å¼ã§åºåããã¾ãã -V readlineã®ç¾å¨ã®å¤æ°åã¨å¤ããªã¹ã表示ãã¾ãã -s readlineã®ãã¯ãã«å²ãå½ã¦ããããã¼ã·ã¼ã±ã³ã¹ã¨ããã¯ããåºåããæååã表示ãã¾ãã 表示ã¯ãåã³èªã¿è¾¼ã¿ã§ããå½¢å¼ã§åºåããã¾ãã -S readlineã®ãã¯ãã«å²ãå½ã¦ããããã¼ã·ã¼ã±ã³ã¹ã¨ããã¯ããåºåããæååã表示ãã¾ãã -f filename ãã¼å²ãå½ã¦ã filename ããèªã¿è¾¼ã¿ã¾ãã -q function æå®ããã function ãå¼ã³åºããã¼ãåãåããã¾ãã -u function æå®ããã function ã«å²ãå½ã¦ããã¦ãããã¼ã®å²ãå½ã¦ãå ¨ã¦åãæ¶ãã¾ãã -r keyseq keyseq ã«å¯¾ããç¾å¨ã®å²ãå½ã¦ãåé¤ãã¾ãã -x keyseq:shell-command keyseq ãæ¼ããããã³ãã¨ã«ã shell-command ãå®è¡ãããããã«ãã¾ãã
- readlineé¢æ°ãå²ãå½ã¦ã
ã³ãã³ãã§ç´æ¥å²ãå½ã¦ãã¨ãã¯quoteããªãã¨ãããªãã
$ bind '"\C-x\C-h": backward-kill-line' $ bind -p | grep '\\C-x\\C-h' "\C-x\C-h": backward-kill-line
- ãã¯ã
C-oã§" > output"ãæ¿å ¥ããã
$ bind '"\C-o": " > output"' $ bind -s | grep output "\C-o": " > output"
- ä»»æã®ã³ãã³ããå²ãå½ã¦ã
C-xC-sã§sshãã°ã¤ã³ãå®è¡ããã ããå²ãå½ã¦ãã³ãã³ãã¯bindã§ç¢ºèªã§ããªãã½ãï¼
$ bind -x '"\C-x\C-s": ssh [email protected]'
ã¾ãè¯ã使ãã³ãã³ããªãaliasãã¨ãã°ããã®ã§ãããããbindããªãã¦ããããã ãã©ãè¶ é »ç¹ã«å ¥åããã³ãã³ããªããã¼ãã¤ã³ãã«å²ãå½ã¦ãã®ãããããï¼
- ä½è : Cameron Newham,Bill Rosenblatt,æ ªå¼ä¼ç¤¾ã¯ã¤ã¼ã
- åºç社/ã¡ã¼ã«ã¼: ãªã©ã¤ãªã¼ã¸ã£ãã³
- çºå£²æ¥: 2005/10/27
- ã¡ãã£ã¢: 大åæ¬
- è³¼å ¥: 7人 ã¯ãªãã¯: 138å
- ãã®ååãå«ãããã° (47件) ãè¦ã