bashãzshã«è² ããªããããé«æ©è½åããããã®tips
ã¯ã£ããè¨ã£ã¦å æ¹äºæ¸¬ã¨è¤æ°è¡ç·¨éã¯ç¡çãã ãã©ä»£æ¿æ段ãããããã ã
ã¨ãããã¨ã§ãbashã§ã©ãã¾ã§zshã«è¿ã¥ããããã£ã¬ã³ã¸ãã¦ã¿ãã
使ç¨ç°å¢ã¯ç°å¢ã¯ubuntu8.10
以ä¸ã.bashrcã«è¿½å
if [ -f /etc/bash_completion ]; then . /etc/bash_completion fi function share_history { history -a; history -c; history -r; } PROMPT_COMMAND='share_history' shopt -u histappend export HISTTIMEFORMAT="%y/%m/%d %H:%M:%S: " export HISTSIZE=300000 function fceditor () { tt=/tmp/$$.sh; cat $1 | ( read -rd '' s; t=/tmp/$$; echo "function a(){" > $t; echo "$s" >> $t; echo -e " }\n declare -f a" >> $t; chmod +x $t; $t > /dev/null 2>&1; if [ $? = 0 ]; then a=`$t|sed '1,2d;$d;s/....//'`";"`echo "$s"|tail -1|sed 's/^.\+\(#[^#]\+\)$/\1/'`; else a="$s"; fi; rm $t; echo "$a" ) > $tt; vim $tt; sed 's/^ *//' $tt > $1; rm $tt; } export FCEDIT=fceditor
âã¯è§£èª¬
TABãã¼ã«ããã³ãã³ãè£å®
ããã©ã«ã(/etc/skel/.bashrc)ããã®ã¾ã¾ä½¿ã£ã¦ãããªãåé¡ç¡ã使ãã¦ããã¯ãã
~$ sudo apt
ãã®æ®µéã§TABãã¼ãæ¼ãã¦æ¬¡ã®ããã«ãªãã¯ã
~$ sudo apt apt-cache apt-mark apt-cdrom apt-sortpkgs apt-config aptitude apt-extracttemplates aptitude-create-state-bundle apt-ftparchive aptitude-run-state-bundle apt-get apturl apt-key ~$ sudo apt
ãªããªãã£ãå ´åã«ã¯~/.bashrcã«ä»¥ä¸ã追å
if [ -f /etc/bash_completion ]; then . /etc/bash_completion fi
å®ãããã¨èªåã¯debianããåã.bashrcã使ã£ã¦ããã®ã§ããã®è¨å®ãè¦éãã¦ãããã¾ã«ã¯/etc/skelãã®ããã¦ã¿ããã
èªåã§ã«ã¼ã«ã追å ãããæã«ã¯/etc/bash_completion ã/etc/bash_completion.d/以ä¸ãåèã«ãã
ï¼æãè¦ã¦rarã¨ãã®ãªãã·ã§ã³ã®æ¸ãæ¹ã§ãããã)
ubulog: bashの補完機能を拡張してみたã¨ãããããåèã«ãªãã
å±¥æ´æ¤ç´¢
ã¾ãããã©ã«ãã®ã¾ã¾ã§ã使ãããã ã
ããã³ããã®æ®µéã§C-r(reverse-i-search)ãæ¼ãã¦ããã°ããã
~$
ããã³ãããåºã¦ããã¨ãã«C-rãããã¨ããã³ããã(reverse-i-search)`':ã«ãªã
(reverse-i-search)`':
ãã®æ®µéã§æ¤ç´¢ãããèªå¥ãå ¥ãã¦ããã¨é次æ¤ç´¢ãã¦ããã
(reverse-i-search)`v': vi .bashrc
ããã§å±¥æ´ã®ææ°ããæ¤ç´¢ãç´ãããã¨ãã«ã¯M->ã§ããã
å±¥æ´ã«ã¿ã¤ã ã¹ã¿ã³ã追å
ãã¤æã£ãã³ãã³ãããåããã°ãªããå½¹ã«ç«ã¤ãããããªãï¼~/.bashrcã«ä»¥ä¸ã追å
export HISTTIMEFORMAT="%y/%m/%d %H:%M:%S: "
å±¥æ´ã®å®¹éãå¢ãã
ãã£ã±ãã¹ã¯ãªããã¯ãã¡ã¤ã«ã«ããã«å±¥æ´ããæ¤ç´¢ããã
export HISTSIZE=300000
ããã ãå¢ããã¦ããã¦ãã¯ã³ã©ã¤ãã¼è£½ä½æã«ã³ã¡ã³ããå
¥ãã¦ããã¨å
¨ææ¤ç´¢ã§ã³ãã³ããæ¢ããããã«ãªãã
ãããªã£ã¦ããã¨ãã¡ã¤ã«åã®åå¨æ義ãçãããã«ãªããªï¼ç¬
(reverse-i-search)`ãµã': for i in * ; do (cd "$i"; pwd ; for j in *; do echo "$j" ; zip -qr "../$j.zip" "$j" ;done);done ; #ãµããã©ã«ãæ¯ã«zip
注æããªãããããªãã®ã¯IMEã«ã¦æç¯ãæ¤ç´¢ã¯ã¼ãã¨ãã¦å
¥åã¦ãã¾ãã¨bashã®æ¹ãæ¤ç´¢ãã¹ããéãi-searchãæ¢ãã¦ãã¾ãããã®ã¨ãã¯C-cã§ããç´ãã¹ãã
ãã®è¾ºãbashãå¤è¨èªåããã¦ããªãã¨ããã
è¤æ°ã®ç«¯æ«ã§å±¥æ´ãå ±æãã
iandeth. - bashにて複数端末間でコマンド履歴(history)を共有する方法ãã
~/.bashrcã«ä»¥ä¸ã追å
function share_history { history -a history -c history -r } PROMPT_COMMAND='share_history' shopt -u histappend export HISTSIZE=300000
å±¥æ´ç·¨é
ã©ããzshã®è¤æ°è¡ç·¨éã¯ç¡çãããªã®ã§ä»£æ¿ã§ã¤ã³ãã³ãä»ãã®ç·¨éã¢ã¼ãã追å ã
bashã®å±¥æ´ãã¨ãã£ã¿ã§ç·¨éããfcã³ãã³ããæ¡å¼µããï¼âã¤ã³ãã³ãä»ã§ç·¨é)
vimã使ãå ´å
function fceditor () { tt=/tmp/$$.sh; cat $1 | ( read -rd '' s; t=/tmp/$$; echo "function a(){" > $t; echo "$s" >> $t; echo -e " }\n declare -f a" >> $t; chmod +x $t; $t > /dev/null 2>&1; if [ $? = 0 ]; then a=`$t|sed '1,2d;$d;s/....//'`";"`echo "$s"|tail -1|sed 's/^.\+\(#[^#]\+\)$/\1/'`; else a="$s"; fi; rm $t; echo "$a" ) > $tt; vim $tt; sed 's/^ *//' $tt > $1; rm $tt; } export FCEDIT=fceditor
emacsã使ãå ´å
function fceditor () { tt=/tmp/$$.sh; cat $1 | ( read -rd '' s; t=/tmp/$$; echo "function a(){" > $t; echo "$s" >> $t; echo -e " }\n declare -f a" >> $t; chmod +x $t; $t > /dev/null 2>&1; if [ $? = 0 ]; then a=`$t|sed '1,2d;$d;s/....//'`";"`echo "$s"|tail -1|sed 's/^.\+\(#[^#]\+\)$/\1/'`; else a="$s"; fi; rm $t; echo "$a" ) > $tt; emacs -nw $tt; sed 's/^ *//' $tt > $1; rm $tt; } export FCEDIT=fceditor
詳ããã¯ãbashのfcコマンドを整形後にエディタで編集する - 計算機と戯れる日々ããåç
§ã®ãã¨
ä»å¾ãããã¨ããã£ã¦ãããã¨
ããæ¹åéä¸ï¼ç¬
ã¨ã©ã¼é³ãPCMã«ãããã
æ¬ä½ããªãã®å«ãªãã ããªã
ã¡ãªã¿ã«ã¨ã©ã¼é³ï¼ã¨ãããbeepé³ï¼ãç»é¢ã®ææ»
ã«ããã®ã¯ä»¥ä¸ã§ããã
echo set bell-style visible >> .inputrc
å æ¹äºæ¸¬ï¼ã¤ã³ã¯ãªã¡ã³ã¿ã«ãªè£å®ï¼
ç¡çãªæ°ããããããã ãã§ãzshã®ä¾¡å¤ããããã ããªâ¦
zshã®ä»¥ä¸ã®æ©è½
autoload predict-on predict-on
è¤æ°è¡ç·¨é
zshã§ã¯è¤æ°è¡ã§å
¥åãããã³ãã³ãã¯è¤æ°è¡ã®ã¾ã¾è¡¨ç¤ºãããããããzshã§ã¯ã表示ãããè¤æ°è¡ã®ã³ãã³ããã¨ãã£ã¿ã§ã使ãããã«ç·¨éã§ãã¦ãã¾ãã
ããããbashã§ã¯1è¡ã³ãã³ãã«å¤æããããã®ã表示ãããã
zshã£ã¦Enterã®æå³ãå¾®å¦ãªãã ãªãæåã®å ¥åã¯ãããã©äºåç®ã®ç·¨éã§EnterãC-oã§è¡ã®æ¿å ¥ãã§ããªããï¼C-kC-yC-yC-kã§ã§ããï¼