🌈 colorls 둜 ls λͺ…령을 더 예쁘게 보기

DoonDoonΒ·2019λ…„ 4μ›” 28일
8
post-thumbnail

Photo by Will Porada on Unsplash

μ΄λ²ˆμ£ΌλŠ” 컴퓨터 곡학 기초λ₯Ό μ—΄μ‹¬νžˆ κ³΅λΆ€ν•˜λ‹€λ³΄λ‹ˆ
그런 λ‚΄μš©λ“€μ€ κΈ€λ‘œ μ •λ¦¬ν•˜κΈ°μ— λ„ˆλ¬΄ 어렀움이 μžˆμ–΄

λŒ€μΆ© μ΅œκ·Όμ— μ„€μΉ˜ν•œ Ruby gem 인 colorls λ₯Ό νŒ”μ•„λ¨Ήμ–΄ 보렀고 ν•©λ‹ˆλ‹€

colorls λž€ ls λͺ…λ Ήμ–΄λ₯Ό 쑰금 더 예쁘게 λ³΄μ—¬μ£ΌλŠ” 것
κ·Έ 이상도 μ΄ν•˜λ„ μ•„λ‹™λ‹ˆλ‹€. μ„€μΉ˜ν•˜λ©΄ μ•„λž˜μ²˜λŸΌ μ“Έ 수 μžˆμŠ΅λ‹ˆλ‹€

image.png

별 맀λ ₯을 λͺ»λŠλΌμ‹œλ©΄ λ’€λ‘œκ°€κΈ°λ₯Ό λˆ„λ₯΄μ‹œλ©΄ λ©λ‹ˆλ‹€... πŸ€”

근데 μ˜ˆμ˜λ‹€κ΅¬μš”? μ €λŸ°κ±° μ’‹μ•„ν•˜μ‹ λ‹€κ΅¬μš”?
그럼 μ“°κ³  μ‹ΆμœΌμ‹  뢄듀을 μœ„ν•΄
κ°„λ‹¨ν•˜κ²Œ μ•„λž˜ 과정을 μ„€λͺ…λ“œλ¦¬λ €κ³  ν•©λ‹ˆλ‹€!

  1. rbenv 둜 μ‹œμŠ€ν…œκ³Ό 격리된 Ruby ν™˜κ²½ λ§Œλ“€κΈ°
  2. colorls μ„€μΉ˜
  3. νŽΈλ¦¬ν•˜κ²Œ μ‚¬μš©ν•˜κΈ° μœ„ν•΄ λͺ‡ 가지 alias μ„€μ •

βœ‹ λ“€μ–΄κ°€κΈ° 전에


μ €λŠ” Ruby λΌλŠ” 언어에 λŒ€ν•΄ μ „ν˜€ λͺ¨λ¦…λ‹ˆλ‹€. μ½”λ“œ ν•œ 쀄 μž‘μ„±ν•΄λ³Έ 적이 μ—†μŠ΅λ‹ˆλ‹€
rbenv 의 μ„€μΉ˜μ— λŒ€ν•΄μ„œλŠ” μ•Œλ €λ“œλ¦¬κΈ°κ°€ μ–΄λ ΅μŠ΅λ‹ˆλ‹€

무엇보닀도 사싀 μ‹œμŠ€ν…œμ— μ„€μΉ˜λœ 루비λ₯Ό κ·ΈλŒ€λ‘œ μ΄μš©ν•΄λ„ λ¬΄κ΄€ν•©λ‹ˆλ‹€!
(κ·Έλƒ₯ μ°μ°ν•΄μ„œ ν™˜κ²½μ„ ν•˜λ‚˜ μƒˆλ‘œ λ§Œλ“€μ–΄μ„œ μž‘μ—…ν–ˆλ‹€κ³  μƒκ°ν•΄μ£Όμ„Έμš”)

그리고 μ£„μ†‘ν•˜μ§€λ§Œ μœˆλ„μš°λŠ”... 잘 λͺ¨λ₯΄κ² μŠ΅λ‹ˆλ‹€ 😭

