¹è½¬(Bash) ÇÁ·ÒÇÁÆ® HOWTO <author>Giles Orr, <htmlurl url="mailto:giles@interlog.com" name="giles@interlog.com"> <date>v0.55, 1 December 1998 <trans>¿Å±äÀÌ: ±è Èï¼ö, <htmlurl url="mailto:hskim@supy.kaist.ac.kr" name="hskim@supy.kaist.ac.kr"> <tdate>¿Å±ä ³¯:1998³â 12¿ù 24ÀÏ <abstract> Å͹̳ΰú XÅÒ ÇÁ·ÒÇÁÆ®µéÀ» ¾î¶»°Ô »ý¼ºÇÏ°í ´Ù·ê °ÍÀΰ¡¿¡ ´ëÇÏ¿© ³íÀÇÇϸç, ¶ÇÇÑ »ç¿ëÀÚ¸í, ÇöÀç ÀÛ¾÷ µð·ºÅ丮, ½Ã°£ µîÀ» ³ªÅ¸³»±â À§ÇÑ Ç¥ÁØÀûÀÎ escape sequence µéÀ» º´ÇÕÇÏ´Â ¹æ¹ýµµ Æ÷ÇÔÇÕ´Ï´Ù. XÅÒ Á¦¸ñ Ç¥½ÃÁÙ(title bar)À» º¯°æÇÏ´Â ¹æ¹ý, ÇÁ·ÒÇÁÆ®¿¡ Á¤º¸¸¦ Á¦°øÇϱâ À§ÇÑ ¿ÜºÎ ÇÔ¼öµéÀÇ »ç¿ë ¹æ¹ý, ANSI »ö(color)À» ¾î¶»°Ô »ç¿ëÇÒ °ÍÀΰ¡¿¡ ´ëÇÏ¿© ´õ ¸¹Àº Á¦¾È µéÀÌ Á¦½ÃµË´Ï´Ù. </abstract> <sect>³»¿ë ¼Ò°³ <sect1>¿ä±¸ »çÇ× <p> ¿ì¼±, ¹è½¬°¡ ÇÊ¿äÇÒ °ÍÀÔ´Ï´Ù. ´ëºÎºÐÀÇ ¸®´ª½º ¹èÆ÷º»¿¡¼­ µðÆúÆ® ¹öÀüÀº 1.14.7 À̸ç(98³â 11¿ù, ÀÌ ±ÛÀÌ ¾º¾î Áú ¶§), ÀÌ ¹öÀüÀº Àß ¾Ë·ÁÁ® ÀÖÀ¸¸ç ¶ÇÇÑ ½Å·ÚÇÒ ¸¸ÇÑ ½©ÀÔ´Ï´Ù. ¹è½¬´Â ÇöÀç·Î ¹öÀü 2.0+ ±îÁö ¾²ÀÌ°í ÀÖÀ¾´Ï´Ù:Àú´Â ¾ó¸¶ Àü ºÎÅÍ ¹è½¬2.0À» »ç¿ëÇØ ¿À°í ÀÖÀ¾´Ï´Ù¸¸, ¿©±â¿¡¼­ Á¦½ÃµÇ´Â ´ëºÎºÐÀÇ ¸í·É¾îµéÀº ¹öÀü 1.14.7 ÀÌÇÏ¿¡¼­µµ ÀÛµ¿ÇÒ °ÍÀÔ´Ï´Ù. ¸¸¾à ¹®Á¦¸¦ ÀνÄÇÏ°Ô µÇ¸é, ±×°Í¿¡ ´ëÇؼ­ ¾ð±ÞÇϵµ·Ï ÇÏ°ÚÀ¾´Ï´Ù. ÇÁ·ÒÇÁÆ®¿¡¼­ 'echo $BASH_VERSION' À̶ó°í Ä¡¸é ¹è½¬ ¹öÀüÀ» È®ÀÎÇÒ ¼ö ÀÖÀ¾´Ï´Ù. Á¦ ±â°èÀÇ °æ¿ì, '2.02.1(1)-release'¶ó°í ¹ÝÀÀÇÕ´Ï´Ù. </p> <p> ½© ÇÁ·Î±×·¥ °æÇèÀÌ ÀÖÀ¸¸é ÁÁÀ¸³ª, ²À ÇÊ¿äÇÑ °ÍÀº ¾Æ´Õ´Ï´Ù: ´õ ¸¹ÀÌ ¾Ë¸é, ´õ º¹ÀâÇÑ ÇÁ·ÒÇÁÆ®µéÀ» »ý¼ºÇÒ ¼ö ÀÖÀ» °ÍÀÔ´Ï´Ù. ½© ÇÁ·Î±×·¥À̳ª À¯´Ð½º µµ±¸µé¿¡ ´ëÇÑ ±âÃÊÀûÀÎ Áö½ÄÀº °¡Áö°í ÀÖ´Ù°í °¡Á¤ÇÕ´Ï´Ù. ±×·¯³ª, Á¦ ÀÚ½ÅÀÇ ½© ÇÁ·Î±×·¥ ±â¼úÀÌ ÇÑ°è°¡ ÀÖÀ¸¹Ç·Î, °íµµÀÇ ½© ÇÁ·Î±×·¡¸Ó¿¡°Ô´Â ÇÊ¿ä¾ø¾î º¸ÀÏ ¼öµµ ÀÖ´Â ¿¹Á¦³ª ¼³¸íµéÀ» ¸¹ÀÌ ÇÏ°Ô µÉ °ÍÀÔ´Ï´Ù. </p> <sect1>Á¦¾È »çÇ×À̳ª ºñÆò º¸³»±â <p> ÀÌ °­ÀÇ´Â Àú¿¡°Ô´Â ¹è¿ì´Â °æÇèÀÔ´Ï´Ù. ¾î¶»°Ô Çϸé Àç¹ÌÀÖ°í À¯¿ëÇÑ ÇÁ·ÒÇÁÆ®¸¦ ¸¸µé ¼ö ÀÖ´ÂÁö ¸¹ÀÌ ¾Ë°Ô µÇ¾úÁö¸¸, ÀÌ ¹®¼­ÀÇ ³»¿ëÀ» ¼öÁ¤ÇÏ°í Çâ»ó ½ÃÅ°´Â µ¥´Â ¿©·¯ºÐµéÀÇ Âü¿©°¡ ÇÊ¿äÇÕ´Ï´Ù. ÀÌ ¹®¼­ÀÇ °¡Àå ÃÖ±ÙÀÇ ¹öÀüÀº <url url="http://www.interlog.com/~giles/bashprompt.html"> ¿¡¼­ ÀÌ¿ëÇÒ ¼ö ÀÖÀ¾´Ï´Ù. ÀÌ È¨ ÆäÀÌÁö¸¦ È®ÀÎÇϽðí, ÀÚÀ¯·Ó°Ô <htmlurl url="mailto:giles@interlog.com" name="giles@interlog.com"> ÀÇ ÁÖ¼Ò·Î e-mail À» ÁÖµµ·Ï ÇϽʽÿÀ. <sect1> ĪÂùÀÇ ±Û <p> ÀÌ ¹®¼­¸¦ ¸¸µå´Âµ¥´Â, <url url="http://bash.current.nu/">ÀÇ ¹è½¬ÇÁ·ÒÇÁÆ® ÇÁ·ÎÁ§Æ®ÀÇ ÀÛ¾÷ À¸·Î ºÎÅÍ ¸¹Àº °ÍÀ» Â÷¿ëÇÏ¿´À¾´Ï´Ù. »ç¿ëµÈ ´Ù¸¥ ÃâóµéÀº ¾Æ·¡¿Í °°À¾´Ï´Ù. Eric ListerÀÇ 'the xterm Title mini-HOWTO' <url url="http://sunsite.unc.edu/LDP/HOWTO/mini/Xterm-Title.html">, KeeblerÀÇ 'Ansi Prompts' <url url="http://www.ncal.verio.com/~keebler/ansi.html">, Stephen WebbÀÇ 'How to make a Bash Prompt Theme' <url url="http://bash.current.nu/bash/HOWTO.html">, StumpyÀÇ 'X ANSI Fonts' <url url="http://home.earthlink.net/~us5zahns/enl/ansifont.html">. ¶ÇÇÑ, À¯´Ð½º¿¡ ´ëÇÑ Áö½Ä¿¡¼­´Â Àú¸¦ ÃÊ¿ùÇÏ´Â Dan, Georgia College & State University¿¡¼­ ³ªÀÇ µ¿·á ¿¬±¸ÀÚ, °úÀÇ ¸î ¹øÀÇ Åä·Ð°ú e-mail¿¡¼­ ¸·´ëÇÑ µµ¿òÀ» ¹Þ¾ÒÀ¾´Ï´Ù. ±×´Â ¸î ¹øÀÇ ¾ÆÁÖ ¿ì¼öÇÑ Á¦¾È°ú ¾ÆÀ̵ð¾î¸¦ Á¦½ÃÇßÀ¸¸ç, °á°ú·Î ¸î ¸îÀÇ Àç¹ÌÀÖ´Â ÇÁ·ÒÇÁÆ®¸¦ ¸¸µé°Ô µÇ¾úÀ¾´Ï´Ù. ÇÁ·ÒÇÁÆ®µéÀ» ÇÁ·Î±×·¥Çϴµ¥ À¯¿ëÇÏ°Ô »ç¿ëµÈ ¼¼±ÇÀÇ Ã¥ÀÌ ÀÖÀ¾´Ï´Ù. Jessica Heckman PerryÀÇ 'Linux in a Nutshell'(O'Reilly, 1997), Cameron Newham °ú Bill RosenblattÀÇ 'Learning the Bash Shell'(O'Reilly, 2nd. ed., 1998), Lowell Jay ArthurÀÇ 'Unix Shell Programming' (Wiley, 1986. ÀÌ Ã¥Àº ù ÆÇÀÌ°í, ³×¹ø° ÆÇÀÌ 1997³âµµ¿¡ ÃâÆǵǾúÀ¾´Ï´Ù.). </sect> <sect> ¹è½¬¿Í ¹è½¬ ÇÁ·ÒÇÁÆ® <p> <sect1> ¹è½¬¶õ ¹«¾ùÀΰ¡ <p> Bourne Shell·Î ºÎÅÍ Àü½ÂµÈ, ¹è½¬´Â GNU ÇÁ·ÎÁ§Æ®ÀÎ "Bourne Again SHell"À̸ç, ´ëºÎºÐÀÇ ¸®´ª½º ±â°è¿¡¼­ÀÇ Ç¥ÁØÀûÀÎ ¸í·É¾î ¶óÀÎ ÀÎÅÍÆäÀ̽ºÀÔ´Ï´Ù. ÀÌ°ÍÀº »óÈ£¿¬°á¼º¿¡¼­, ±×¸®°í ¸í·É¾î ¶óÀÎ ÆíÁý, ¿Ï·á, Àç½ÇÇàÀ» Áö¿øÇϴµ¥ Ź¿ùÇÕ´Ï´Ù. ¹è½¬´Â ¶ÇÇÑ, Çü¼º°¡´É ÇÁ·ÒÇÁÆ®¸¦ Áö¿øÇÕ´Ï´Ù-¸¹Àº »ç¶÷µéÀÌ ÀÌÁ¡À» ÀνÄÇÏ°í´Â ÀÖÁö¸¸ ¾ÆÁÖ ¸¹Àº °ÍÀÌ °¡´ÉÇÏ´Ù´Â »ç½ÇÀ» ¸ð¸£°í ÀÖÀ¾´Ï´Ù. <sect1> ¹è½¬¸¦ Àâ¾Æ ºñƲ¾î¼­ ¹«¾ùÀ» ÇÏ°Ô ÇÒ °ÍÀΰ¡ <p> ´ëºÎºÐÀÇ ¸®´ª½º ½Ã½ºÅÛÀº ´Ü»ö(ÀϹÝÀûÀ¸·Î ȸ»ö)ÀÇ µðÆúÆ® ÇÁ·ÒÇÁÆ®¸¦ °¡Áö°í ÀÖ¾î, »ç¿ëÀÚ ¸í, ÀÛ¾÷ÇÏ°íÀÖ´Â ±â°èÀÇ À̸§, ±×¸®°í ÇöÀçÀÇ ÀÛ¾÷ µð·¢Å丮µîÀ» Ç¥½ÃÇÕ´Ï´Ù. ÀÌ°ÍÀÌ À¯¿ëÇÑ Á¤º¸ÀÇ ÀüºÎÀÌÁö¸¸, ÇÁ·ÒÇÁÆ®·Î ÈξÀ ¸¹Àº °ÍÀ» ÇÒ ¼ö ÀÖÀ¾´Ï´Ù: ¸ðµç Á¾·ùÀÇ Á¤º¸(tty¹øÈ£, ½Ã°£, ³¯Â¥, ºÎÇÏ, »ç¿ëÀÚÀÇ ¼ö, °É¸° ½Ã°£...)¸¦ Ç¥½Ã ÇÒ ¼ö ÀÖÀ¸¸ç, ÇÁ·ÒÇÁÆ®´Â ANSI »öÀ» »ç¿ëÇÒ ¼ö À־ Àç¹ÌÀÖ°Ô º¸À̰ųª, ¾î¶² Á¤º¸ ´Â µ¸º¸ÀÌ°Ô ÇÒ ¼ö ÀÖÀ¾´Ï´Ù. ¶ÇÇÑ XÅÒÀÇ Á¦¸ñ Ç¥½ÃÁÙÀ» Á¶Á¤ÇÒ ¼ö À־ À̵é Á¤º¸ Áß ¸î °³¸¦ ¹Ý¿µÇÒ ¼ö ÀÖµµ·Ï ÇÕ´Ï´Ù. <sect1> °í¹ÎÀº ±×¸¸ÇϽÿÀ <p> ½Ã½ºÅÛ Á¤º¸ÀÇ ÀÚÃ븦 À¯ÁöÇÏ´Â °ÍÀº Á¾Á¾ À¯¿ëÇÑ °æ¿ì°¡ ¸¹À¾´Ï´Ù. ¸î¸îÀÇ »ç¶÷µé ¿¡°Ô È£¼Ò·Â ÀÖ°Ô º¸ÀÌ´Â, Á¦°¡ ¾Æ´Â ¾ÆÀ̵ð¾î Áß Çϳª´Â, °¢°¢ÀÇ ¼­·Î ´Ù¸¥ ±â°è ¸¶´Ù ´Ù¸¥ »ö±òÀÇ ÇÁ·ÒÇÁÆ®¸¦ À¯ÁöÇϵµ·Ï ÇÒ ¼ö ÀÖ´Ù´Â °Í ÀÔ´Ï´Ù. ¸¸¾à ¸î °³ÀÇ ´Ù¸¥ ±â°è¿¡¼­ XÅÒµéÀ» ¿­°í Àִٰųª, ¶Ç´Â ÀÛ¾÷ ÁßÀÎ ±â°è°¡ ¾î´À ±â°èÀÎÁö Àؾî¹ö·Á¼­ ¾û¶×ÇÑ ÆÄÀϵéÀ» Áö¿ö ¹ö¸®´Â °æÇâÀÌ ÀÖ´Ù¸é, ÀÌ ¹æ¹ýÀº ÇöÀç ÀÛ¾÷ ÁßÀÎ ±â°è¸¦ »ó±â ½ÃÅ°´Âµ¥ À־ ¸Å¿ì Çö¸íÇÑ ¹æ¹ýÀ̶ó´Â °ÍÀ» ¾Ë°Ô µÉ °ÍÀÔ´Ï´Ù. <sect1> ù¹ø° <p> ÇÁ·ÒÇÁÆ®ÀÇ »ý±è»õ´Â PS1 ½© º¯¼ö·Î Á¦¾îÇÕ´Ï´Ù. ¸í·ÉÀÇ °è¼ÓÀº PS2 ½© º¯¼ö¿¡ ÀÇÇØ ÁöÁ¤µÇ´Âµ¥, ÀÌ°ÍÀº ¿©±â¼­ ³íÀǵǴ ¹Ù¿Í ²À °°Àº ¹æ¹ýÀ¸·Î ¼öÁ¤ÇÒ ¼ö ÀÖÀ¾´Ï´Ù- -PS2¸¦ Á¶Á¤ÇÏ´Â °ÍÀº Á¤È®ÇÏ°Ô ¶È°°Àº ¹æ¹ýÀ̶ó¼­, ±×·¸°Ô Èï¹Ì·ÓÁö ¾ÊÀ¸¹Ç·Î PS1 ½© º¯¼ö¸¦ ´ëºÎºÐ ¼öÁ¤ÇÒ °ÍÀÔ´Ï´Ù(ÀÏ¹Ý »ç¿ëÀÚµéÀº º»ÀûÀÌ ¾ø´Â PS3, PS4 ½© º¯¼öµµ ÀÖÀ¾´Ï´Ù-À̰͵éÀÇ »ç¿ë¿¡ Èï¹Ì°¡ ÀÖÀ¸½Å ºÐµéÀº ¹è½¬ ¸Þ´º¾ó ÆäÀÌÁö¸¦ Âü°í Çϼ¼¿ä). ÇÁ·ÒÇÁÆ®¸¦ ´Ù¸£°Ô º¸À̵µ·Ï Çϱâ À§Çؼ­, PS1 ½© º¯¼ö¸¦ ¹Ù²Ù¸é µË´Ï´Ù. ½ÇÇèÀûÀ¸·Î, ÇöÀçÀÇ ÇÁ·ÒÇÁÆ®¿¡¼­ Á÷Á¢ PS1 º¯¼ö¸¦ ÀÔ·ÂÇؼ­ ´çÀå ±× °á°ú¸¦ º¸½Ç ¼ö ÀÖÀ¾´Ï´Ù.(ÀÌ°ÍÀº ÇöÀçÀÇ ½ê¼Ç¿¡¼­¸¸ È¿·ÂÀÌ ÀÖ°í ·Î±× ¾Æ¿ôÇÏ°Ô µÇ¸é »ç¶óÁö°Ô µË´Ï´Ù). ¹Ù²ï ÇÁ·ÒÇÁÆ®¸¦ ¿µ±¸ÀûÀ¸·Î À¯ÁöÇÒ·Á°í ÇÑ´Ù¸é, '~/.bashrc' ÆÄÀÏÀ» ¼öÁ¤ ÇÏ¿©, ±×°÷¿¡ PS1ÀÇ »õ·Î¿î Á¤ÀǸ¦ ÷°¡Çϵµ·Ï ÇϽʽÿÀ. ¸¸¾à ·çÆ®ÀÇ ±ÇÇÑÀ» °®°í °è½Ã´Ù¸é '/etc/profile'À̶ó´Â ÆÄÀÏÀ» ã¾Æ "PS1=" ¶óÀÎÀ» ¼öÁ¤ÇÒ ¼ö ÀÖÀ¾´Ï´Ù. ¸î¸îÀÇ ¹èÆ÷º»(Àû¾îµµ RedHat 5.1)¿¡¼­´Â '/etc/bashrc'ÆÄÀÏÀÌ PS1, PS2 ½© º¯¼ö¸¦ ¹«È¿È­ ½ÃŲ´Ù´Â Á¡À» ÁÖÀÇ ÇϽʽÿÀ. ½ÃÀÛÇϱâ Àü¿¡, PS1 º¯¼ö´Â ´Ù¸¥ ȯ°æ º¯¼öµé°ú ¸¶Âù°¡Áö·Î ȯ°æº¯¼ö ±â¾ï Àå¼Ò¿¡ ÀúÀåµÇ¾î ÀÖ´Ù´Â °ÍÀ» ¸í½ÉÇØ¾ß ÇÕ´Ï´Ù. ¸í·É¾î ¶óÀο¡¼­ PS1À» ¼öÁ¤ÇϰԵǸé, ´çÀå ÇÁ·ÒÇÁÆ®°¡ ¹Ù²î°Ô µË´Ï´Ù. ¾î¶°ÇÑ º¯°æÀ» °¡Çϱâ Àü¿¡, ¶Ç´Ù¸¥ ȯ°æº¯¼ö¿¡ ÇöÀçÀÇ ÇÁ·ÒÇÁÆ®¸¦ ÀúÀåÇÒ ¼ö ÀÖÀ¾´Ï´Ù. <verb> [giles@nikola giles]$ SAVE=$PS1 [giles@nikola giles]$ </verb> °¡Àå °£´ÜÇÑ ÇÁ·ÒÇÁÆ®´Â ´ÙÀ½°ú °°ÀÌ, ÇϳªÀÇ ¹®ÀÚ·Î µÉ °ÍÀÌÁÒ. <verb> [giles@nikola giles]$ PS1=$ $ ls bin mail $ </verb> ¸í·É¾î ¶óÀο¡¼­ ÀÔ·ÂÇÔÀ¸·Î½á, ±âº»ÀûÀÎ ÇÁ·ÒÇÁÆ®¿¡ ´ëÇÑ ½ÇÇèÀÇ ÃÖ»óÀÇ ¹æ¹ýÀ» ¼³¸íÇÕ´Ï´Ù. »ç¿ëÀÚ°¡ ÀÔ·ÂÇÑ ¹®ÀåÀº ÇÁ·ÒÇÁÆ®ÀÇ ¹Ù·Î µÚ¿¡ ³ªÅ¸³­´Ù´Â Á¡À» ÁÖ¸ñ ÇϽʽÿÀ: Àú´Â ¾Æ·¡¿Í °°ÀÌ »ç¿ëÇϱ⸦ ´õ ÁÁ¾Æ ÇÕ´Ï´Ù. <verb> $PS1="$ " $ ls bin mail $ </verb> ÀÌ°ÍÀº ÇÁ·ÒÇÁÆ® µÚ¿¡ °ø¹éÀ» µÎ¾î¼­, ´õ Àб⠽±µµ·Ï ÇÕ´Ï´Ù. ¿ø·¡ÀÇ ÇÁ·ÒÇÁÆ®·Î º¹±ÍÇϱâ À§Çؼ­´Â, ´ÜÁö ÀúÀåÇÏ¿´´ø º¯¼ö¸¦ ºÎ¸£±â¸¸ ÇÏ¸é µË´Ï´Ù. <verb> $ PS1=$SAVE [giles@nikola giles]$ </verb> <sect1> ¹è½¬ À̽ºÄÉÀÙ ½ÃÄö½º(escape sequence) <p> ¹è½¬ ½©¿¡¼­´Â ÇÁ·ÒÇÁÆ®¿¡ »ðÀÔÇϱâ À§Çؼ­ ¸¹Àº À̽ºÄÉÀÙ ½ÃÄö½º°¡ Á¦°øµË´Ï´Ù. ¹è½¬2.02 ¸Þ´º¾ó ÆäÀÌÁö·Î ºÎÅÍ: »óÈ£ÀûÀ¸·Î ½ÇÇàÇÒ ¶§, ¹è½¬´Â ¸í·ÉÀ» ¹Þ¾ÆµéÀÏ Áغñ°¡ µÇ¸é ±âº» ÇÁ·ÒÇÁÆ® PS1À» Ç¥½ÃÇÏ°í, ¸í·É¾î¸¦ ¿Ï¼ºÇϱâ À§ÇØ ´õ ¸¹Àº ÀÔ·ÂÀÌ ¿ä±¸µÉ ¶§´Â µÎ¹ø° ÇÁ·ÒÇÁÆ®ÀÎ PS2¸¦ ³ªÅ¸³À´Ï´Ù. ¹è½¬¿¡¼­´Â À̵é ÇÁ·ÒÇÁÆ® º¯¼öµéÀÌ backslash(\)¿Í ÇϳªÀÇ ¹®ÀÚ·Î Á¶ÇÕµÈ Æ¯¼ö ¹®ÀÚµé·Î ¸¸µé¾îÁöµµ·Ï Çϸç, ±×°ÍµéÀº ¾Æ·¡¿Í °°ÀÌ Çؼ® µË´Ï´Ù. <verb> \a ASCII Á¾¼Ò¸® ¹®ÀÚ(07) \d "¿äÀÏ ´Þ ³¯Â¥" Çü½ÄÀÇ ³¯Â¥ Ç¥½Ã (¿¹ : "Tue May 26") \e ASCIIÀÇ escape ¹®ÀÚ (033) \h ù¹ø° "." ±îÁöÀÇ hostname \H hostname \n »õ·Î¿î ÁÙ(ÁÙ ¹Ù²Ù±â) \r carrage return \s ½©ÀÇ À̸§, $0 ÀÇ basename (¸¶Áö¸· slashÀÇ ´ÙÀ½¿¡ µû¶ó¿À´Â ºÎºÐ) \t 24-½Ã°£À¸·Î ÇöÀç ½Ã°¢, HH:MM:SS(½Ã:ºÐ:ÃÊ) Çü½Ä \T 12-½Ã°£À¸·Î ÇöÀç ½Ã°¢, HH:MM:SS(½Ã:ºÐ:ÃÊ) Çü½Ä \@ 12-½Ã°£À¸·Î ÇöÀç ½Ã°¢, ¿ÀÀü/¿ÀÈÄ Çü½Ä \u ÇöÀç »ç¿ëÀÚÀÇ username \v bashÀÇ ¹öÀü(¿¹: 2.00) \V bashÀÇ ¹èÆ÷, ¹öÀü + ÆÐÄ¡¼öÁØ (¿¹ : 2.00.0) \w ÇöÀç ÀÛ¾÷ µð·¢Å丮 \W ÇöÀç ÀÛ¾÷ µð·¢Å丮ÀÇ basename \! ÇöÀç ¸í·É¾îÀÇ history ¹øÈ£ \# ÇöÀç ¸í·É¾îÀÇ command ¹øÈ£ \$ À¯È¿ÇÑ UID°¡ 0 À̸é # ¸¦, ±×·¸Áö ¾ÊÀ¸¸é $ À» Ç¥½Ã \nnn 8 Áø¼ö nnn¿¡ ÇØ´çÇÏ´Â ¹®ÀÚ \\ backslash \[ Å͹̳ΠÁ¶Á¤ sequence¸¦ ÇÁ·ÒÇÁÆ®¿¡ ³¢¿ö ³Ö±â À§ÇØ »ç¿ëµÉ ¼ö ÀÖ´Â non-printing ¹®ÀÚÀÇ ½ÃÀÛ \] non-printing ¹®ÀÚÀÇ ³¡ </verb> ¶°³µ´ø °÷¿¡¼­ °è¼ÓÇؼ­ : <verb> [giles@nikola giles]$ PS1="\u@\h \W> " giles@nikola giles> ls bin mail giles@nikola giles> </verb> ÀÌ°ÍÀº ´ëºÎºÐÀÇ ¹èÆ÷º»¿¡¼­ÀÇ µðÆúÆ®¿Í À¯»çÇÕ´Ï´Ù. Àú´Â ¾à°£ ´Ù¸£°Ô º¸À̱⸦ ¿øÇؼ­ ÀÌ·¸°Ô ¹Ù²Ù¾úÀ¾´Ï´Ù: <verb> giles@nikola giles> PS1="[\t][\u@\h:\w]\$ " [21:52:01][giles@nikola:~]$ ls bin mail [21:52:15][giles@nikola:~]$ </verb> </sect> <sect> ¿ÜºÎ ¸í·É¾îµé <p> <sect1> PROMPT_COMMAND <p> ¹è½¬¿¡¼­´Â ¶Ç ´Ù¸¥ ȯ°æ º¯¼ö PROMPT_COMMAND°¡ Á¦°øµË´Ï´Ù. ¹è½¬°¡ ÇÁ·ÒÇÁÆ®¸¦ Ç¥½ÃÇϱ⠹ٷΠÁ÷Àü¿¡, Á¤»óÀûÀÎ ¹è½¬ ¸í·É¾î·Î¼­, ÀÌ º¯¼öÀÇ ³»¿ëÀÌ ½ÇÇàµË´Ï´Ù. <verb> [21:55:01][giles@nikola:~] PS1="[\u@\h:\w]\$ " [giles@nikola:~] PROMPT_COMMAND="date +%H%M" 2155 [giles@nikola:~] d bin mail 2156 [giles@nikola:~] </verb> À§¿¡¼­ ÀϾ ÀÏÀ» ¸»¾¸µå¸®ÀÚ¸é, À̽ºÄÉÀÙ ½ÃÄö½º¿¡¼­ '\t'¸¦ Á¦¿Ü ½ÃÄѼ­, ÇÁ ·ÒÇÁÆ®¿¡ ½Ã°¢ÀÌ ´õ ÀÌ»ó Æ÷ÇÔµÇÁö ¾Êµµ·Ï ÇÏ¿´À¾´Ï´Ù. ±×¸®°í³ª¼­ 'date +%H%M' ¸¦ »ç¿ëÇÏ¿© Á¦°¡ ´õ ÁÁ¾ÆÇÏ´Â Çü½ÄÀ¸·Î ½Ã°¢À» Ç¥½ÃÇϵµ·Ï ÇÏ¿´À¾´Ï´Ù. ±×·¸Áö¸¸ À̹ø¿¡´Â ÇÁ·ÒÇÁÆ®¿Í´Â ¼­·Î ´Ù¸¥ ÁÙ¿¡ ³ªÅ¸³µÀ¾´Ï´Ù. ¹è½¬2.0+ ¿¡¼­´Â 'echo -n ...'¸¦ »ç¿ëÇÏ¿© Àß Á¤µ·ÇÒ ¼ö ÀÖÀ¸¸ç, ¾Æ·¡¿¡¼­¿Í °°ÀÌ ÀÛ¿ëÇÏÁö¸¸, ¹è½¬1.14.7¿¡¼­´Â ÀÛµ¿ÇÏÁö ¾Ê°Ô µË´Ï´Ù.: ¸í¹éÈ÷ ÇÁ·ÒÇÁÆ®´Â ´Ù¸¥ ½ÄÀ¸·Î ÀÛ¼ºµÇ °í, ¾Æ·¡¿Í °°Àº ¹æ¹ýÀº Áߺ¹µÈ ¹®ÀåÀ¸·Î ³ªÅ¸³³´Ï´Ù. <verb> 2156 [giles@nikola:~] PROMPT_COMMAND="echo -n [$(date +%H%M)]" [2156][giles@nikola:~]$ [2156][giles@nikola:~]$ d bin mail [2157][giles@nikola:~]$ unset PROMPT_COMMAND [giles@nikola:~] </verb> 'echo -n ...'¿¡ ÀÇÇØ ³¯Â¥ ¸í·ÉÀÇ Ãâ·ÂÀÌ Á¶ÀýµÇ°í µÚ¿¡ µû¸£´Â '»õÁÙ' ¹®ÀÚ°¡ ¹«È¿ È­µÇ¾î, ÇÁ·ÒÇÁÆ®¿Í ÇÔ²² ¸ðµÎ ÇÑ ÁÙ¿¡ ³ªÅ¸³ª°Ô µË´Ï´Ù. ¸¶Áö¸·¿¡¼­, 'unset' ¸í·É ¿¡ ÀÇÇØ È¯°æ º¯¼ö PROMPT_COMMAND°¡ Á¦°ÅµÇ¾úÀ¾´Ï´Ù. ¸í·É¾î ´ëÄ¡¸¦ À§ÇØ $(<command>) ¾ç½ÄÀÌ »ç¿ëµÈ °Í¿¡ À¯ÀÇÇϽʽÿÀ: Áï, <verb> $(date +%H%M) </verb> ´Â "¿©±â¿¡´Ù 'date +%H%M' ¸í·ÉÀ¸·Î ºÎÅÍÀÇ Ãâ·ÂÀ¸·Î ´ëÄ¡ÇϽÿÀ" ¶ó´Â ÀÇ¹Ì ÀÔ´Ï´Ù. ÀÌ°ÍÀº ¹è½¬2.0+ ¿¡¼­ ÀÛµ¿ÇÕ´Ï´Ù. 1.14.7 ÀÌÀüÀÇ ¸î¸î ±¸ ¹öÀüÀÇ ¹è½¬ ¿¡¼­´Â ¿ªÀÎ¿ë ºÎÈ£(backquates)(`date +%H%M`)°¡ ÇÊ¿äÇÒ ¼ö°¡ ÀÖÀ¾´Ï´Ù. ¿ªÀÎ¿ë ºÎÈ£´Â ¹è½¬2.0+ ¿¡¼­µµ »ç¿ë °¡´ÉÇÏÁö¸¸, $() ¾ç½ÄÀ» ´õ ¼±È£ ÇÔ¿¡ µû¶ó »ç¶óÁ® °¡°í ÀÖÀ¸¸ç, $() ¾ç½ÄÀÌ ÀÚ¸®¸¦ ±»Çô °¡°í ÀÖÀ¾´Ï´Ù. ÀÌ ¹®¼­¿¡¼­µµ »õ ¾ç½ÄÀ¸·Î °è¼Ó µÉ °Í ÀÔ´Ï´Ù. ¸¸¾à ÀÌÀü ¹öÀüÀ» »ç¿ëÇÏ°í °è½Ã´Ù¸é, $() ÀÌ ³ªÅ¸³ª´Â °÷¿¡¼­ ¿ªÀÎ¿ë ºÎÈ£·Î ´ëÄ¡ÇÏ¸é µÉ °ÍÀÔ´Ï´Ù. ¸¸¾à, ¸í·É¾î ´ëÄ¡°¡ À̽ºÄÉÀ٠󸮵Ǿî ÀÖ´Ù¸é (Áï, \$(command) ), basckslash('\')¸¦ »ç¿ëÇÏ¿© ¾çÂÊÀÇ ¿ªÀÎ¿ë ºÎÈ£¸¦ À̽ºÄÉÀ٠ó¸® ÇϽʽÿÀ(Áï, \'command\' ). <sect1> ÇÁ·ÒÇÁÆ®¿¡¼­ÀÇ ¿ÜºÎ ¸í·É¾îµé <p> ÇÁ·ÒÇÁÆ®¿¡¼­ Á¤»óÀûÀÎ ¸®´ª½º ¸í·ÉÀÇ Ãâ·Â °á°úµµ ¿ª½Ã »ç¿ë °¡´ÉÇÕ´Ï´Ù. ³Ê¹« ¸¹Àº °ÍµéÀ» ÇÁ·ÒÇÁÆ®¿¡ Æ÷ÇÔÇϱ⸦ ¿øÇÏÁö´Â ¾ÊÀ» °ÍÀÔ´Ï´Ù. ±×·¸Áö ¾ÊÀ¸¸é ÇÁ·ÒÇÁÆ®°¡ ³Ê¹« ±æ¾îÁú Å״ϱî¿ä. ¶ÇÇÑ, ½Å¼ÓÈ÷ 󸮵Ǵ ¸í·É¾î¸¦ »ç¿ëÇϱ⸦ ¿øÇÒ °ÍÀÔ´Ï´Ù. ¿Ö³ÄÇϸé, ½ºÅ©¸°¿¡ ÇÁ·ÒÇÁÆ®°¡ ³ªÅ¸³¯ ¶§ ¸¶´Ù ±×¸í·É¾îµéÀÌ ¼öÇàµÇ¾î¾ß ÇÏ°í, ÀÛ¾÷À» ÇÏ´Â µ¿¾È¿¡ ÇÁ·ÒÇÁÆ®°¡ ³ªÅ¸³ª´Â °ÍÀÌ ¼º°¡½Ã°Ô µÉ ¼öµµ Àֱ⠶§¹®ÀÔ´Ï´Ù.( ÀÌÀüÀÇ ¿¹¿Í ¾ÆÁÖ À¯»çÇÑ °á°úÀÌÁö¸¸, ¹è½¬1.14.7¿¡¼­µµ ÀÛµ¿ÇÕ´Ï´Ù) <verb> [21:58:33][giles@nikola:~]$ PS1="[\$(date +%H%M)][\u@\h:\w]\$ " [2159][giles@nikola:~]$ ls bin mail [2200][giles@nikola:~]$ </verb> ¸í·É¾î ´ëÄ¡ÀÇ ´Þ·¯±âÈ£('$') ¾ÕÀÇ backslash¿¡ ÁÖÀÇÇÏ´Â °ÍÀÌ Áß¿äÇÕ´Ï´Ù. ±×°ÍÀÌ ¾øÀ¸¸é ¿ÜºÎ ¸í·É¾î´Â Á¤È®ÇÏ°Ô Çѹø¸¸ ¼öÇàµË´Ï´Ù: PS1 º¯¼ö°¡ ÀÐ¾î µé¿©Áú ¶§ ¸¶´Ù. ÀÌ ÇÁ·ÒÇÁÆ®ÀÇ °æ¿ì¿¡´Â, ÇÁ·ÒÇÁÆ®ÀÇ ±æÀÌ°¡ ¾ó¸¶³ª µÇ´ÂÁö »ó°ü ¾øÀÌ µ¿½Ã¿¡ Ç¥½ÃµÉ °ÍÀ̶ó´Â °ÍÀ» ÀǹÌÇÕ´Ï´Ù. backslash('\')¿¡ ÀÇÇØ $()ÀÇ ³»¿ëÀÌ ½© Çؼ®À¸·Î ºÎÅÍ º¸È£µÇ¾î, "date" ¸í·ÉÀÌ »õ·Î¿î ÇÁ·ÒÇÁÆ® °¡ »ý¼ºµÉ ¶§ ¸¶´Ù ¼öÇàµË´Ï´Ù. ¸®´ª½º¿¡´Â ¸¹Àº Á¾·ùÀÇ, date, grep, ¶Ç´Â wc ¿Í °°Àº Á¶±×¸¶ÇÑ À¯Æ¿¸®Æ¼ ÇÁ·Î±×·¥µéÀÌ ºÎ¼öµÇ¾î ÀÖ¾î, µ¥ÀÌŸ¸¦ ó¸®ÇÒ ¼ö ÀÖµµ·Ï ÇÕ´Ï´Ù. ¸¸¾à, À̵é ÇÁ·Î±×·¥µéÀÇ ¾ÆÁÖ º¹ÀâÇÑ Á¶ÇÕÀ» »ý¼ºÇؼ­ ÇÁ·ÒÇÁÆ® ¾È¿¡ ³Ö°íÀÚ ÇϽŠ´Ù¸é, ¿©·¯ºÐ ÀÚ½ÅÀÇ ½© ½ºÅ©¸³Æ®¸¦ ÀÛ¼ºÇÑ ´ÙÀ½, ÇÁ·ÒÇÁÆ®¿¡¼­ ±×°ÍÀ» ºÒ·¯ µéÀÌ´Â ¹æ¹ýÀÌ ´õ ½¬¿ï ¼ö ÀÖÀ¾´Ï´Ù. ÀûÀýÇÑ ¶§¿¡ ½© º¯¼öµéÀÌ Ç®¾îÁöµµ·Ï Çϱâ À§ÇØ ½© ½ºÅ©¸³Æ® ³»¿¡¼­ ÀÚÁÖ À̽ºÄÉÀÙ ½ÃÄö½ºµéÀÌ ¿ä±¸µË´Ï´Ù(À§¿¡¼­ º¸¿©Áø ³¯Â¥ ¸í·É¾î¿Í °°ÀÌ): ÀÌ°ÍÀº ÇÁ·ÒÇÁÆ® PS1 ¶óÀÎ ³»¿¡¼­ ÇÑ ´Ü°è ³ôÀº ¼öÁØÀ¸·Î ¿Ã¶ó °¡´Â °ÍÀ̸ç, ½© ½ºÅ©¸³Æ®¸¦ »ý¼ºÇÏ¿© ȸÇÇÇÏ´Â ¹æ¹ýÀº ¾ÆÁÖ ÈǸ¢ÇÑ ¾ÆÀ̵ð¾îÀÔ´Ï´Ù. ÇÁ·ÒÇÁÆ® ³»¿¡¼­ »ç¿ëµÇ´Â Á¶±×¸¸ ½© ½ºÅ©¸³Æ® ¿¹Á¦°¡ ¾Æ·¡¿¡¼­ ÁÖ¾îÁý´Ï´Ù. <verb> #!/bin/bash # lsbytesum - sum the number of bytes in a directory listing TotalBytes=0 for Bytes in $(ls -l | grep "^-" | cut -c30-41) do let TotalBytes=$TotalBytes+$Bytes done TotalMeg=$(echo -e "scale=3 \n$TotalBytes/1048576 \nquit" | bc) echo -n "$TotalMeg" </verb> Àú´Â ÀÌ°ÍÀ» ¶§¿¡ µû¶ó¼­ ÇÔ¼ö·Î(ÈξÀ È¿À²ÀûÀÌÁö¸¸-ºÒÇàÇÏ°Ôµµ ÇÔ¼ö¿¡ ´ëÇÑ ÀÚ¼¼ÇÑ ¼³¸íÀº ÀÌ ¹®¼­ÀÇ ¹üÀ§ ¹ÛÀÔ´Ï´Ù), ¶Ç´Â °æ·Î¿¡ Æ÷ÇԵǾî ÀÖ´Â '~/bin' µð·¢Å丮¿¡ ÀÖ´Â ½© ½ºÅ©¸³Æ®·Î º¸°üÇßÀ¾´Ï´Ù. ÇÁ·ÒÇÁÆ®¿¡ »ç¿ëµÇ¾î ¾Æ·¡¿Í °°Àº °á°ú°¡ µË´Ï´Ù. <verb> [2158][giles@nikola:~]$ PS1="[\u@\h:\w (\$(lsbytesum) Mb)]\$ " [giles@nikola:~ (0 Mb)]$ cd /bin [giles@nikola:/bin (4.498 Mb)]$ </verb> <sect1> ÇÁ·ÒÇÁÆ®¿¡¼­ ÇÊ¿äÇÑ ±×¹ÛÀÇ °Íµé <p> ´ëºÎºÐÀÇ Á¦°¡ ¸¸µç ÇÁ·ÒÇÁÆ®¿¡´Â ½Ã°¢°ú ÇöÀç µð·¢Å丮ÀÇ À̸§ÀÌ Æ÷ÇԵǾî ÀÖ´Ù´Â °ÍÀ» ¾Ë ¼ö ÀÖÀ¾´Ï´Ù. ¿©±â¿¡´Ù°¡, ¼ÒÇüÀÌÁö¸¸ È¿°úÀûÀÎ Dan¾¾°¡ ¸¸µç ÇÁ·ÒÇÁÆ®¸¦ ³Ö°íÀÚ ÇÕ´Ï´Ù. <verb> [giles@nikola:~]$ cur_tty=$(tty | sed -e "s/.*tty\(.*\)/\1/") [giles@nikola:~]$ echo $cur_tty p4 [giles@nikola:~]$ PS1="\!,$cur_tty,\$?\$ " 1095,p4,0$ </verb> µð·¢Å丮 °æ·Î¸¦ ¹Ù²Þ¿¡ µû¶ó¼­ ÇÁ·ÒÇÁÆ®ÀÇ Å©±â°¡ °©ÀÛ½º·´°Ô ¹Ù²ð ¼ö Àֱ⠶§¹®¿¡ Dan¾¾´Â ÇÁ·ÒÇÁÆ®¿¡ ÇöÀçÀÇ µð·¢Å丮°¡ Ç¥½ÃµÇ´Â °ÍÀ» ÁÁ¾ÆÇÏÁö ¾ÊÀ¾´Ï´Ù. ±×·¡¼­ ±×´Â µð·¢Å丮ÀÇ ÀÚÃ븦 ±×ÀÇ ¸Ó¸®¼Ó¿¡ ±â¾ïÇÕ´Ï´Ù(¶Ç´Â "pwd"¸¦ Ä¡±âµµ ÇÕ´Ï´Ù.) Dan¾¾´Â cash°ú tcsh·Î À¯´Ð½º¸¦ ÀÍÇû±â ¶§¹®¿¡, ±×´Â ¸í·É¾î history¸¦ ±¤¹üÀ§ ÇÏ°Ô »ç¿ëÇÏ°í ÀÖÀ¸¸ç(¿ì¸®µéÀÇ ´ëºÎºÐÀº ¹è½¬¸¦ ¾´´Ù°í ¹Ï±â¿¡ ±×·² ÇÊ¿ä°¡ ¾øÁö¸¸), ±×·¡¼­, ±×ÀÇ ÇÁ·ÒÇÁÆ®ÀÇ Ã¹¹ø° Ç׸ñÀº ¸í·É¾î history ¹øÈ£ÀÔ´Ï´Ù. µÎ¹ø° Ç׸ñÀº ttyÀÇ Áß¿ä ¹®ÀÚµé ÀÔ´Ï´Ù("tty"ÀÇ Ãâ·ÂÀ» 'sed'·Î ¸ðÀ¾´Ï´Ù). ¼¼¹ø° Ç×Àº ¸¶Áö¸· command/pipelineÀÇ exit °ªÀÔ´Ï´Ù(note that this is rendered useless by any command executed within the prompt - you could work around that by capturing it to a variable and playing it back, though). ¸¶Áö¸·À¸·Î, "\$"Àº ÀÏ¹Ý »ç¿ëÀÚ¿¡°Ô´Â ´Þ·¯ ±âÈ£¸¦ ³ªÅ¸³»°í, »ç¿ëÀÚ°¡ ·çÆ®ÀÏ °æ¿ì¿¡´Â Çؽ¬ Ç¥½Ã("#") ¸¦ ³ªÅ¸³À´Ï´Ù. <sect> ¹è½¬ ȯ°æ°ú ÇÔ¼öµé <p> ¾Õ¿¡¼­ ¾ð±ÞµÈ ¹Ù¿Í °°ÀÌ, PS1, PS2, PS3, PS4 ±×¸®°í PROMPT_COMMAND µéÀº ¸ðµÎ ¹è½¬ ȯ°æÀ¸·Î ÀúÀåµÇ¾î ÀÖÀ¾´Ï´Ù. DOS¿¡ Àͼ÷ÇÑ ºÐµéÀº ¾ÆÁÖ Å« µ¢¾î¸®ÀÇ Á¤º¸¸¦ ȯ°æÀ¸·Î ³Ñ±â´Âµ¥¿¡ ´ëÇÏ¿© µÎ·Á¿î »ý°¢À» °¡Áú °ÍÀÔ´Ï´Ù. ¿Ö³ÄÇϸé DOSÀÇ È¯°æÀº Á¶±×¸¶Çß À¸¸ç, Àß È®ÀåÇÏÁöµµ ¾Ê¾Ò±â ¶§¹®ÀÔ´Ï´Ù. ȯ°æ¿¡ ³ÖÀ» ¼ö ÀÖ°í ³Ö¾î¾ß¸¸ ÇÏ´Â °Íµé¿¡ ´ëÇؼ­ ½ÇÁ¦ÀûÀÎ Á¦¾àÀÌ ÀÖÀ»Áöµµ ¸ð¸£Áö¸¸, ±×°ÍµéÀÌ ¹¹°¡ µÉÁöµµ ¸ð¸£°í, ¿©±â¿¡¼­ ´Â DOS »ç¿ëÀڵ鿡°Ô Àͼ÷ÇÑ ±×·± ȯ°æº¸´Ù´Â ±Ô¸ð¿¡ À־ ¾Æ¸¶ ¸î¹è³ª ÈξÀ ´õ Å« °Í¿¡ ´ëÇÏ¿© À̾߱⸦ ÇÏ°í ÀÖÀ¾´Ï´Ù. ¿ì¸®ÀÇ Dan¾¾°¡ ¸»ÇÕ´Ï´Ù: "Á¦°¡ »ç¿ëÇÏ´Â ½©¿¡´Â, 62°³ÀÇ ¾Ë¸®¾Æ½º¿Í 25°³ÀÇ ÇÔ¼ö°¡ ÀÖÀ¾´Ï´Ù. ±â°è¿¡¼­ Á÷Á¢ »ç¿ëÇÒ °æ¿ì¿¡, ¾î¶² °ÍÀÌ ´Üµ¶ÀûÀ¸·Î ÇÊ¿äÇÏ°í bash¿¡¼­ ¼ÕÀ¸·Î ½±°Ô ¾º¾îÁú ¼ö À¸¸é, ±×°ÍÀ» ½© ÇÔ¼ö·Î ¸¸µç´Ù´Â °ÍÀÌ Á¦ÀÏ Ã¹¹ø° ±ÔÄ¢ÀÔ´Ï´Ù(¾Ë¸®¾Æ½º·Î ½±°Ô Ç¥Çö ÇÒ ¼ö ¾ø´Ù´Â °¡Á¤ÇÏ¿¡¼­). ¸¸¾à ¸Þ¸ð¸®¿¡ ´ëÇؼ­ °ÆÁ¤ÇÏ´Â »ç¶÷µéÀÌ ÀÖ´Ù¸é, ±×µéÀº bash¸¦ »ç¿ëÇÒ ÇÊ¿ä°¡ ¾øÀ¾´Ï´Ù. Bash´Â ÀúÀÇ ¸®´ª¼­ ±â°è¿¡¼­ ½ÇÇàµÇ´Â °¡Àå Å« ÇÁ·Î±×·¥ ÁßÀÇ ÇϳªÀÔ´Ï´Ù(OracleÀ» Á¦¿ÜÇÏ°í). ¶§¶§·Î 'top'À» ½ÇÇà ½ÃÄѼ­ »ç¿ë ¸Þ¸ð¸®º°·Î ºÐ·ùÇϱâ À§ÇØ 'M'À» ´­·¯ º¸¼¼¿ä-¸ñ·Ï¿¡¼­ bash°¡ ¾ó¸¶³ª À­ÂÊ¿¡ °¡±îÀÌ ÀÖ´ÂÁö »ìÆì º¸¼¼¿ä. À¹, sendmailº¸´Ùµµ ´õ µ¢Ä¡°¡ Å©±º¿ä! ±×µé ´õ·¯ °¡¼­ ash³ª ¶Ç´Â ´Ù¸¥ °ÍµéÀ» ±¸Ç϶ó°í Çϼ¼¿ä" ¾Æ¸¶µµ ±×´Â ±× ÀÛ¾÷À» ÇÏ·Á°í ÇÏ´Â ³¯¿¡¸¸ ÄܼÖÀ» »ç¿ëÇÏÁö¾Ê³ª ÃßÃøÇÕ´Ï´Ù:X³ª XÀÀ¿ë ÇÁ·Î±×·¥À» ½ÇÇà½ÃÅ°¸é, ¹è½¬º¸´Ù ´õ Å« °ÍµéÀÌ ¸¹ÀÌ ÀÖÀ¾´Ï´Ù. ±×·¸Áö¸¸, ¾ÆÀ̵ð¾î´Â µ¿ÀÏÇÕ´Ï´Ù:ȯ°æÀ̶ó´Â °ÍÀº »ç¿ëµÇ¾î¾ß ÇÏ´Â °ÍÀÌ°í, ±×°ÍÀÌ Â÷°í ³ÑÄ¡´Â °ÍÀº °ÆÁ¤ÇÒ ÇÊ¿ä°¡ ¾øÀ¾´Ï´Ù. Á¦°¡ ÀÌ·¸°Ô ¸»ÇÒ ¶§(³Ê¹« ´Ü¼øÈ­ ½ÃÄ×´Ù´Â °Í¿¡ ´ëÇؼ­) À¯´Ð½º ±¸·çµé·Î ºÎÅÍ Ã¥¸Á À» ¹ÞÀ» °¢¿À¸¦ ÇÏÁö¸¸, ÇÔ¼öµéÀ̶õ ±âº»ÀûÀ¸·Î È¿À²¼ºÀ» À§ÇØ È¯°æÀ¸·Î ÀûÀçµÇ´Â Á¶±×¸¸ ½© ½ºÅ©¸³Æ®µéÀÔ´Ï´Ù. Dan¾¾ÀÇ ¸»À» ´Ù½Ã ÀοëÇÕ´Ï´Ù:"½© ÇÔ¼öµéÀº °¡´ÉÇÑ ¸¸Å­ È¿À²È­ ÇÑ°ÍÀÔ´Ï´Ù. It is the approximate equivalent of sourcing a bash/bourne shell script save that no file I/O need be done as the function is already in memory. ½© ÇÔ¼öµéÀº ÀüÇüÀûÀ¸·Î, ±×°ÍµéÀÌ ÃÖÃÊÀÇ ½©¿¡¼­¸¸ ÇÊ¿äÇÑÁö ¶Ç´Â ÇϺÎÀÇ ½©¿¡¼­µµ ¿ä±¸µÇ´Â°¡¿¡ µû¶ó, [.bashrc ¶Ç´Â .bash_profile]·Î ºÎÅÍ ÀûÀçµË´Ï´Ù. ½© ½ºÅ©¸³Æ® Çϳª¸¦ ½ÇÇà ½ÃÄѼ­ ÀÌ°ÍÀ» ´ëºñÇØ º¸½Ê½Ã¿À: ½©ÀÌ ºÐ±âÇÏ¿©, ÀÚ½Ä ÇÁ·Î½ê½º°¡ exec ¸¦ ¼öÇàÇÏ°í, potentially °æ·Î°¡ ã¾ÆÁö°í, Ä¿³ÎÀÌ ÆÄÀÏÀ» ¿­°í ±× ÆÄÀÏÀ» ¾î¶»°Ô ½ÇÇàÇÒÁö °áÁ¤ÇϱâÀ§ÇØ ÃæºÐÇÑ ¹ÙÀÌÆ®¸¦ °Ë»çÇϸç, ½© ½ºÅ©¸³Æ®ÀÎ °æ¿ì ½©ÀÌ ±× ½ºÅ©¸³Æ®ÀÇ À̸§À» º¯¼ö·Î ÇÏ¿© ½ÃÀÛÇÏ¿©¾ß Çϸç, ±× ´ÙÀ½¿¡ ÆÄÀÏÀ» ¿­°í, ÀÐ°í ±× ¹®ÀåÀ» ¼öÇàÇÕ´Ï´Ù. ½© ÇÔ¼ö¿Í ºñ±³ÇÏ¿©, ¹®ÀåÀ» ¼öÇàÇÏ´Â °ÍÀ» »©°í´Â ´Ù¸¥ °ÍµéÀº ºÒÇÊ¿äÇÑ °ÍÀ¸·Î °£Áֵ˴ϴÙ." </sect> <sect> XÅÒ Á¦¸ñ Ç¥½ÃÁÙÀÇ Á¶ÀÛ <p> Non-printing À̽ºÄÉÀÙ ½ÃÄö½ºµéÀ» »ç¿ëÇÏ¿© Èï¹ÌÀÖ´Â ÇÁ·ÒÇÁÆ®¸¦ »ý¼ºÇÒ ¼ö ÀÖÀ¾´Ï ´Ù. À̵é À̽ºÄÉÀÙ ½ÃÄö½º¸¦ »ç¿ëÇϱâ À§Çؼ­´Â, ±×°ÍµéÀ» \[ ¿Í \] ·Î µÑ·¯ ½Ò ÇÊ¿ä °¡ Àִµ¥, ±×·¸°Ô ÇÔÀ¸·Î½á ¹è½¬°¡ ÇÁ·ÒÇÁÆ®ÀÇ ±æÀ̸¦ °è»êÇÒ ¶§ ±×°ÍµéÀ» ¹«½ÃÇϵµ ·Ï ÇÒ ¼ö ÀÖÀ¾´Ï´Ù. ÀÌµé ±¸È¹ ¹®ÀÚµéÀ» ºü¶ß¸®°Ô µÇ¸é ÇÁ·ÒÇÁÆ®ÀÇ ½ÇÁ¦ ±æÀ̸¦ ¾Ë ¼ö ¾ø°Ô µÇ±â ¶§¹®¿¡, Ä¿¼­°¡ ¾û¶×ÇÑ °÷¿¡ ³ªÅ¸³ª°Ô µË´Ï´Ù. ¶ÇÇÑ, À̽ºÄÉÀÙ ½ÃÄö½ºµéÀÇ ¾Õ¿¡´Â ¹è½¬¹öÀü 2 ÀÌÀüÀÇ °æ¿ì¿¡´Â \033[, ±× ÀÌÈÄÀÇ ¹öÀüÀÎ °æ¿ì¿¡´Â \033[ À̰ųª \e[ ÀÌ ¼±Çà µÇ¾î¾ß¸¸ ÇÕ´Ï´Ù. Äֿܼ¡¼­, ÇÁ·ÒÇÁÆ®¸¦ ½á¼­ XÅÒÀÇ Á¦¸ñÇ¥½ÃÁÙÀ» º¯°æÇÏ°íÀÚ ÇÒ °æ¿ì¿¡´Â, ÇÁ·ÒÇÁÆ®¿¡ À⵿»ç´ÏµéÀÌ ³ªÅ¸³ª°Ô µË´Ï´Ù. ÀÌ°ÍÀ» ÇÇÇϱâ À§Çؼ­, ÇÁ·ÒÇÁÆ®°¡ XÅÒ¿¡ ÀÖ°Ô µÉ °ÍÀ̶ó´Â °ÍÀ» ¹è½¬¿¡°Ô ÀÏ·¯ ÁÖ±âÀ§ÇØ TERM ȯ°æº¯¼ö¸¦ Å×½ºÆ®ÇØ º¸½Ê½Ã¿À. <verb> function proml { case $TERM in xterm*) local TITLEBAR='\[\033]0;\u@\h:\w\007\]' ;; *) local TITLEBAR='' ;; esac PS1="${TITLEBAR}\ [\$(date +%H%M)]\ [\u@\h:\w]\ \$ " PS2='> ' PS4='+ ' } </verb> ÀÌ°ÍÀº '~/.bashrc'¿¡ Æ÷Ç﵃ ¼ö ÀÖ´Â ÇÔ¼öÀÇ ÇϳªÀÔ´Ï´Ù. ÇÔ¼öÀÇ À̸§À» ºÒ·¯¼­ ½ÇÇàÇÒ ¼ö ÀÖÀ¾´Ï´Ù. PS1¹®ÀÚ¿­°ú ¸¶Âù°¡Áö·Î, ÇÔ¼öµµ ȯ°æ¿¡ ÀúÀåµÇ¾î ÀÖÀ¾´Ï´Ù. PS1¹®ÀÚ¿­ÀÌ ÇÔ¼ö¿¡ ÀÇÇØ Çѹø ¼³Á¤µÇ¸é, 'unset proml' ¸í·ÉÀ¸·Î ÇÔ¼ö¸¦ ȯ°æÀ¸·Î ºÎÅÍ Á¦°ÅÇÒ ¼ö ÀÖÀ¾´Ï´Ù. ÇÁ·ÒÇÁÆ®´Â XÅÒ¿¡ ÀÖ´Â °Í¿¡¼­ Äֿܼ¡ ÀÖ´Â °ÍÀ¸·Î º¯°æÇÒ ¼ö ¾ø±â ¶§¹®¿¡, TERM º¯¼ö´Â ÇÁ·ÒÇÁÆ®°¡ »ý¼ºµÉ ¶§ ¸¶´Ù Å×½ºÆ® µÇÁö ¾ÊÀ¾ ´Ï´Ù. ÇÁ·ÒÇÁÆ®¸¦ Á¤ÀÇÇÒ ¶§ ¿¬¼ÓÇ¥½Ã(backslashes'\')µéÀ» »ç¿ëÇÏ¿©, ¿©·¯ ÁÙ¿¡ °ÉÃÄ ±×°ÍÀ» ÇÒ ¼ö ÀÖÀ¾´Ï´Ù. ÀÌ·± ¹æ¹ýÀÌ ´õ Àб⠽±°Ô ÇØÁÖ¸ç, ¼öÁ¤Çϰųª µð¹ö°Å ½Ã¿¡ À¯¸®ÇÕ´Ï´Ù. Àú´Â ÀÌ°ÍÀ» ÇÔ¼ö·Î¼­ Á¤ÀÇÇϴµ¥, ¹è½¬ÇÁ·ÒÇÁÆ® ÆÐÅ°Áö(À̹®¼­ÀÇ ÈĹݿ¡¼­ ³íÀÇÇÔ)°¡ ÇÁ·ÒÇÁÆ®µéÀ» ´Ù·ç´Â ¹æ¹ýÀ̱⠶§¹®ÀÔ´Ï´Ù:À¯ÀÏÇÑ ¹æ¹ýÀº ¾Æ´ÏÁö¸¸, Àß ÀÛµ¿ÇÕ´Ï´Ù. »ç¿ëÇÏ´Â ÇÁ·ÒÇÁÆ®°¡ ´õ º¹ÀâÇØÁü¿¡ µû¶ó, ±×°ÍµéÀ» ÇÁ·ÒÇÁÆ®¿¡ ŸÀÌÇÁÇÏ´Â °ÍÀÌ ´õ¿í ´õ ¼º°¡½Ã°Ô µÇ¹Ç·Î, ±×°ÍµéÀ» ÅؽºÆ® ÆÄÀÏ¿¡´Ù ¸¸µé¾î ³õ´Â °ÍÀÌ ´õ ½Ç¿ëÀûÀÔ ´Ï´Ù. ÀÌ °æ¿ì¿¡ À־, ÇÁ·ÒÇÁÆ®¿¡¼­ Å×½ºÆ®Çϱâ À§ÇØ, "proml"À̶ó´Â ÅؽºÆ® ÆÄÀÏ¿¡ ÀúÀåÇϽʽÿÀ. ¾Æ·¡¿Í °°ÀÌ ÀÛ¾÷À» ÇÒ ¼ö ÀÖÀ¾´Ï´Ù. <verb> [giles@nikola:/bin (4.498 Mb)]$ cd -> ÇÁ·ÒÇÁÆ®¸¦ ÀúÀåÇÏ°íÀÚ ÇÏ´Â µð·¢Å丮·Î À̵¿ [giles@nikola:~ (0 Mb)]$ vi proml -> ÇÁ·ÒÇÁÆ® ÆÄÀÏÀ» ÀÛ¼ºÇÔ ... -> À§¿¡ ÁÖ¾îÁø ³»¿ëÀ» ÀÔ·ÂÇÔ [giles@nikola:~ (0 Mb)]$ source proml -> ÇÁ·ÒÇÁÆ® ÇÔ¼ö¸¦ ÀÐ¾î µéÀÓ [giles@nikola:~ (0 Mb)]$ proml -> ÇÁ·ÒÇÁÆ® ÇÔ¼ö¸¦ ½ÇÇà </verb> ÀÌ ÇÁ·ÒÇÁÆ®¸¦ »ý¼ºÇÏ´Â µ¥ À־ ù¹ø° ½ºÅÜÀº, ¿ì¸®µéÀÌ ½ÃÀÛÇÏ´Â ½©ÀÌ XÅÒÀÎÁö ¾Æ´ÑÁö¸¦ Å×½ºÆ®ÇÕ´Ï´Ù:¸¸¾à ±×·¸´Ù¸é, ½© º¯¼ö (${TITLEBAR})°¡ Á¤Àǵ˴ϴÙ. ±×°ÍÀº Àû´çÇÑ À̽ºÄÉÀÙ ½ÃÄö½ºµé°ú XÅÒ Á¦¸ñÇ¥½ÃÁÙ¿¡ <»ç¿ëÀÚ>@<±â°è>:<ÀÛ¾÷ µð·¢ Å丮>¸¦ Ç¥½ÃÇÏ´Â \u@\h:\w ·Î ±¸¼ºµË´Ï´Ù. ÀÌ°ÍÀº Ưº°È÷ ÃÖ¼ÒÈ­µÈ XÅҵ鿡¼­ À¯¿ëÇÏ°í, ´õ¿í ½Å¼ÓÇÏ°Ô Å͹̳ÎÀ» È®ÀÎÇϵµ·Ï ÇØ ÁÝ´Ï´Ù. ÀÌ ÇÁ·ÒÇÁÆ®¿¡ ÀÖ´Â ´Ù¸¥ °ÍµéÀº ¿ì¸®°¡ ÀÌÀü¿¡ ¸¸µé¾ú´ø °Íµé°ú À¯»çÇÒ °ÍÀÔ´Ï´Ù. ÀÌ·± ½ÄÀ¸·Î XÅÒ Á¦¸ñÇ¥½ÃÁÙÀ» Á¶ÀÛÇÏ´Â µ¥ ÀÖ¾î ´Ü ÇϳªÀÇ ¾àÁ¡Àº, Á¦¸ñÇ¥½ÃÁÙ hack¸¦ ¼³Á¤ÇÏÁö ¾ÊÀº ½Ã½ºÅÛÀ¸·Î ·Î±×ÀÎÇØ µé¾î °¥ ¶§ ³ªÅ¸³³´Ï´Ù:XÅÒÀº Á¦¸ñ Ç¥½ÃÁÙ hack °¡ À§Ä¡ÇÏ´Â ÀÌÀü ½Ã½ºÅÛÀ¸·Î ºÎÅÍÀÇ Á¤º¸¸¦ °è¼ÓÇؼ­ º¸¿© ÁÙ °ÍÀÔ´Ï´Ù. </sect> <sect> »ö <p> ¾Õ¿¡¼­ ¾ð±ÞÇÑ ¹Ù¿Í °°ÀÌ, non-printing À̽ºÄÉÀÙ ½ÃÄö½ºµéÀº \[\033[¿Í \]·Î µÑ·¯ ½Î¿© ÀÖ¾î¾ß¸¸ ÇÕ´Ï´Ù. »ö À̽ºÄÉÀÙ ½ÃÄö½ºµéÀÇ °æ¿ì¿¡´Â, ¼Ò¹®ÀÚ mµµ °°ÀÌ ³Ö¾î¾ß ÇÕ´Ï´Ù. ¾Æ·¡¿Í °°Àº ÇÁ·ÒÇÁÆ®µéÀ» ½ÃµµÇؼ­, ¸í¸íµÈ »ö±òµéÀÌ ³ªÅ¸³ªÁö ¾Ê´Â´Ù¸é, '~/.Xdefaults' ÆÄÀÏ(ȤÀº °°Àº Á¾·ùÀÇ ÆÄÀÏ)À» °ËÅäÇؼ­ "XTerm*Foreground: BlanchedAlmond" ¿Í °°Àº ÁÙÀÌ ÀÖ´ÂÁö »ìÆì º¸½Ê½Ã¿À. ±× ÁÙÀÇ ¾ÕÂÊ¿¡ ´À³¦Ç¥('!')¸¦ »ðÀÔÇؼ­ ÁÖ¼® ó¸®ÇÒ ¼ö ÀÖÀ¾´Ï´Ù. ¹°·Ð, ÀÌ ÀÛ¾÷Àº »ç¿ëÇÏ´Â Å͹̳Π¿¡¹Ä·¹ÀÌÅÍÀÇ Á¾·ù¿¡ µû¶ó ´Þ¶ó Áý´Ï´Ù. ÀÌ°ÍÀÌ Å͹̳ÎÀÇ Àü°æ »ö±òÀ» ¹«È¿È­ ÇÒ ¼ö ÀÖ´Â °¡Àå °¡´É¼ºÀÌ ÀÖ´Â °÷ÀÔ´Ï´Ù. ÇÁ·ÒÇÁÆ®¿¡ ÆĶõ»ö ÅؽºÆ®¸¦ Æ÷ÇÔÇϱâ À§ÇØ : PS1="\[\033[34m\][\$(date %H%M)][\u@\h:\w]$ " ÀÌ ÇÁ·ÒÇÁÆ®ÀÇ ¹®Á¦Á¡Àº, 34¹ø »ö ÄÚµå·Î ½ÃÀÛÇÏ´Â ÆĶõ»ö±òÀÌ Åë»óÀûÀΠȸ»öÀ¸·Î µÇµ¹¾Æ °¡Áö ¾Ê¾Æ¼­, ÇÁ·ÒÇÁÆ® µÚ¿¡ ½á ³Ö´Â ¾î¶² Á¾·ùÀÇ ÅؽºÆ®¶óµµ ÇÁ·ÒÇÁÆ®¿Í °°Àº »öÀ» °¡Áö°Ô µÈ´Ù´Â °ÍÀÔ´Ï´Ù. ÀÌ°ÍÀº ¾îµÎ¿î ÆĶõ»öÀ̶ó¼­, °­Á¶ Äڵ尡 ¾à°£Àº µµ¿òÀÌ µÉ ¼ö ÀÖÀ¾´Ï´Ù. PS1="\[\033[1;34m\][\$(date %H%M)][\u@\h:\w]$\[\033[0;37m\] " ÀÌÁ¦´Â ¹àÀº ÆĶõ»öÀ¸·Î µÇ¸ç, ´ëºÎºÐÀÇ »ç¶÷µéÀÌ ¹Ù¶ó´Â ȸ»öÀ¸·Î µÇµ¹¾Æ °¡¼­ ³¡ ³ª°Ô µË´Ï´Ù. ÁÖÀÇ : ´ÙÀ½°ú °°Àº Á¡À» ÁöÀûÇØ µÎ°íÀÚ ÇÕ´Ï´Ù. ¸¸¾à, XÅÒÀ» »ç¿ëÇϸ鼭, Å͹̳ÎÀÇ »ö±ò¿¡ ´ëÇØ "xterm -bg midnightblue -fg yellow" °ú °°Àº½ÄÀ¸·Î ¼³Á¤ÇØ ³õÀ¸¼Ì´Ù¸é, À§¿¡¼­ ±â¼úÇÑ ¹Ù¿Í °°ÀÌ »ö±òÀ» µÇµ¹¸®´Â ÀÛ¾÷ÀÌ ¿©·¯ºÐµéÀÌ ¼³Á¤ÇÑ "-fg"À» ¹«È¿È­ ½ÃŲ´Ù´Â °ÍÀÔ´Ï´Ù. Àú´Â À̹®Á¦¸¦ ÇØ°áÇÏÁö ¸øÇßÀ¸¸ç, ¿©·¯ºÐµéÀÌ ÇعýÀ» ¹ß°ßÇÏ°Ô µÇ¸é Àú¿¡°Ô ÀÏ·¯ Áֽñ⠹ٶø´Ï´Ù. ¿©·¯ºÐµéÀÌ ¹àÀº »öÀÇ ¹è°æÀ» »ç¿ëÇÏ°í °è½Å´Ù¸é, À§¿¡¼­ »ç¿ëµÈ ȸ»ö ÅؽºÆ®´Â ÀбⰡ °ï¶õÇÒ °ÍÀÔ´Ï´Ù. ¶ÇÇÑ, XÅÒ¿¡¼­ ¹àÀº ¹è°æÀ» »ç¿ëÇϸ鼭, Äְܼú XÅÒ ¾çÂÊ¿¡¼­ ÇÁ·ÒÇÁÆ®¸¦ »ç¿ëÇϱ⸦ ¿øÇϽøé Á¦¸ñ Ç¥½ÃÁÙ Àý¿¡ ¼­ º¸ÀÎ ¹Ù¿Í °°ÀÌ "case $TERM in ..." ·Î½á »ö ¼³Á¤¿¡ ´ëÇؼ­ ¾à°£ÀÇ Á¶Á¤À» ÇÒ ÇÊ¿ä°¡ ÀÖÀ¾´Ï´Ù. ¾Æ·¡¿¡ »ö»óÇ¥°¡ ÁÖ¾îÁý´Ï´Ù: <verb> Black 0;30 Dark Gray 1;30 Blue 0;34 Light Blue 1;34 Green 0;32 Light Green 1;32 Cyan 0;36 Light Cyan 1;36 Red 0;31 Light Red 1;31 Purple 0;35 Light Purple 1;35 Brown 0;33 Yellow 1;33 Light Gray 0;37 White 1;37 </verb> ¹è°æ»öµµ ¶ÇÇÑ ¼³Á¤ÇÒ ¼ö Àִµ¥, ÆĶõ ¹è°æ¿¡ ´ëÇؼ­´Â 44, »¡°£»ö ¹è°æ¿¡ ´ëÇؼ­´Â 41, µîÀ» »ç¿ëÇÒ ¼ö°¡ ÀÖÀ¾´Ï´Ù. ¹è°æ»ö¿¡ ´ëÇؼ­´Â °­Á¶ »öÀº ¾øÀ¾´Ï´Ù. ÆĶõ»ö ¹è°æ¿¡ ¹àÀº »¡°£»ö ÅؽºÆ®¿Í °°ÀÌ Á¶ÇÕÀ» Çؼ­µµ »ç¿ëÇÒ ¼öÀÖÀ¾´Ï´Ù: \[\033[44;1;31m\], ±×·¸Áö¸¸, µû·Î µû·Î »ö±òÀ» ¼³Á¤ÇÏ´Â °ÍÀÌ ´õ Àß ÀÛµ¿ÇÏ´Â °Í °°À¾´Ï´Ù(Áï, \[\033[44m\]\[\033[1;31m\]). ´Ù¸¥ ÄÚµåµéµµ Æ÷ÇÔÇÏ¿© »ç¿ëÇÒ ¼ö Àִµ¥, 4:¹ØÁÙ, 5:±ô¹Ú°Å¸², 7:¹ÝÀü ±×¸®°í 8:¼û±è µîÀÌ ÀÖÀ¾´Ï´Ù. ÇÁ·ÒÇÁÆ® ÆÐÅ°Áö(Á¦°¡ ¼öÁ¤À» ÇÏ¿©, ¿ø¹®À» º¸±âÀ§ÇØ ¿ä±¸µÇ´Â Ưº°ÇÑ XÅÒ ÆùÆ®µé À» »ç¿ëÇϱ⠺¸´Ù´Â Ç¥ÁØÀûÀÎ Äֿܼ¡¼­ ´õ Àß ÀÛµ¿Çϵµ·Ï ¸¸µé¾úÀ¾´Ï´Ù)¿¡ ÀÖ´Â "elite2"¶ó°í À̸§ ºÙÀÎ ÇÁ·ÒÇÁÆ®¿¡ ±Ù°ÅÇÏ¿©, ¾Æ·¡ÀÇ ÇÁ·ÒÇÁÆ®´Â Á¦°¡ ¾ÆÁÖ ¸¹ÀÌ »ç¿ëÇÏ´Â °ÍÀÔ´Ï´Ù. <verb> function elite { local GRAY="\[\033[1;30m\]" local LIGHT_GRAY="\[\033[0;37m\]" local CYAN="\[\033[0;36m\]" local LIGHT_CYAN="\[\033[1;36m\]" case $TERM in xterm*) local TITLEBAR='\[\033]0;\u@\h:\w\007\]' ;; *) local TITLEBAR="" ;; esac local GRAD1=$(tty|cut -d/ -f3) PS1="$TITLEBAR\ $GRAY-$CYAN-$LIGHT_CYAN(\ $CYAN\u$GRAY@$CYAN\h\ $LIGHT_CYAN)$CYAN-$LIGHT_CYAN(\ $CYAN\#$GRAY/$CYAN$GRAD1\ $LIGHT_CYAN)$CYAN-$LIGHT_CYAN(\ $CYAN\$(date %H%M)$GRAY/$CYAN\$(date %d-%b-%y)\ $LIGHT_CYAN)$CYAN-$GRAY-\ $LIGHT_GRAY\n\ $GRAY-$CYAN-$LIGHT_CYAN(\ $CYAN\$$GRAY:$CYAN\w\ $LIGHT_CYAN)$CYAN-$GRAY-$LIGHT_GRAY " PS2="$LIGHT_CYAN-$CYAN-$GRAY-$LIGHT_GRAY " } </verb> »ö±òµéÀ» Àб⠽¬¿î À̸§À¸·Î Àӽà ½© º¯¼ö·Î Á¤ÀÇ ÇÏ¿´À¾´Ï´Ù. ÀÌ·¸°Ô Çϸé, ÀÛ¾÷ Çϱ⿡ Æí¸®ÇÕ´Ï´Ù. "GRAD1"º¯¼ö°¡ »ç¿ëµÇ¾î, »ç¿ëÇÏ´Â Å͹̳ÎÀÇ Á¾·ù¸¦ °áÁ¤ÇÕ´Ï´Ù. XÅÒ¿¡¼­ ÀÛ¾÷À» ÇÏ´ÂÁö °áÁ¤Çϱâ À§ÇØ Å×½ºÆ®ÇÑ °Í°ú ¸¶Âù°¡Áö·Î, ´ÜÁö Çѹø¸¸ ½ÇÇàµÉ ÇÊ¿ä°¡ ÀÖÀ¾´Ï´Ù. »ö±òÀ» Á¦¿ÜÇϸé, ¾Æ·¡¿Í °°Àº ÇÁ·ÒÇÁÆ®¸¦ º¸½Ã°Ô µË´Ï´Ù. <verb> --(giles@nikola)-(75/ttyp7)-(1908/12-Oct-98)-- --($:~/tmp)-- </verb> </sect> <sect> ¹è½¬ ÇÁ·ÒÇÁÆ® ÆÐÅ°Áö <p> <sect1> ÀÔ¼ö °¡´ÉÇÑ °÷ <p> ¹è½¬ ÇÁ·ÒÇÁÆ® ÆÐÅ°Áö´Â <url url="http://bash.current.nu"> ¿¡¼­ ±¸ÇÒ ¼öÀÖÀ¸¸ç, ÀÌ ÀÛ¾÷Àº Rob Current(aka BadLandZ) ¾¾ÀÇ Á¶Á¤ÇÏ¿¡ ¸î¸î »ç¶÷µéÀÌ Âü¿©ÇÏ¿© ÀÌ·ç ¾îÁø °ÍÀÔ´Ï´Ù. ÀÌ ÆÐÅ°Áö´Â ¿¹Àü ºÎÅÍ º£Å¸ ¹öÀüÀÌÁö¸¸, ´ÙÁß ÇÁ·ÒÇÁÆ®(theme)¸¦ »ç¿ëÇÒ ¼ö ÀÖµµ·Ï ÇÏ´Â ¾ÆÁÖ °£´ÜÇÑ ¹æ¹ýÀ» Á¦°øÇÏ¿©, ·Î±×ÀÎ ½©°ú ÇϺν©¿¡¼­ ÇÁ·ÒÇÁÆ®¸¦ ¼³Á¤ÇÒ ¼ö ÀÖ°Ô ÇÕ´Ï´Ù(Áï, PS1 ¹®ÀÚ¿­À» '~/.bash_profile'°ú '~/.bashrc' ÆÄÀÏ¿¡ ÀúÀå ÇÔÀ¸·Î½á). ´ëºÎºÐÀÇ Å׸¶(theme)µéÀº È®Àå VGA ¹®ÀÚ ¼¼Æ®µéÀ» »ç¿ëÇϱ⠶§¹®¿¡, VGA ÆùÆ®(´ëºÎºÐÀÇ ½Ã½ºÅÛ¿¡¼­ µðÆúÆ®°¡ ¾Æ´Ô)¿¡ Àͼ÷ÇÏÁö ¾ÊÀ¸½Å ºÐµé¿¡°Ô´Â ÁÁÁö ¾Ê°Ô º¸ÀÔ´Ï´Ù. <sect1> XÅÒ ÆùÆ® ¹Ù²Ù±â <p> ¹è½¬ ÇÁ·ÒÇÁÆ® ÆÐÅ°Áö¿¡ ÀÖ´Â °¡Àå ¸Å·ÂÀûÀÎ ÇÁ·ÒÇÁÆ® ¸î°³¸¦ »ç¿ëÈ÷±â À§Çؼ­´Â, ÇÁ·ÒÇÁÆ®¿¡ ¾²ÀÏ ¹®ÀÚ¼¼Æ®µéÀ» Áö¿øÇÏ´Â ÆùÆ®¸¦ ±¸Çؼ­ ¼³Ä¡ÇÒ ÇÊ¿ä°¡ ÀÖÀ¾´Ï´Ù. À̰͵éÀº "VGA ÆùÆ®"¶ó°í ÇÏÁö¸¸, ¸®´ª½º¿¡ ÀϹÝÀûÀ¸·Î ÀûÀçµÇ´Â ÆùÆ®µé-È®½ÇÈ÷ ´Ù¸¥ ¹®ÀÚ ¼¼Æ®¸¦ Áö¿øÇϱâ´Â ÇÏÁö¸¸-°úÀÇ Â÷ÀÌ°¡ ¸íÈ®ÇÏÁö´Â ¾Ê´Ù°í º¾´Ï´Ù. Ç¥ÁØ XÅÒ ÆùÆ®µéÀº, ¸¹Àº Á¾·ùÀÇ °­Á¶ ¹®ÀÚµéÀ» Æ÷ÇÔÇؼ­, È®Àå ¾ËÆĺ£Æ®¸¦ Áö¿øÇÕ´Ï´Ù. VGA ÆùÆ®¿¡¼­´Â, ÀÌ·¯ÇÑ °ÍµéÀº ±×·¡ÇÈ ¹®ÀÚµé-ºí·Ï, Á¡, ¼±µé-·Î ´ëÄ¡µË´Ï´Ù. ÀÌ°ÍÀ» ´õ ÀÚ¼¼È÷ ¼³¸íÇÒ ¼ö ÀÖ´Â ºÐÀÌ °è½Ã´Ù¸é, e-¸ÞÀÏÀ» º¸³» Áֽñ⠹ٶó¸ç, ¿©±â¿¡ Æ÷ÇÔ ½ÃÅ°µµ·Ï ÇÏ°ÚÀ¾´Ï´Ù. À̵é ÆùÆ®¸¦ ±¸Çؼ­ ¼³Ä¡ÇÏ´Â °ÍÀº ¾à°£ º¹ÀâÇÑ °úÁ¤À» °ÅĨ´Ï´Ù. ¿ì¼±, ±× ÆùÆ®(µé) À» º¹±¸ÇÕ´Ï´Ù. ´ÙÀ½À¸·Î, ±×°ÍµéÀÌ .pcf ¶Ç´Â .pcf.gz Çü½ÄÀÇ ÆÄÀÏÀÎÁö È®ÀÎÇÕ´Ï´Ù. ¸¸¾à, ±×°ÍµéÀÌ .bdf ÆÄÀÏÀ̸é, "bdftopcf"¸í·ÉÀ» Á¶»çÇÕ´Ï´Ù(Áï, ¸Ç ÆäÀÌÁö¸¦ ÀÐ¾î º¾´Ï´Ù). ±×¸®°í .pcf ¶Ç´Â .pcf.gz ÆÄÀϵéÀ» '/usr/X11R6/lib/X11/fonts/misc' (RedHat5.1 °ú Slackware3.4 ÀÇ °æ¿ì¿¡´Â ÀÌ µð·¢Å丮°¡ ¿Ã¹Ù¸¥ µð·¢Å丮ÀÌÁö¸¸, ±× ¹ÛÀÇ ¹èÆ÷º»¿¡¼­´Â ´Ù¸¥ µð·¢Å丮°¡ µÉ ¼öµµ ÀÖÀ¾´Ï´Ù) µð·¢Å丮¿¡ ¿Å±â¼¼¿ä. "cd" ¸í·ÉÀ¸·Î ±× µð·¢Å丮·Î ¹Ù²Û ´ÙÀ½¿¡, "mkfontdir" ¸í·ÉÀ» ½ÇÇà ½Ãŵ´Ï´Ù. ±× ´ÙÀ½¿¡ "xset fp rehash" ¸¦ ½ÇÇàÇÕ´Ï´Ù. ¶§¶§·Î, °°Àº µð·¢Å丮¿¡ ÀÖ´Â 'fonts.alias' ÆÄÀÏ À» ÆíÁýÇؼ­, ±× ÆùÆ®¿¡ ÇØ´çÇÏ´Â ´õ ªÀº ¾Ë¸®¾Æ½º À̸§À» ¸¸µå´Â °Íµµ ÈǸ¢ÇÑ ¾ÆÀ̵ð¾îÀÔ´Ï´Ù. »õ·Î¿î ÆùÆ®µéÀ» »ç¿ëÇϱâ À§Çؼ­´Â, ¿©·¯ºÐÀÇ XÅÒ¿¡ ¸Â´Â Àû´çÇÑ ¸í·É¾î·Î½á ¼±ÅÃµÈ ¿É¼ÇµéÀ» Æ÷ÇÔÇؼ­ XÅÒ ÇÁ·Î±×·¥À» ½ÃÀÛÇÏ¸é µÇ´Âµ¥, ÀÌ·¯ÇÑ ÀÛ¾÷¿¡ ´ëÇؼ­´Â ¸Ç ÆäÀÌÁö³ª ¶Ç´Â ¸í·É¾î ÁÙ¿¡¼­ "--help"¸¦ »ç¿ëÇؼ­ ¾Ë¾Æ ³¾ ¼ö ÀÖÀ¾´Ï´Ù. ¾Æ·¡ÀÇ ¿¹´Â ´ëÁßÀûÀ¸·Î ¸¹ÀÌ ¾²ÀÌ´Â ¿ë¾î ÀÔ´Ï´Ù: <verb> xterm -font <fontname> </verb> ¶Ç´Â <verb> xrerm -fn <fontname> -fb <fontname-bold> Eterm -f <fontname> rxvt -fn <fontname> </verb> VGA ÆùÆ®µéÀº <url url="http://hoome.earthlink.net/~us5zahns/enl/ansifont.htm"> ÀÇ 'Stumpy's ANSI Fonts' ÆäÀÌÁö¿¡¼­ ±¸ÇÒ ¼ö ÀÖÀ¾´Ï´Ù(Á¦°¡ ÀÌ ±ÛÀ» ¾²¸é¼­ ¸¹Àº ºÎºÐÀ» ÂüÁ¶ÇÑ ÆäÀÌÁöÀÓ). </sect> <sect> ´Ù¸¥ ÇÁ·ÒÇÁÆ® ºÒ·¯ µéÀ̱â <p> <sect1> Á¶±Ý ÈÄ¿¡, ´Ù¸¥ ÇÁ·ÒÇÁÆ® ºÒ·¯ µéÀ̱â <p> ÀÌ HOWTO ¹®¼­¿¡¼­, PS1 ȯ°æ º¯¼öµéÀ» ¾î¶»°Ô ¸¸µé¸ç, ¶Ç À̵é PS1°ú PS2 ¹®ÀÚ¿­µéÀ» ¾î¶»°Ô ÇÔ¼ö¿¡ ÇÕº´ÇØ ³Ö¾î¼­, '~/.bashrc' ³ª ÇÁ·ÒÇÁÆ® ÆäÅ°ÁöÀÇ Å׸¶·Î½á ½ÇÇàµÉ ¼ö ÀÖ´Â Áö¿¡ ´ëÇÏ¿© ¼³¸íÇÏ¿´À¾´Ï´Ù. ¹è½¬ ÇÁ·ÒÇÁÆ® ÆäÅ°Áö¸¦ »ç¿ëÇÒ °æ¿ì¿¡, 'bashprompt -i'¶ó°í ÀÔ·ÂÇÏ¿© »ç¿ë °¡´ÉÇÑ Å׸¶µéÀÇ ¸ñ·ÏÀ» º¼ ¼ö ÀÖÀ¾´Ï´Ù. ¾ÕÀ¸·ÎÀÇ ·Î±×ÀÎ ½©(¿©·¯ºÐµéÀÇ XÅÒ ¼³Á¤¿¡ µû¶ó ´Ù¸£±â´Â ÇÏÁö¸¸, ÁÖ·Î ÄܼÖ, »Ó¸¸ ¾Æ´Ï¶ó, ÅÚ³ÝÀ̳ª XÅÒ)¿¡¼­ ÇÁ·ÒÇÁÆ®¸¦ ¼³Á¤Çϱâ À§Çؼ­´Â, 'bashprompt -l themename'À» ÀÔ·ÂÇÏ¸é µË´Ï´Ù. ±×·¯¸é, ¿äûµÈ Å׸¶°¡ ½ÃÀÛµÉ ¶§, ±×°ÍÀ» ºÎ¸¦ ¼ö ÀÖµµ·Ï, ¹è½¬ÇÁ·ÒÇÁÆ®´Â '~/.bash_profile'À» ¼öÁ¤ÇÏ°Ô µË´Ï´Ù. ¾ÕÀ¸·ÎÀÇ ÇϺΠ½©(´ë°³, XÅÒ, rxvt, µî)¿¡¼­ÀÇ ÇÁ·ÒÇÁÆ®¸¦ ¼³Á¤ÇϱâÀ§Çؼ­´Â, 'bashprompt -s themename'À» ÀÔ·ÂÇÏ¸é µÇ¸ç, ¹è½¬ÇÁ·ÒÇÁÆ®´Â '~/.bash' ÆÄÀÏÀ» ¼öÁ¤ÇÏ¿©, ±âµ¿ÇÒ ¶§, ÀûÀýÇÑ Å׸¶¸¦ ºÎ¸¦ ¼ö ÀÖµµ·Ï ÇÕ´Ï´Ù. <sect1> Áö±Ý Áï½Ã, ´Ù¸¥ ÇÁ·ÒÇÁÆ® ºÒ·¯ µéÀ̱â <p> ÇöÀçÀÇ Å͹̳ο¡¼­(À§¿¡¼­ Á¦½ÃµÈ ¿¹ÀÎ 'elite'ÇÔ¼ö¸¦ »ç¿ëÇؼ­) ÇÁ·ÒÇÁÆ®¸¦ ¹Ù²Ü ¼ö Àִµ¥, 'source elite'¶ó°í Ä£ ´ÙÀ½¿¡ 'elite'('elite'ÇÔ¼ö ÆÄÀÏÀÌ ÀÛ¾÷ µð·¢Å丮¿¡ ÀÖ´Ù°í °¡Á¤)¸¦ ÀÔ·ÂÇÏ¸é µË´Ï´Ù. ÀÌ·¸°Ô ÇÏ´Â °ÍÀº ¾à°£ ¼º°¡½Å ÀÛ¾÷À̸ç, ¿©·¯ºÐÀÇ È¯°æ °ø°£¿¡ ¿©ºÐÀÇ ÇÔ¼ö(elite)¸¦ ³²°Ü ³õ´Â °ÍÀÌ µË´Ï´Ù-ȯ°æ¿¡¼­ ±×°ÍÀ» ±ú²ýÀÌ Áö¿ì°í ½ÍÀ¸½Ã¸é, ¿ª½Ã, 'unset elite'¶ó°í ÀÔ·ÂÇÏ½Ã¸é µË´Ï´Ù. ÀÌ·¸°Ô ÇÏ´Â °ÍÀÌ Á¶±×¸¸ ½© ½ºÅ©¸³Æ®¿¡ ´ëÇؼ­´Â ÀÌ»óÀûÀÎ ¹æ¹ý °°ÀÌ º¸ÀÌÁö¸¸, ¿©±â¿¡¼­´Â ½ºÅ©¸³Æ®´Â ÀÛµ¿ÇÏÁö ¾ÊÀ¾´Ï´Ù. ¿Ö³ÄÇϸé, ½ºÅ©¸³Æ®·Î´Â ÇöÀç ½©ÀÇ È¯°æÀ» º¯°æÇÒ ¼ö ¾ø±â ¶§¹®ÀÔ´Ï´Ù:½ºÅ©¸³Æ®´Â ÇϺΠ½©ÀÇ È¯°æ¸¸ ¹Ù²Ü ¼ö ÀÖÀ¾´Ï´Ù. ½ºÅ©¸³Æ®°¡ Á¤ÁöÇÏ´Â ¼ø°£¿¡, ÇϺΠ½©Àº »ç¶óÁö°Ô µÇ°í, ±× ½ºÅ©¸³Æ®¿¡ ÀÇÇؼ­ º¯°æ µÈ ÇϺΠ½©ÀÇ È¯°æµµ »ç¶óÁö°Ô µË´Ï´Ù. ÇöÀç ½©ÀÇ È¯°æ º¯¼öµéÀ» ¹Ù²Ü ¼ö ÀÖ´Â °ÍÀº ȯ°æ ÇÔ¼öµé »ÓÀÔ´Ï´Ù. ¹è½¬ÇÁ·ÒÇÁÆ® ÆÐÅ°Áö¿¡ ÀÇÇؼ­, "callbashprompt"¶ó°í ºÒ¸®´Â ÇÔ¼ö°¡ ȯ°æ¿¡ Ãß°¡µÇ¸ç, ±×¸®°í, while they don't document it, ¹è½¬ ÁøÇà Áß¿¡, ±× ÇÔ¼ö°¡ ºÒ¸®¾îÁ®, ¾î¶² ¹è½¬ ÇÁ·ÒÇÁÆ®¶óµµ ÀûÀç ÇÒ ¼ö ÀÖÀ¾´Ï´Ù. ±× ÇÔ¼ö´Â Å׸¶°¡ ¼³Ä¡µÈ µð·¢Å丮(¿©·¯ºÐÀÌ ºÎ¸¦·Á°í ÇÏ´Â Å׸¶´Â ¿©±â¿¡ ÀÖ¾î¾ß ÇÕ´Ï´Ù)¸¦ »ìÆì º¸°í, ¿äûµÈ ÇÔ¼ö¸¦ ¼Ò½ºÈ­ Çؼ­, ±× ÇÔ¼ö¸¦ ÀûÀçÇÏ°í, ±×¸®°í³ª¼­ ±×ÇÔ¼ö¸¦ ³»¸®°Ô µÇ¾î, ȯ°æÀ» Á¤µ·µÈ »óÅ·ΠÀ¯ÁöÇÕ´Ï´Ù. "callbashprompt"´Â ÀÌ·¸°Ô »ç¿ëµÇ±â·Î ÀǵµµÈ °Íµµ ¾Æ´Ï¸ç, ¿À·ù °Ë»çµµ ¾øÁö¸¸, ÀÌ Á¡¸¸ ¸í½ÉÇÑ´Ù¸é, Àß ÀÛµ¿ÇÕ´Ï´Ù. </sect> <sect> ÇÁ·ÒÇÁÆ® »öÀ» µ¿ÀûÀ¸·Î ºÒ·¯ µéÀ̱â <p> <sect1> ¿¹ "Proof of Concept" <p> ¾Æ·¡ÀÇ ¿¹´Â Èï¹Ì·Î¿î ÇÁ·ÒÇÁÆ®¶ó±â º¸´Ù´Â "proof of concept" ÀÔ´Ï´Ù:µ¿ÀûÀ¸·Î ÇÁ·ÒÇÁÆ® ¾ÈÀÇ »ö±òÀ» ¹Ù²Ù´Â °ÍÀÔ´Ï´Ù. ÀÌ ¿¹¿¡¼­´Â, ½Ã½ºÅÛÀÇ ºÎÇÏ¿¡ µû¶ó¼­, È£½ºÆ® À̸§ÀÇ »ö±òÀ» ¹Ù²Ù°Ô µË´Ï´Ù(°æ°í ·Î¼­). <verb> #!/bin/bash # "hostloadcolour" - 17 October 98, by Giles # # The idea here is to change the colour of the host name in the prompt, # depending on a threshold load value. # THRESHOLD_LOAD is the value of the one minute load (multiplied # by one hundred) at which you want # the prompt to change from COLOUR_LOW to COLOUR_HIGH THRESHOLD_LOAD=200 COLOUR_LOW='1;34' # light blue COLOUR_HIGH='1;31' # light red function prompt_command { ONE=$(uptime | sed -e "s/.*load average: \(.*\...\), \(.*\...\), \(.*\...\)/\1/" -e "s/ //g") # Apparently, "scale" in bc doesn't apply to multiplication, but does # apply to division. ONEHUNDRED=$(echo -e "scale=0 \n $ONE/0.01 \nquit \n" | bc) if [ $ONEHUNDRED -gt $THRESHOLD_LOAD ] then HOST_COLOUR=$COLOUR_HIGH # Light Red else HOST_COLOUR=$COLOUR_LOW # Light Blue fi } function hostloadcolour { PROMPT_COMMAND=prompt_command PS1="[$(date +%H%M)][\u@\[\033[\$(echo -n \$HOST_COLOUR)m\]\h\[\033[0;37m\]:\w]$ " } </verb> ¿©·¯ºÐÀÌ ¼±È£ÇϽô ÆíÁý±â¸¦ ÀÌ¿ëÇؼ­, ÀÌ ÆÄÀÏÀ» "hostloadcolour"¶ó´Â À̸§À¸·Î ÀúÀåÇϽʽÿÀ. ¸¸¾à, ¹è½¬ÇÁ·ÒÇÁÆ® ÆÐÅ°Áö¸¦ ÀÌ¹Ì ¼³Ä¡Çϼ̴ٸé, ÀÌ ÆÄÀÏÀº Å׸¶ÀÇ Çϳª·Î¼­ ÀÛµ¿ÇÒ °ÍÀÔ´Ï´Ù. ¹è½¬ÇÁ·ÒÇÁÆ®¸¦ ¼³Ä¡ÇÏÁö ¾Ê¾Ò´Ù¸é, 'source hostloadcolour'¶ó°í Ä¡°í³ª¼­, 'hostloadcolour'¸¦ ÀÔ·ÂÇϽʽÿÀ. ¾î´À ÂÊÀ̵çÁö, "prompt_command"´Â ¿©·¯ºÐµéÀÇ È¯°æ¿¡¼­ ÇÔ¼öµé Áß Çϳª°¡ µË´Ï´Ù. À§ Äڵ带 Àß »ìÆì º¸½Ã¸é, »ö±òµé($COLOUR_HIGH ¿Í $COLOUR_LOW)ÀÌ ºÎºÐÀûÀÎ »ö»ó ÄÚµå(Áï, "\[\033[1;34m\]" ´ë½Å¿¡ "1;34")·Î ¸¸ ¼³Á¤µÇ¾î ÀÖ´Ù´Â °ÍÀ» ¾Æ½Ã°Ô µÉ °ÍÀÔ´Ï´Ù. ÀÌ ¹æ¹ýÀ» Àú´Â ´õ ¼±È£ÇÕ´Ï´Ù. Àú´Â ¿Ï¼ºµÈ ÄÚµå·Î ÀÛµ¿ÇÏ°Ô ÇÒ ¼ö°¡ ¾ø¾ú´Âµ¥, ÀÌ ¹®Á¦¸¦ ´Ù·ê ¼ö ÀÖÀ¸¸é Àú¿¡°Ô ÀÏ·¯ ÁֽʽÿÀ. </sect> <sect> ¿¹Á¦ ÇÁ·ÒÇÁÆ®µé <p> <sect1> "Lightweight" ÇÁ·ÒÇÁÆ® <p> <verb> function proml { local BLUE="\[\033[0;34m\]" local RED="\[\033[0;31m\]" local LIGHT_RED="\[\033[1;31m\]" local WHITE="\[\033[1;37m\]" local LIGHT_GRAY="\[\033[0;37m\]" case $TERM in xterm*) TITLEBAR='\[\033]0;\u@\h:\w\007\]' ;; *) TITLEBAR="" ;; esac PS1="${TITLEBAR}\ $BLUE[$RED\$(date +%H%M)$BLUE]\ $BLUE[$LIGHT_RED\u@\h:\w$BLUE]\ $WHITE\$$LIGHT_GRAY " PS2='> ' PS4='+ ' } </verb> <sect1> ¹è½¬ÇÁ·ÒÇÁÆ® Å׸¶¿¡¼­ÀÇ 'elite' <p> ÀÌ ÇÁ·ÒÇÁÆ®´Â VGA ÆùÆ®°¡ ÇÊ¿äÇÏ´Ù´Â Á¡¿¡ À¯ÀÇ ÇϽʽÿÀ. <verb> # Created by KrON from windowmaker on IRC # Changed by Spidey 08/06 function elite { PS1="\[\033[31m\]\332\304\[\033[34m\](\[\033[31m\]\u\[\033[34m\]@\[\033[31m\]\h\ \[\033[34m\])\[\033[31m\]-\[\033[34m\](\[\033[31m\]\$(date +%I:%M%P)\ \[\033[34m\]-:-\[\033[31m\]\$(date +%m)\[\033[34m\033[31m\]/\$(date +%d)\ \[\033[34m\])\[\033[31m\]\304-\[\033[34m]\\371\[\033[31m\]-\371\371\ \[\033[34m\]\372\n\[\033[31m\]\300\304\[\033[34m\](\[\033[31m\]\W\[\033[34m\])\ \[\033[31m\]\304\371\[\033[34m\]\372\[\033[00m\]" PS2="> " } </verb> <sect1> "Power User" ÇÁ·ÒÇÁÆ® <p> Àú´Â ½ÇÁ¦·Î ÀÌ ÇÁ·ÒÇÁÆ®¸¦ »ç¿ëÇÏ°í ÀÖÁö¸¸, PII 400, single-user ½Ã½ºÅÛ¿¡¼­ ÇÁ·ÒÇÁÆ®°¡ ³ªÅ¸³ª´Â µ¥´Â °¨ÁöÇÒ ¼öÀÖÀ» Á¤µµÀÇ Áö¿¬ÀÌ ³ªÅ¸³ª¹Ç·Î, PII 100 ¶Ç´Â ´Ù¸¥ muti-user ½Ã½ºÅÛ¿¡´Â »ç¿ëÇϱ⸦ ±ÇÀåÇÏÁö ¾ÊÀ¾´Ï´Ù. ½ÇÁ¦ÀûÀÎ ÇÁ·ÒÇÁÆ®·Î ¾²±â À§Çؼ­ º¸´Ù´Â, ¾ÆÀ̵ð¾î¸¦ ¾ò±â À§ÇØ Àß »ìÆì º¸½Ã±â ¹Ù¶ø´Ï´Ù. <verb> #!/bin/bash #---------------------------------------------------------------------- # POWER USER PROMPT "pprom2" #---------------------------------------------------------------------- # # Created August 98, Last Modified 9 November 98 by Giles # # Problem: when load is going down, it says "1.35down-.08", get rid # of the negative # - limit the length of the $PWD to 30 chars - right-truncate if # it exceeds that function prompt_command { # Create TotalMeg variable: sum of visible file sizes in current directory local TotalBytes=0 for Bytes in $(ls -l | grep "^-" | cut -c30-41) do let TotalBytes=$TotalBytes+$Bytes done TotalMeg=$(echo -e "scale=3 \nx=$TotalBytes/1048576\n if (x<1) {print \"0\"} \n print x \nquit" | bc) # This is used to calculate the differential in load values # provided by the "uptime" command. "uptime" gives load # averages at 1, 5, and 15 minute marks. # local one=$(uptime | sed -e "s/.*load average: \(.*\...\), \(.*\...\), \(.*\...\)/\1/" -e "s/ //g") local five=$(uptime | sed -e "s/.*load average: \(.*\...\), \(.*\...\), \(.*\...\).*/\2/" -e "s/ //g") local diff1_5=$(echo -e "scale = scale ($one) \nx=$one - $five\n if (x>0) {print \"up\"} else {print \"down\"}\n print x \nquit \n" | bc) loaddiff="$(echo -n "${one}${diff1_5}")" # Count visible files: let files=$(ls -l | grep "^-" | wc -l | tr -d " ") let hiddenfiles=$(ls -l -d .* | grep "^-" | wc -l | tr -d " ") let executables=$(ls -l | grep ^-..x | wc -l | tr -d " ") let directories=$(ls -l | grep "^d" | wc -l | tr -d " ") let hiddendirectories=$(ls -l -d .* | grep "^d" | wc -l | tr -d " ")-2 let linktemp=$(ls -l | grep "^l" | wc -l | tr -d " ") if [ "$linktemp" -eq "0" ] then links="" else links=" ${linktemp}l" fi unset linktemp let devicetemp=$(ls -l | grep "^[bc]" | wc -l | tr -d " ") if [ "$devicetemp" -eq "0" ] then devices="" else devices=" ${devicetemp}bc" fi unset devicetemp } PROMPT_COMMAND=prompt_command function pprom2 { local BLUE="\[\033[0;34m\]" local LIGHT_GRAY="\[\033[0;37m\]" local LIGHT_GREEN="\[\033[1;32m\]" local LIGHT_BLUE="\[\033[1;34m\]" local LIGHT_CYAN="\[\033[1;36m\]" local YELLOW="\[\033[1;33m\]" local WHITE="\[\033[1;37m\]" local RED="\[\033[0;31m\]" case $TERM in xterm*) TITLEBAR='\[\033]0;\u@\h:\w\007\]' ;; *) TITLEBAR="" ;; esac PS1="$TITLEBAR\ $BLUE[$RED\$(date +%H%M)$BLUE]\ $BLUE[$RED\u@\h$BLUE]\ $BLUE[\ $LIGHT_GRAY\${files}.\${hiddenfiles}-\ $LIGHT_GREEN\${executables}x \ $LIGHT_GRAY(\${TotalMeg}Mb) \ $LIGHT_BLUE\${directories}.\ \${hiddendirectories}d\ $LIGHT_CYAN\${links}\ $YELLOW\${devices}\ $BLUE]\ $BLUE[${WHITE}\${loaddiff}$BLUE]\ $BLUE[\ $WHITE\$(ps ax | wc -l | sed -e \"s: ::g\")proc\ $BLUE]\ \n\ $BLUE[$RED\$PWD$BLUE]\ $WHITE\$\ \ $LIGHT_GRAY " PS2='> ' PS4='+ ' } </verb> <sect1> Å͹̳ÎÀÇ Æø ÇÁ·ÒÇÁÆ® <p> ÇÑ Ä£±¸°¡ ºÒÆòÀ» Çߴµ¥, ÇÁ·ÒÇÁÆ® ¾È¿¡ $PWD ¸í·ÉÀÌ À־ °è¼Ó ±æÀÌ°¡ ¹Ù²î´Â ±×·± ÇÁ·ÒÇÁÆ®¸¦ ÁÁ¾Æ ÇÏÁö¾Ê´Â´Ù°í ÇßÀ¾´Ï´Ù. ±×·¡¼­, ¿©·¯ºÐµéÀÇ Å͹̳ÎÀÇ Æø¿¡ ²À ¸Âµµ·Ï ±æÀ̸¦ Á¶Á¤ÇÒ ¼ö ÀÖ´Â ÇÁ·ÒÇÁÆ®¸¦ ÀÛ¼º ÇÏ¿´À¾´Ï´Ù. <verb> #!/bin/bash # termwide prompt # by Giles - created 2 November 98 # last modified 9 November 98 # # The idea here is to have the upper line of this two line prompt # always be the width of your term. Do this by calculating the # width of the text elements, and putting in fill as appropriate # or right-truncating $PWD. # # - needs a lot of refinement, but it works # - host doesn't need to be figured out every time: that's a # constant # - what about username? could change? # - text vars generated by prompt_command can't be locals, # because they have to go to PS1. function prompt_command { TERMWIDTH=${COLUMNS} # Calculate the width of the prompt: hostnam=$(echo -n $HOSTNAME | sed -e "s/[\.].*//") let hostsize=$(echo -n $hostnam | wc -c | tr -d " ") # "whoami" and "pwd" include a trailing newline usernam=$(whoami) let usersize=$(echo -n $usernam | wc -c | tr -d " ") newPWD="${PWD}" let pwdsize=$(echo -n ${newPWD} | wc -c | tr -d " ") # Add all the accessories below ... let promptsize=$(echo -n "--(${usernam}@${hostnam})---(${PWD})--" \ | wc -c | tr -d " ") let fillsize=${TERMWIDTH}-${promptsize} fill="" while [ "$fillsize" -gt "0" ] do fill="${fill}-" let fillsize=${fillsize}-1 done if [ "$fillsize" -lt "0" ] then let cut=((${fillsize})*(-1))+3 sedvar="" while [ "$cut" -gt "0" ] do sedvar="${sedvar}." let cut=${cut}-1 done newPWD="...$(echo -n $PWD | sed -e "s/\(^${sedvar}\)\(.*\)/\2/")" fi } PROMPT_COMMAND=prompt_command function termwide { local GRAY="\[\033[1;30m\]" local LIGHT_GRAY="\[\033[0;37m\]" local WHITE="\[\033[1;37m\]" local LIGHT_BLUE="\[\033[1;34m\]" local YELLOW="\[\033[1;33m\]" case $TERM in xterm*) TITLEBAR='\[\033]0;\u@\h:\w\007\]' ;; *) TITLEBAR="" ;; esac PS1="$TITLEBAR\ $YELLOW-$LIGHT_BLUE-(\ $YELLOW\${usernam}$LIGHT_BLUE@$YELLOW\${hostnam}\ ${LIGHT_BLUE})-${YELLOW}-\${fill}${LIGHT_BLUE}-(\ $YELLOW\${newPWD}\ $LIGHT_BLUE)-$YELLOW-\ \n\ $YELLOW-$LIGHT_BLUE-(\ $YELLOW\$(date +%H%M)$LIGHT_BLUE:$YELLOW\$(date \"+%a,%d %b %y\")\ $LIGHT_BLUE:$WHITE\$$LIGHT_BLUE)-\ $YELLOW-\ $LIGHT_GRAY " PS2="$LIGHT_BLUE-$YELLOW-$YELLOW-$LIGHT_GRAY " } </verb> </sect> </article>