×ðÁú¿­Ê±¹ÙÍøµÇ¼

Linux ³¬µÈƯÁÁµÄ Shell

ÏÈÀ´Ò»ÕÅÃÀͼ

1 zsh ÏÈÈÝ

1.1 Linux shell

Linux/Unix ÌṩÁËÐí¶àÖÖ Shell£¬ÎªÃ«ÒªÕâô¶à Shell£¿

Æñ·ÇÓÃÀ´³´×ųÔô£¿ÄÇÎÒÎÊÄ㣬ÄãͬÀàÐ͵ÄÒ·þÔõôÓÐÄÇô¶à¼þ£¿»¨É«£¬Öʵػ¹·×ÆçÑù¡£Ð´³ÌÐò±ÈÂòÒ·þÖØ´ó¶àÁË£¬²¢ÇÒ³ÌÐòÔ±ÍùÍùÈÏÕæ°ÑÖØ´óµÄÊÂÇé¸ã¼òÆÓ£¬¼òÆÓµÄÊÂÇé¸ãÖØ´ó¡£Å£³ÌÐòÔ±¿´µ½²»Ë¬µÄ Shell£¬¾Í»á×Ô¼ºÖØÐÂдһÌ×£¬Öð²½ÐγÉÁËһЩ±ê×¼£¬³£ÓÃµÄ Shell ÓÐÕâô¼¸ÖÖ£¬sh¡¢bash¡¢csh µÈ£¬ÏëÖªµÀÄãµÄϵͳÓм¸ÖÖ shell£¬¿ÉÒÔͨ¹ýÒÔÏÂÏÂÁîÉó²é£º

cat /etc/shells

µÇ¼ºó¸´ÖÆ

ÏÔʾÈçÏ£º

1.2 zsh ¼ò½é

Zsh ÊÇÒ»¸ö Linux ÏÂÇ¿Ê¢µÄ shell, ÓÉÓÚ´ó´ó¶¼ Linux ²úÆ·×°Öã¬ÒÔ¼°Ä¬ÈÏʹÓÃbash shell, ¿ÉÊÇË¿¾ø²»Ó°Ï켫¿ÍÃÇ¶Ô zsh µÄÈÈÖÔ, ÏÕЩÿһ¿î Linux ²úÆ·¶¼°üÀ¨ÓÐ zsh£¬Í¨³£¿ÉÒÔÓà apt-get¡¢urpmi »ò yum µÈ°ü¹ÜÀíÆ÷¾ÙÐÐ×°ÖÃ

Zsh ¾ßÓÐÒÔÏÂÖ÷Òª¹¦Ð§

¿ªÏä¼´Óᢿɱà³ÌµÄÏÂÁîÐв¹È«¹¦Ð§¿ÉÒÔ×ÊÖúÓû§ÊäÈëÖݪֲÎÊýÒÔ¼°Ñ¡Ïî

ÔÚÓû§Æô¶¯µÄËùÓÐ shell ÖÐ ¹²ÏíÏÂÁîÀúÊ·

ͨ¹ýÀ©Õ¹µÄÎļþͨÅä·û£¬¿ÉÒÔµ¹ÔËÓÃÍâÊÖÏÂÁîµÖ´ï find ÏÂÁîÒ»Ñùƽ³£Õö¿ªÎļþÃû

ˢеıäÁ¿ÓëÊý×é´¦Àí

ÔÚ»º³åÇøÖб༭¶àÐÐÏÂÁî

¶àÖÖ¼æÈÝģʽ£¬ÀýÈçʹÓà / bin/sh ÔËÐÐʱ¿ÉÒÔαװ³É Bourne shell

¿ÉÒÔ¶¨ÖÆ·ºÆðÐÎʽµÄÌáÐÑ·û£»°üÀ¨ÔÚÆÁÄ»ÓÒ¶ËÏÔʾÐÅÏ¢£¬²¢ÔÚ¼üÈ볤ÊÙÁîʱ×Ô¶¯Òþ²Ø

¿É¼ÓÔصÄÄ£¿é£¬ÌṩÆäËûÖÖÖÖÖ§³Ö£ºÍêÕûµÄ TCP Óë Unix ÓòÌ×½Ó×Ö¿ØÖÆ£¬FTP ¿Í»§¶ËÓëÀ©³ä¹ýµÄÊýѧº¯Êý

ÍêÈ«¿É¶¨ÖÆ»¯

1.3 zsh Óë oh-my-zsh ×îÖÕÉèÖÃ

֮ǰÊÇÓÉÓÚ¿´µ½ÕâƪÎÄÕ£º×îÖÕ Shell¡ª¡ªZsh ²ÅÑ¡ÔñʹÓà zsh£¬±»ËüµÄ×Ô¶¯Íê³É¡¢²¹È«¹¦Ð§ÎüÒýÁË¡£¹ÙÍø£ºwww.zsh.org