πŸ’Ž rbenv


rbenv λŠ” 루비 λͺ…λ Ήμ–΄λ₯Ό "κ°€λ‘œμ±„μ„œ" shim executable μ΄λΌλŠ” 것을
$PATH ν™˜κ²½λ³€μˆ˜μ— μ£Όμž… ν•˜μ—¬ μ λ‹Ήν•œ 루비 λ²„μ „μœΌλ‘œ μ‹€ν–‰λ˜λ„λ‘ ν•΄μ£ΌλŠ”
μ†Œμœ„ λ£¨λΉ„μ˜ 격리된 ν™˜κ²½μ„ λ§Œλ“€μ–΄μ£ΌλŠ” ν”„λ‘œκ·Έλž¨ μž…λ‹ˆλ‹€

NodeJS 의 nvm κ³Ό λΉ„μŠ·ν•˜λ‹€κ³  μƒκ°ν•˜μ…”λ„ λ©λ‹ˆλ‹€

MacOS μ—μ„œλŠ” μ•„λž˜μ²˜λŸΌ μ„€μΉ˜ν•©λ‹ˆλ‹€

$ brew install rbenv

μ—­μ‹œ homebrew λŠ” μΆ•λ³΅μž…λ‹ˆλ‹€...

κ·Έ μ΄ν›„μ˜ Instruction 은 λ‹€μŒμ˜ λ¬Έμ„œλ₯Ό 따라... ν•˜λΌκ³  λ§μ”€λ“œλ¦¬κ³  μ‹Άμ§€λ§Œ
우리의 λͺ©ν‘œλŠ” colorls λ₯Ό μ„€μΉ˜ ν•˜λŠ” 것이기 λ•Œλ¬Έμ— μƒμ„Έν•œ μ„€λͺ…은 μƒλž΅ν•©λ‹ˆλ‹€

# μ„€μΉ˜ 확인
$ rbenv --version
rbenv 1.1.2

$ rbenv init
# Load rbenv automatically by appending
# the following to ~/.zshrc:

eval "$(rbenv init -)"

rbenv init λͺ…λ Ήμ–΄λ₯Ό μž…λ ₯ν•˜λ‹ˆ, eval "$(rbenv init -)" λ₯Ό μ‰˜ μ‹€ν–‰ μŠ€ν¬λ¦½νŠΈμ— λ„£μœΌλΌκ³  ν•©λ‹ˆλ‹€
bash μ‚¬μš©μžλŠ” .bashrc 에, zsh μ‚¬μš©μžλŠ” .zshrc 에 λ„£μ–΄ μ€μ‹œλ‹€

그리고 터미널을 껐닀 μΌœκ±°λ‚˜, source .zshrc 와 같은 λͺ…λ Ήμ–΄λ₯Ό 톡해 μž¬μ‹œμž‘ ν•΄ μ£Όμ„Έμš”!

rbenv-doctor 슀크립트λ₯Ό 톡해, rbenv κ°€ 정상 μ„€μΉ˜ λ˜μ—ˆλŠ”μ§€ 확인 ν•©λ‹ˆλ‹€

$ curl -fsSL https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-doctor | bash
Checking for `rbenv' in PATH: /usr/local/bin/rbenv
Checking for rbenv shims in PATH: OK
Checking `rbenv install' support: /usr/local/bin/rbenv-install (ruby-build 20170523)
Counting installed Ruby versions: none
  There aren't any Ruby versions installed under `~/.rbenv/versions'.
  You can install Ruby versions like so: rbenv install 2.2.4
Checking RubyGems settings: OK
Auditing installed plugins: OK

μ—¬κΈ°κΉŒμ§€ μ„€μΉ˜ν•˜μ…¨μœΌλ©΄ 사싀상 λ‹€ ν–ˆλ‹€κ³  λ§μ”€λ“œλ¦΄ 수 μžˆκ² λ„€μš”!

