๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
๊ฐœ๋ฐœ ์„ค์ •

MacOS iTerm zsh - alias ์„ค์ •ํ•˜๊ธฐ

by ์ฃผ๋ฐœ2 2021. 7. 4.
๋ฐ˜์‘ํ˜•

๐Ÿ“Ž MacOS iTerm zsh - alias ์„ค์ •

์•ˆ๋…•ํ•˜์„ธ์š”! ์ด๋ฒˆ์—๋Š” MacOS์˜ zsh alias๋ฅผ ์„ค์ •ํ•˜๋Š” ๋ฐฉ๋ฒ•์— ๋Œ€ํ•ด ์•Œ์•„๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค!

 

์ €๋Š” ๋งฅ๋ถ์„ ์ตœ๊ทผ์— ๊ตฌ๋งคํ•˜๋ฉด์„œ ํ„ฐ๋ฏธ๋„์„ ๊ต‰์žฅํžˆ ๋งŽ์ด ์‚ฌ์šฉํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค.

ํ„ฐ๋ฏธ๋„์—์„œ ํŠน์ • ๋””๋ ‰ํ† ๋ฆฌ์— ๋ฐ˜๋ณต์ ์œผ๋กœ ์ด๋™์„ ํ•˜๋Š” ๊ฒฝ์šฐ๊ฐ€ ์กด์žฌํ•˜๋Š”๋ฐ์š”,

์ด๋•Œ๋งˆ๋‹ค ๋งค๋ฒˆ ํ„ฐ๋ฏธ๋„์—์„œ cd ๊ฒฝ๋กœ~ ๋ฅผ ์ž…๋ ฅํ•ด์„œ ์ ‘๊ทผํ•˜๋Š”๊ฒŒ ๊ฝค๋‚˜ ๋ฒˆ๊ฑฐ๋กœ์šด ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.. ๐Ÿ˜ญ

 

ํ•ด๋‹น ๋””๋ ‰ํ† ๋ฆฌ๋กœ ๊ฐ€์„œ ํ„ฐ๋ฏธ๋„์„ ๋ฐ”๋กœ ์‹คํ–‰ํ•  ์ˆ˜๋„ ์žˆ์ง€๋งŒ, ์ด๋ฒˆ์—๋Š” alias๋ฅผ ์„ค์ •ํ•ด์„œ ํ„ฐ๋ฏธ๋„์—์„œ ์˜ˆ์•ฝ์–ด๋ฅผ ํ†ตํ•ด

๋ฐ”๋กœ ํŠน์ • ๋””๋ ‰ํ† ๋ฆฌ์— ์ด๋™ํ•˜๋Š” ๋ฐฉ๋ฒ•์— ๋Œ€ํ•ด ์•Œ์•„๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค.

 

๋”ฐ๋ผ์„œ MacOS์—์„œ ์ž์ฃผ ์‚ฌ์šฉํ•˜๋Š” ๋ช…๋ น์–ด์˜ ๊ฒฝ์šฐ, alias ๋ช…๋ น์–ด๋กœ ์„ค์ •์„ ํ•ด๋‘๋ฉด ๋ฒˆ๊ฑฐ๋กœ์šด ์ž‘์—…์€ ๋ฐ˜๋ณตํ•˜์ง€ ์•Š์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

 

 

vi ~/.zshrc

zshrc ํŒŒ์ผ์— alias ์„ค์ •์„ ์œ„ํ•ด ์œ„ ๋ช…๋ น์–ด๋ฅผ ์ž…๋ ฅํ•ฉ๋‹ˆ๋‹ค.

 

 

 

aliases ์ถ”๊ฐ€

ํŒŒ์ผ์—์„œ ๊ฐ€์žฅ ์•„๋ž˜์ชฝ์œผ๋กœ ๋‚ด๋ ค๊ฐ€๋ณด๋ฉด # Example aliases ์œผ๋กœ ์ฃผ์„(#) ์ฒ˜๋ฆฌ๊ฐ€ ๋˜์–ด์žˆ๋Š” ๋ถ€๋ถ„์ด ์žˆ์Šต๋‹ˆ๋‹ค.

 

์œ„ ๋ถ€๋ถ„ ์•„๋ž˜์—์„œ ์›ํ•˜๋Š” ๋ช…๋ น์–ด๋ฅผ ์ž…๋ ฅํ•ฉ๋‹ˆ๋‹ค.

 

alias ๋‹จ์ถ•์–ด = "๋ช…๋ น์–ด"

alias study = "cd /Users/juhyun/Desktop/study/๊ฐœ์ธ๊ณต๋ถ€/study"

์ €์˜ ๊ฒฝ์šฐ study ๋ฅผ ์ž…๋ ฅํ–ˆ์„๋•Œ, /Users/juhyun/Desktop/study/๊ฐœ์ธ๊ณต๋ถ€/study ์ด ๊ฒฝ๋กœ๋กœ ๋””๋ ‰ํ† ๋ฆฌ๋ฅผ ์ด๋™ํ•˜๋„๋ก ์„ค์ •ํ–ˆ์Šต๋‹ˆ๋‹ค.

 

 

 

aliases ์ €์žฅ

source ~/.zshrc

์œ„์—์„œ ์„ค์ •ํ•œ alias๋ฅผ ์ ์šฉํ•˜๊ธฐ ์œ„ํ•ด ์œ„ ๋ช…๋ น์–ด๋ฅผ ํ„ฐ๋ฏธ๋„์—์„œ ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค.

 

 

 

 

๊ทธ ํ›„ ์œ„์—์„œ ์„ค์ •ํ–ˆ๋˜ alias ๋ฅผ ์ž…๋ ฅํ•˜๋ฉด ์ •์ƒ์ ์œผ๋กœ ๋ช…๋ น์–ด๊ฐ€ ์‹คํ–‰๋ฉ๋‹ˆ๋‹ค. ๐Ÿ˜ƒ

 

๋ฐ˜์‘ํ˜•

๋Œ“๊ธ€