Ñ¡Ôñ oh-my-zsh, oh-my-zsh ÊÇ»ùÓÚ zsh µÄ¹¦Ð§×öÁËÒ»¸öÀ©Õ¹£¬Àû±ãµÄ²å¼þÖÎÀí¡¢Ö÷Ìâ×Ô½ç˵£¬ÒÔ¼°Æ¯ÁÁµÄ×Ô¶¯ÍêЧ¹û¹û¡£

ÔÚ Github ÉÏÕÒ¹ØÓÚ zsh µÄÏîĿʱ·¢Ã÷µÄ£¬ÊÔÓÃÁËÒ»ÏÂÒÔΪºÜÀû±ã£¬²»±ØÏñÉÏÃæÎÄÕÂÄÚÀïÌáµ½µÄÄÇôÖØ´ó£¬ÉèÖÃһЩ²å¼þµÄÃû³Æ¼´¿ÉʹÓÃÏìÓ¦µÄ¹¦Ð§¡£

Å£±Æ°¡£¡½Ó˽»î±Ø±¸µÄ N ¸ö¿ªÔ´ÏîÄ¿£¡¸ÏæÕä²Ø

µÇ¼ºó¸´ÖÆ

¹ÙÍø£ºhttps://github.com/robbyrussell/oh-my-zsh

2 ×°ÖÃ zsh

2.1 ×°ÖÃ zsh

¹ØÓÚÒ»Ñùƽ³£µÄ Ubuntu ϵͳ£¬ÉèÖúÃ׼ȷµÄÔ´Ö®ºó£¬¾ÍÄÜÖ±½Ó¼üÈëÒÔÏÂÏÂÁî×°Öãº

sudo apt-get install zsh

µÇ¼ºó¸´ÖÆ

2.2 ÉèÖÃ zsh

zsh µÄÉèÖÃÊÇÒ»ÃÅ´óѧÎÊ£¬ÕâÀﲻ׸Êö£¬Ö±½Ó¸ø³öÒ»¸öÉèÖÃÎļþ£¬¸÷ÈË¿ÉÒÔÏÂÔغó·ÅÈë zsh ÉèÖÃÎĵµÖ±½ÓʹÓᣣ¨ÎÒµÄÒ»¸ö·¨¹úÅóÙ­ÊÖÅäµÄ£¬Ï൱ËæÊÖ£©

°Ñ. zshrc ¿½±´µ½ÏìÓ¦Óû§µÄ home Ŀ¼¼´¿É(Ò²¿ÉÒÔ°ÑÄãµÄ bash µÄÉèÖÃÎļþ (~/.bash_prorile »òÕß~/.profile µÈ) ¸ø¿½±´µ½ zsh µÄÉèÖÃÎļþ~/.zshrc ÀÓÉÓÚ zsh ¼æÈÝ bash)

2.3 È¡´ú bash£¬ÉèΪĬÈÏ shell

sudo usermod -s /bin/zsh username

µÇ¼ºó¸´ÖÆ

»òÕß

chsh -s /bin/zsh

µÇ¼ºó¸´ÖÆ

chsh -s `which zsh`

µÇ¼ºó¸´ÖÆ

ÈôÊÇÒªÇл»»ØÈ¥ bash£º

chsh -s /bin/bash

µÇ¼ºó¸´ÖÆ

ËäÈ»Äã×Åʵ²»¿ÏÒâ°Ñ zsh µ±³ÉĬÈ쵀 shell, ¶øÓÖÏëʹÓÃËü, ÄÇôÄã¿ÉÒÔÿ´Î½øÈëÊǶ¼Ê¹ÓÃzsh½øÈë, ¶øÊäÈëexitÍ˳ö

2.4 ×°ÖÃ oh-my-zsh

Ö±½ÓÓà zsh »áºÜµ°ÌÛ£¬ÓÉÓÚ zsh ¹¦Ð§ºÜÇ¿Ê¢¿ÉÊÇÌ«ÖØ´ó£¬ÒÔÊÇÐèÒª oh-my-zsh À´½«Ëü¼òÆÓ»¯¡£ÁíÍ⣬ËÑË÷ÃñÖÚºÅLinux¾Í¸ÃÕâÑùѧºǫ́»Ø¸´¡°Linux¡±£¬»ñÈ¡Ò»·Ý¾ªÏ²Àñ°ü¡£

Ö±½ÓÓà git ´Ó github ÉÏÃæÏÂÔØ°ü

git clone git://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh

µÇ¼ºó¸´ÖÆ

±¸·ÝÒÑÓÐµÄ zshrc, Ìæ»» zshrc

cp ~/.zshrc ~/.zshrc.origcp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc

µÇ¼ºó¸´ÖÆ