μƒˆλ‘œμš΄ λ²„μ „μ˜ 루비λ₯Ό μ„€μΉ˜ν•΄ λ΄…μ‹œλ‹€
무슨 버전을 μ„€μΉ˜ν•΄μ•Ό ν•  지 λͺ¨λ₯Όλ•ŒλŠ” 곡식 ν™ˆνŽ˜μ΄μ§€μ—μ„œ μ•ˆλ‚΄ν•˜λŠ”
stable 버전을 μ„€μΉ˜ν•˜λŠ”κ²Œ 제일 μ’‹κ² μ£ ?

image.png
~이런 γ…γ…Š ν”„λ‘œκ·Έλž˜λ¨Έμ˜ 단짝 μΉœκ΅¬λΌλ‹ˆ! λ„ˆλ¬΄ κ·€μ—¬μš΄κ±° μ•„λ‹Œκ°€μš” 😭~

2.6.3을 μ„€μΉ˜ν•˜λΌκ³  ν•©λ‹ˆλ‹€. 이 λ¬Έμ„œκ°€ λͺ‡ 년이 μ§€λ‚˜λ©΄ κ·Έ λ•Œμ— λ§žλŠ” λ²„μ „μœΌλ‘œ μ„€μΉ˜ν•΄ μ£Όμ„Έμš”
인터넷에 μžˆλŠ” XX κ°€μ΄λ“œ λ¬Έμ„œλŠ” μ—¬λŸ¬λΆ„μ˜ 생각을 λŒ€μ‹ ν•΄μ£Όμ§€ μ•ŠμŠ΅λ‹ˆλ‹€...
휴먼, 생각을 ν•˜λ©΄μ„œ λ”°λΌν•˜μ„Έμš”!

$ rbenv install 2.6.3
ruby-build: definition not found: 2.6.3

