Computer >> 컴퓨터 >  >> 프로그래밍 >> Python

Fish – Linux를 위한 스마트하고 사용자 친화적인 대화형 쉘 완벽 가이드

Fish(Friendly Interactive Shell)는 UNIX 및 UNIX 계열 운영체제를 위해 개발된 쉘(Shell)입니다. Bash나 Zsh 같은 기존 쉘과 함께 사용할 수 있으며, 수많은 실용적인 기능이 기본적으로 활성화되어 있다는 점이 큰 특징입니다. 다른 쉘들이 시스템 자원을 절약하기 위해 일부 기능을 기본적으로 비활성화하는 것과 달리, Fish는 모든 기능을 기본값으로 활성화하여 사용자가 최대한의 편의성을 누릴 수 있도록 설계되었습니다.

Fish의 주요 특징

  • 사용자 친화적이고 대화형인 쉘 환경 제공
  • 강력하고 다양한 내장 기능 탑재
  • 웹 기반 설정 도구 내장
  • VGA 색상 및 터미널 256색 지원
  • X 클립보드 지원
  • 명령어 오류 검사 기능
  • help 명령어로 Fish 문서 열람 가능
  • 방향키로 자동 제안(suggestion) 선택 가능

Fish 설치 방법

Fish를 설치하려면 먼저 python-software-properties 패키지가 필요합니다. 아래 명령어로 Python 관련 패키지를 설치하세요.

$ sudo apt-get install python-software-properties

정상적으로 실행되면 다음과 같은 출력 결과를 확인할 수 있습니다.

Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
    python-pycurl
Suggested packages:
    libcurl4-gnutls-dev python-pycurl-dbg
The following NEW packages will be installed:
python-pycurl python-software-properties
0 upgraded, 2 newly installed, 0 to remove and 7 not upgraded.
Need to get 67.5 kB of archives.
After this operation, 358 kB of additional disk space will be used.
Do you want to continue? [Y/n] y

다음으로, 아래 명령어를 입력하여 Fish 저장소(repository)를 시스템에 추가합니다.

$ sudo add-apt-repository ppa:fish-shell/nightly-master

저장소 추가가 진행되면 다음과 같은 화면이 나타납니다.

This repository contains regular builds of the most recent source of Fish shell,
built from the Git master trunk at https://github.com/fish-shell/fish-shell/.

More info: https://launchpad.net/~fish-shell/+archive/ubuntu/nightly-master
Press [ENTER] to continue or ctrl-c to cancel adding it

gpg: keyring `/tmp/tmpzn3dsxqj/secring.gpg' created
gpg: keyring `/tmp/tmpzn3dsxqj/pubring.gpg' created
gpg: requesting key 6DC33CA5 from hkp server keyserver.ubuntu.com
gpg: key 6DC33CA5: public key "Launchpad PPA for Fish shell maintainers" imported
gpg: Total number processed: 1
gpg:               imported: 1 (RSA: 1)
OK

저장소 추가가 완료되면 아래 명령어로 패키지 목록을 최신 상태로 업데이트합니다.

$ sudo apt-get update

이제 다음 명령어로 Fish를 설치합니다.

$ sudo apt-get install fish

설치 과정은 다음과 같이 진행됩니다.

Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
    xsel
The following NEW packages will be installed:
    fish xsel
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 1,187 kB of archives.
After this operation, 6,568 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 https://ppa.launchpad.net/fish-shell/nightly-master/ubuntu/ trusty/main fish amd64 2.2.0-680-ga701264-1~trusty [1,166 kB]
Get:2 https://in.archive.ubuntu.com/ubuntu/ trusty/universe xsel amd64 1.2.0-2 [20.6 kB]
Fetched 1,187 kB in 4s (284 kB/s)

Fish 쉘 사용법

설치가 완료되었다면 아래 명령어로 Fish 쉘을 실행할 수 있습니다.

$ fish

실행하면 다음과 같은 환영 메시지가 표시됩니다.

Welcome to fish, the friendly interactive shell
Type help for instructions on how to use fish

설치된 버전 확인하기

현재 설치된 Fish의 버전을 확인하려면 아래 명령어를 입력하세요.

$ echo $FISH_VERSION

출력 예시는 다음과 같습니다.

2.2.0-680-ga701264

자동 제안(Auto Suggestion) 기능 활용하기

Fish의 가장 강력한 기능 중 하나는 자동 제안입니다. 예를 들어 "da"라고 입력하기 시작하면, 이전에 사용한 명령어를 기반으로 date 명령어가 자동으로 제안됩니다.

$ date

엔터 키를 누르면 현재 날짜와 시간이 출력됩니다.

Tue Mar 15 11:29:50 IST 2016

help 명령어로 문서 보기

Fish에 대한 더 자세한 정보가 필요하면 아래 명령어를 입력하세요. 웹 브라우저에서 공식 문서가 열립니다.

$ help

실시간 구문 강조(Syntax Highlighting)

Fish는 입력하는 명령어의 유효성을 실시간으로 판단하여 색상으로 구분해 줍니다. 올바른 명령어는 한 가지 색으로, 잘못된 명령어는 붉은색으로 표시되어 오류를 사전에 방지할 수 있습니다.

$ echo "I am loving tutorialspoint"

출력 결과:

I am loving tutorialspoint

Fish를 기본 쉘로 설정하기

Fish를 마음에 들어한다면, 아래 명령어로 기본 쉘(default shell)로 변경할 수 있습니다.

$ chsh -s /usr/bin/fish

반대로 이전에 사용하던 쉘(예: Bash)로 되돌아가고 싶다면 다음 명령어를 사용하세요.

$ chsh -s /bin/bash

축하합니다! 이제 여러분은 "Linux를 위한 스마트하고 사용자 친화적인 대화형 쉘, Fish"의 설치 방법과 기본 사용법을 모두 익히셨습니다. 다음 Linux 포스트에서는 더 유용한 명령어들을 소개해 드리겠습니다. 계속해서 지켜봐 주세요!