Ö±½ÓʹÓþ籾װÖÃ

cd oh-my-zsh/tools./install.sh

µÇ¼ºó¸´ÖÆ

Äã¿ÉÒÔÖ±½ÓÖ±½ÓʹÓÃÈçÏÂÏÂÁî×°ÖÃ

curl

sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

µÇ¼ºó¸´ÖÆ

wget

sh -c "$(wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"

µÇ¼ºó¸´ÖÆ

ÆäʵÖʾÍÊÇÏÂÔز¢Ö´ÐÐÁË github É쵀 install.sh ¾ç±¾, ¸Ã¾ç±¾Î»ÓÚoh-my-zsh/tools/install.sh

ÉèÖÃÖ÷Ìâ

oh-my-zsh ¼¯³ÉÁË´ó×ÚµÄÖ÷Ìâ, λÓÚ oh-my-zsh/theme

ÉèÖÃÖ÷Ìâ, ¿ÉÒÔͨ¹ýÐÞ¸Ä~/.zshrcÖеÄÇéÐαäÁ¿ZSH_THEMEÀ´Íê³É

ZSH_THEME="agnoster" # (this is one of the fancy ones)

µÇ¼ºó¸´ÖÆ

ÈôÊÇÄãÒÔΪÖ÷ÌâÌ«¶àÄã¿ÉÒÔÑ¡ÔñʹÓÃËæ»úģʽ, ÀíÓÉϵͳËæ»úÑ¡Ôñ

ZSH_THEME="random" # (...please let it be pie... please be some pie..)

µÇ¼ºó¸´ÖÆ

ÏêϸµÄÖ÷ÌâÐÅÏ¢, ¿ÉÒ԰ݼû zsh Ö÷ÌâÏÈÈÝ

ÉèÖòå¼þ

Ð޸ġ«/.zshrcÖÐplugins

plugins=(git bundler osx rake ruby)

µÇ¼ºó¸´ÖÆ

ÏêϸµÄ²å¼þÐÅÏ¢, ¿ÉÒ԰ݼû zsh ²å¼þ Plugins ÏÈÈÝ

¸üРoh-my-zsh

ĬÈÏÇéÐÎÏÂ, Äú½«±»ÌáÐѼì²éÿ¼¸ÖܵÄÉý¼¶. ÈôÊÇÄãÏëÎÒ ZSH ×Ô¶¯Éý¼¶×Ô¼ºÃ»ÓÐÌáÐÑÄã, ÐÞ¸Ä `~/.zshrc¡£ÁíÍ⣬ËÑË÷ÃñÖںŶ¥¼¶Ëã·¨ºǫ́»Ø¸´¡°Ëã·¨¡±£¬»ñÈ¡Ò»·Ý¾ªÏ²Àñ°ü¡£

disable_update_prompt = true

µÇ¼ºó¸´ÖÆ

½ûÓÃ×Ô¶¯Éý¼¶, ÐÞ¸Ä~/.zshrc

disable_auto_update = true

µÇ¼ºó¸´ÖÆ

ËäÈ»ÄãÒ²¿ÉÒÔÑ¡ÔñÊÖ¶¯¸üÐÂ

ÈôÊÇÄãÏëÔÚÈκÎʱ¼äµãÉý¼¶£¨Ò²ÐíÓÐÈ˸ոÕÐû²¼ÁËÒ»¸öеIJå¼þ£¬Äã²»ÏëÆÚ´ýÒ»¸öÐÇÆÚ£¿) ÄãÖ»ÐèÒªÔËÐУº

upgrade_oh_my_zsh

µÇ¼ºó¸´ÖÆ

жÔØ oh-my-zsh

ÈôÊÇÄãÏëжÔØoh-my-zsh, Ö»ÐèÒªÖ´ÐÐuninstall_oh_my_zsh zsh£¬ ´ÓÏÂÁîÐÐÔËÐÐ. Õ⽫ɾ³ý×Ô¼ººÍ»Ö¸´ÄãÒÔÇ°µÄ bash »òÕß zsh ÉèÖÃ.

ÒÔÉϾÍÊÇLinux ³¬µÈƯÁÁµÄ ShellµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí£¬°æȨÕùÒéÓë±¾Õ¾Î޹أ¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í×ðÁú¿­Ê±¹ÙÍøµÇ¼ÂËÓÍ»úÍø¹Ù·½Ì¬¶È£¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ£¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢£¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢£¬ÇëÄúÁ¬Ã¦ÁªÏµ×ðÁú¿­Ê±¹ÙÍøµÇ¼ʵʱÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ×ðÁú¿­Ê±¹ÙÍøµÇ¼

18523999891

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎ壬9:30-18:30£¬½ÚãåÈÕÐÝÏ¢

QR code
ÍøÕ¾µØͼ