See all available versions with `rbenv install --list'.

If the version you need is missing, try upgrading ruby-build:

  brew update && brew upgrade ruby-build

이런! ruby 2.6.3 이 ruby-build 에 μ‘΄μž¬ν•˜μ§€ μ•ŠλŠ”λ‹€κ³  ν•˜λ„€μš”
brew update λ₯Ό 톡해, μƒˆλ‘œμš΄ λ²„μ „μ˜ ruby-build λ₯Ό λ°›μ•„μ˜΅λ‹ˆλ‹€

$ brew update && brew upgrade ruby-build  # It might takes your (long) time ... take a cup of coffee β˜•οΈ
Updated 3 taps (homebrew/cask-versions, homebrew/core and homebrew/cask).
==> Updated Formulae
readline βœ”                cmocka                    fn                        kubeprod                  nats-streaming-server     webdis
badtouch                  erlang                    ghq                       libiconv                  quazip                    you-get
binaryen                  exploitdb                 golang-migrate            libxo                     traefik
buildkit                  faas-cli                  grpc                      lmod                      volt
==> Upgrading 1 outdated package:
ruby-build 20190320 -> 20190423
==> Upgrading ruby-build
==> Downloading https://github.com/rbenv/ruby-build/archive/v20190423.tar.gz
==> Downloading from https://codeload.github.com/rbenv/ruby-build/tar.gz/v20190423
######################################################################## 100.0%
==> ./install.sh
🍺  /usr/local/Cellar/ruby-build/20190423: 446 files, 223.5KB, built in 6 seconds
Removing: /usr/local/Cellar/ruby-build/20190320... (440 files, 220.8KB)

히히호호 ruby-build 에 μƒˆλ‘œμš΄ 버전이 μΆ”κ°€λ˜μ—ˆλŠ”μ§€ ν™•μΈν• κΉŒμš”?

$ ruby-build --definitions
2.6.0-dev
2.6.0-preview1
2.6.0-preview2
2.6.0-preview3
2.6.0-rc1
2.6.0-rc2
2.6.0
2.6.1
2.6.2
2.6.3 ← μž‘μ•˜λ‹€ μš”λ†ˆ 🐢
jruby-9.2.6.0

이제 μ€€λΉ„κ°€ λ˜μ—ˆμœΌλ‹ˆ μ„€μΉ˜ν•©λ‹ˆλ‹€
(μ„€μΉ˜λŠ” 정말 μ‹œκ°„μ΄ κ½€ κ±Έλ¦½λ‹ˆλ‹€. 컀피 ν•œ μž” ν•˜κ³  μ˜€μ„Έμš”!)

$ rbenv install # It might takes your (long, long... long) time ... take a cup of coffee β˜•οΈ

이제 μ„€μΉ˜ν–ˆμœΌλ‹ˆ, 잘 μ„€μΉ˜ λ˜μ—ˆλŠ”μ§€ 확인해 λ³ΌκΉŒμš”?

$ rbenv versions
* system (set by /Users/doondoony/.rbenv/version)
  2.6.3

2.6.3 버전이 잘 μ„€μΉ˜ λ˜μ—ˆμŠ΅λ‹ˆλ‹€! system 이라고 ν‘œμ‹œλœ 버전은
MacOS κ°€ 기본적으둜 가지고 μžˆλŠ” ruby 의 λ²„μ „μž…λ‹ˆλ‹€.

μ§€κΈˆκΉŒμ§€μ˜ μž‘μ—…μ€ λ°”λ‘œ system 버전을 κ±΄λ“œλ¦¬μ§€ μ•ŠκΈ° μœ„ν•΄μ„œ
λ‹€λ₯Έ 루비 버전을 μ„€μΉ˜ν•œ κ²ƒμž…λ‹ˆλ‹€!

그럼 이제 global ruby 버전을 λ³€κ²½ν•΄ λ³Όκ²Œμš”

FYI. λ‚˜μ€‘μ— ruby κ΄€λ ¨ λ¬Έμ œκ°€ μžˆμ„ κ²½μš°μ—λŠ”
rbenv global system λͺ…λ ΉμœΌλ‘œ μ‹œμŠ€ν…œ 루비 버전을 λ³΅κ΅¬ν•˜μ„Έμš”

$ rbenv global 2.6.3
$ ruby --version
ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-darwin18]
$ gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 3.0.3
  - RUBY VERSION: 2.6.3 (2019-04-16 patchlevel 62) [x86_64-darwin18]
  - INSTALLATION DIRECTORY: /Users/doondoony/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0
  ... 이런 μ €λŸ° λ‚΄μš©λ“€ ...

ruby --version λͺ…λ ΉμœΌλ‘œ 루비 버전을 ν™•μΈν–ˆκ³ 
gen env λͺ…λ ΉμœΌλ‘œ gem μ΄λΌλŠ” 루비 νŒ¨ν‚€μ§€λ§€λ‹ˆμ €κ°€ ruby 의 μ–΄λ–€ 버전에 μ’…μ†λ˜μ–΄ μžˆλŠ”μ§€λ„ ν™•μΈν–ˆμŠ΅λ‹ˆλ‹€

고생 ν•˜μ…¨μŠ΅λ‹ˆλ‹€. 이제 빨리 colorls λ₯Ό μ„€μΉ˜ν•˜λ € κ°€μš”

πŸ³οΈβ€πŸŒˆ colorls μ„€μΉ˜


~κ²°λ‘ λΆ€ν„° λ§μ”€λ“œλ¦¬λ©΄ colorls Github μ—μ„œ μ•ˆλ‚΄ν•˜λŠ” λ°©λ²•λŒ€λ‘œ
gem install colorls 둜 μ„€μΉ˜ν•˜κ²Œ 되면... tree μ˜΅μ…˜μ΄ λ™μž‘μ„ μ•ˆν•©λ‹ˆλ‹€ 😭~

μžˆμ—ˆλŠ”λ°μš”... μ—†μ—ˆμŠ΅λ‹ˆλ‹€? μ›λž˜λŠ” λ™μž‘μ„ μ•ˆν–ˆλŠ”λ°
4μ›” 9일에 1.2.0 릴리즈λ₯Ό ν•˜λ©΄μ„œ 였λ₯˜ μˆ˜μ •μ΄ λ˜μ—ˆκΈ° λ•Œλ¬Έμ—
이제 νŽΈν•˜κ²Œ μ„€μΉ˜ν•  수 μžˆκ² λ„€μš”

$ gem install colorls
Fetching colorls-1.2.0.gem

  *******************************************************************
    Changes introduced in colorls

    Sort by dirs  : -sd flag has been renamed to --sd
    Sort by files : -sf flag has been renamed to --sf
    Git status    : -gs flag has been renamed to --gs

    Clubbed flags : `colorls -ald` works
    Help menu     : `colorls -h` provides all possible flag options

    Tab completion enabled for flags

    -t flag : Previously short for --tree, has been re-allocated to sort results by time
    -r flag : Previously short for --report, has been re-allocated to reverse sort results

    Man pages have been added. Checkout `man colorls`.

  *******************************************************************
Successfully installed colorls-1.2.0
Parsing documentation for colorls-1.2.0
Installing ri documentation for colorls-1.2.0
Done installing documentation for colorls after 0 seconds
1 gem installed

$ colorls --version
1.2.0

μ„€μΉ˜ 끝! 이제 잘 λ™μž‘ν•˜λŠ”μ§€ 확인해 λ΄μš”

image.png

잘 λ©λ‹ˆλ‹€. 근데 μš°λ¦¬κ°€ colorls λ₯Ό 맀번 μž…λ ₯ν• κ²Œ μ•„λ‹ˆκΈ° λ•Œλ¬Έμ—...
(ls λͺ…령에 λΉ„ν•΄ 무렀 5 κΈ€μžλ₯Ό 더 타이핑 ν•΄μ•Όν•©λ‹ˆλ‹€)
alias λ₯Ό λͺ‡κ°€μ§€ λ§Œλ“€μ–΄ λ³΄μ•˜μŠ΅λ‹ˆλ‹€

😎 νŽΈλ¦¬ν•˜κ²Œ μ‚¬μš©ν•˜κΈ° μœ„ν•΄ λͺ‡ 가지 alias μ„€μ •


λͺ…λ Ήμ–΄μ˜ alias λŠ” 보톡 .zshrc 와 같은 μ‰˜ μ‹€ν–‰ μŠ€ν¬λ¦½νŠΈμ— μž‘μ„±ν•©λ‹ˆλ‹€
κ·Έλž˜μ„œ 저도 μž‘μ„± ν–ˆμŠ΅λ‹ˆλ‹€

image.png

μ˜΅μ…˜μ€ colorls --help λ‘œλ„ ν™•μΈν•˜μ‹€ 수 μžˆμ§€λ§Œ
κ°„λ‹¨ν•˜κ²Œ μ œκ°€ μ‚¬μš©ν•œ κ²ƒλ§Œ 정리해 λ³΄κ² μŠ΅λ‹ˆλ‹€

  • --gs: git status λ₯Ό λ³΄μ—¬μ€λ‹ˆλ‹€
  • --l: κΈ΄ λ¦¬μŠ€νŠΈν˜• 포맷을 μ‚¬μš©ν•©λ‹ˆλ‹€ (ls -l κ³Ό λ™μΌν•©λ‹ˆλ‹€)
  • -lA: . 으둜 μ‹œμž‘ν•˜λŠ” 파일 λ˜λŠ” 디렉토리도 ν¬ν•¨ν•˜μ—¬ λ³΄μ—¬μ€λ‹ˆλ‹€ (ls -al κ³Ό λ™μΌν•©λ‹ˆλ‹€)
  • --sd: 디렉토리 μš°μ„ μœΌλ‘œ ordering ν•˜μ—¬ λ³΄μ—¬μ€λ‹ˆλ‹€
  • -t: μ΅œκ·Όμ— μˆ˜μ •λœ 파일이 상단에 μ˜€λ„λ‘ ordering ν•©λ‹ˆλ‹€
  • --tree: tree ν˜•νƒœλ‘œ λ³΄μ—¬μ€λ‹ˆλ‹€. brew install tree λ₯Ό ν•΄μ„œ μ“°μ‹ λ‹€λ©΄, λ™μΌν•©λ‹ˆλ‹€

μ²¨λΆ€ν•œ μ΄λ―Έμ§€μ˜ alias μ€‘μ—μ„œ
lct λͺ…령은 lct {tree-depth} {DIRECTORY} 처럼 μ‚¬μš©ν•©λ‹ˆλ‹€
μ œκ°€ λ§Œλ“€κ³ λ„ 개인적으둜 자주 μ‚¬μš©ν•˜λŠ” κΈ°λŠ₯μž…λ‹ˆλ‹€ πŸ‘

$ lct 2
$ lct 2 ~/Downloads
... 이런 μ‹μœΌλ‘œ ...

λͺ…λ Ήμ–΄λ₯Ό μ‹€ν–‰ν•˜λ©΄ μ΄λ ‡κ²Œ λ³Ό 수 μžˆμŠ΅λ‹ˆλ‹€

image.png

🌈 마치며


예쁘긴 ν•œλ°, 잘 μ“°λƒκ΅¬μš”?
손에 이미 ll, ls κ°€ 읡어버린 터리 사싀 κ·Έλ ‡κ²Œ 잘 μ“°μ§€λŠ” μ•ŠμŠ΅λ‹ˆλ‹€...
디렉토리 트리λ₯Ό λ³Ό λ•Œ lct λͺ…령은 가끔 μ‚¬μš©ν•˜λŠ” νŽΈμž…λ‹ˆλ‹€

κ·Έλž˜λ„ μ˜ˆμ˜μž–μ•„μš”. 예쁘면 λ°₯ κ°’ ν•œκ±°λΌκ³  μƒκ°ν•©λ‹ˆλ‹€
λ˜λŠ” λ°œν‘œν•  λ•Œ, νšŒμ‚¬μ—μ„œ λ‚΄ 컴퓨터 화면에 λ„μšΈλ•Œ λ­”κ°€ 괜히 νž™ν•΄ λ³΄μ΄λŠ” λŠλ‚Œ...
μ•„λ¬΄νŠΌ μš©λ„λŠ” 개인이 μ•Œμ•„μ„œ 잘 μ°ΎμœΌμ‹œλ¦¬λΌ λ―ΏμŠ΅λ‹ˆλ‹€

κΈ΄ κΈ€ μ½μ–΄μ£Όμ…”μ„œ κ°μ‚¬ν•©λ‹ˆλ‹€
λ”λΆˆμ–΄ 예쁜걸 μ’‹μ•„ν•˜μ‹œλŠ” 뢄듀은 lolcat μ΄λΌλŠ” ruby gem 도 μΆ”μ²œν•©λ‹ˆλ‹€
좜λ ₯을 RAINBOW 🌈 μƒ‰μœΌλ‘œ λ³€κ²½ν•΄ μ€λ‹ˆλ‹€. RAINBOW 덕후 λΆ„λ“€κ»˜ μΆ”μ²œ γ…‡γ……γ…‡

image.png

그럼 이만 🐢

profile
Espresso Cream Cat DD

4개의 λŒ“κΈ€

comment-user-thumbnail
2019λ…„ 4μ›” 28일

였였 λ„˜λ‚˜ μ˜λ‘±ν•˜λ„€μš”...! πŸ₯Ίμ†Œκ°œ κ°μ‚¬ν•©λ‹ˆλ‹€.
https://media1.tenor.com/images/7c821a688c98b2f09a2325516ecb54d9/tenor.gif?itemid=8764636
(λŒ“κΈ€μ— 움지을 μ“°κ³  μ‹Άμ–΄μš”...)

1개의 λ‹΅κΈ€
comment-user-thumbnail
2019λ…„ 4μ›” 28일

였우 μ˜ˆμ˜λ„€μš”

1개의 λ‹΅κΈ€