Skip to the content.

피쉬 쉘(Fish Shell) 한글화 문서 [비공식]

문서

자습서

디자인

명령

FAQ

라이센스

피쉬 쉘 (Fish Shell) 자습서 [입문, 강좌, 소개, 튜토리얼]

왜 피쉬(fish)인가?

[Fish:피쉬 또는 Fish Shell:피쉬 쉘 로 발음합니다. 원하실 경우 ‘물고기’로 불러도 됩니다]

피쉬 배우기 (Learning fish)

Welcome to fish, the friendly interactive shell
Type help for instructions on how to use fish
you@hostname ~>

명령 실행 (Running Commands)

> echo hello world
hello world
> mkdir My\ Files
> cp ~/Some\ File 'My Files'
> ls "My Files"
Some File

도움 받기 (Getting Help)

> man set
set - handle shell variables
  Synopsis...

구문 강조 (Syntax Highlighting)

> /bin/mkd
> /bin/mkdir
> cat ~/somefi

와일드 카드 (Wildcards)

> ls *.jpg
 lena.jpg
 meena.jpg
 산타 마리아.jpg
> ls l*.p*
 lena.png
 lesson.pdf
> ls /var/**.log
 /var/log/system.log
 /var/run/sntp.log

파이프 및 방향 전환 (Pipes and Redirections)

> echo hello world | wc
       1       2      12
> grep fish < /etc/shells > ~/output.txt ^ ~/errors.txt

자동 제안 (Auto-suggestions)

> /bin/hostname
> grep --ignore-case
> r<\@args{ync} \ ssh . myname@somelonghost.com:/some/long/path/doo/dee/doo/dee/doo}

탭 완성 (Tab Completions)

> /pri @key{Tab} → /private/
> ~/stuff/s @key{Tab}
~/stuff/script.sh  (Executable, 4.8kB)  ~/stuff/sources/</font>  (Directory)
> git merge pr @key{Tab} → git merge prompt_designer
> git checkout b @key{Tab}
builtin_list_io_merge (Branch) builtin_set_color (Branch) busted_events (Tag)

변수 (Variables)

> echo My home directory is $HOME
My home directory is /home/tutorial
> echo "My current directory is $PWD"
My current directory is /home/tutorial
> echo 'My current directory is $PWD'
My current directory is $PWD
> set name 'Mister Noodle'
> echo $name
Mister Noodle
> mkdir $name
> ls
Mister Noodle

종료 상태(Exit Status)

> false
> echo $status
1

내보내기 (셸 변수)

> set -x MyVariable SomeValue
> env | grep MyVariable
MyVariablem=SomeValue
> set -e MyVariable
> env | grep MyVariable
(no output)

목록(List)

> echo $PATH
/usr/bin /bin /usr/sbin /sbin /usr/local/bin
> count $PATH
5
> set PATH $PATH /usr/local/bin
 > echo $PATH
/usr/bin /bin /usr/sbin /sbin /usr/local/bin
> echo $PATH[1]
/usr/bin
> echo $PATH[-1]
/usr/local/bin
> echo $PATH[1..2]
/usr/bin /bin
> echo $PATH[-1..2]
/usr/local/bin /sbin /usr/sbin /bin
> for val in $PATH
    echo "entry: $val"
  end
entry: /usr/bin/
entry: /bin
entry: /usr/sbin
entry: /sbin
entry: /usr/local/bin
> set -l a 1 2 3
> set -l 1 a b c
> echo $a$1
1a 2a 3a 1b 2b 3b 1c 2c 3c
> echo $a" banana"
1 banana 2 banana 3 banana
> echo "$a banana"
1 2 3 banana

명령 확장(Variable expansion)

> echo In (pwd), running (uname)
In /home/tutorial, running FreeBSD
> set os (uname)
> echo $os
Linux
> touch "testing_"(date +%s)".txt"
> ls *.txt
testing_1360099791.txt
> printf '%s\n' (pkg-config --libs gio-2.0)
-lgio-2.0 -lgobject-2.0 -lglib-2.0
> printf '%s\n' (pkg-config --libs gio-2.0 | string split " ")
-lgio-2.0
-lgobject-2.0
-lglib-2.0

명령 분리 (세미콜론)

echo fish; echo chips
\# or
echo fish
echo chips

결합자 (And, Or, Not)

> cp file1.txt file1_bak.txt; and echo "Backup successful"; or echo "Backup failed"
Backup failed
cp file1.txt file1_bak.txt
and echo "Backup successful"
or echo "Backup failed"

조건문 (If, Else, Switch)

if grep fish /etc/shells
    echo Found fish
else if grep bash /etc/shells
    echo Found bash
else
    echo Got nothing
end
if grep fish /etc/shells; and command -sq fish
    echo fish is installed and configured
end
switch (uname)
case Linux
    echo Hi Tux!
case Darwin
    echo Hi Hexley!
case FreeBSD NetBSD DragonFly
    echo Hi Beastie!
case '*'
    echo Hi, stranger!
end

함수 (Function)

> function say_hello
          echo Hello $argv
  end
> say_hello
Hello
> say_hello everybody!
Hello everybody!
> functions
alias, cd, delete-or-exit, dirh, dirs, down-or-search, eval, export, fish_command_not_found_setup, fish_config, fish_default_key_bindings, fish_prompt, fish_right_prompt, fish_sigtrap_handler, fish_update_completions, funced, funcsave, grep, help, history, isatty, ls, man, math, nextd, nextd-or-forward-word, open, popd, prevd, prevd-or-backward-word, prompt_pwd, psub, pushd, seq, setenv, trap, type, umask, up-or-search, vared
> functions ls
function ls --description 'List contents of directory'
    command ls -G $argv
end

루프 (Loop)

> while true
    echo "Loop forever"
end
Loop forever
Loop forever
Loop forever
...
> for file in *.txt
    cp $file $file.bak
end
> for x in (seq 5)
    touch file_$x.txt
end

프롬프트 (Prompt)

> function fish_prompt
    echo "New Prompt % "
end
New Prompt %
> function fish_prompt
      set_color purple
      date "+%m/%d/%y"
      set_color FF0
      echo (pwd) '>'
      set_color normal
  end
02/06/13
/home/tutorial >

$PATH (경로 변수)

> set PATH /usr/local/bin /usr/sbin $PATH
> set PATH (string match -v /usr/local/bin $PATH)
> set -U fish_user_paths /usr/local/bin $fish_user_paths

초기화 (.bashrc는 어디 갔나요?)

> cat ~/.config/fish/config.fish

set -x PATH $PATH /sbin/

function ll
    ls -lh $argv
end

함수 자동 로딩 (Autoloading Functions)

> cat ~/.config/fish/functions/ll.fish
function ll
    ls -lh $argv
end
> cat ~/.config/fish/functions/fish_prompt.fish
function fish_prompt
    echo (pwd) "> "
end

범용 변수 (Universal Variables)

> set -U EDITOR vim
> echo $EDITOR
vim

피쉬를 사용하실 준비되셨습니까?!

번역 후기

미러링된 글

라이센스 주의