๋ฌผ๊ณ ๊ธฐ ๋ฒ์ : 2.5.0
์ฐ๋ถํฌ 16.04 Linux limebox 4.4.0-78-generic #99-Ubuntu SMP Thu Apr 27 15:29:09 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
๋ด๊ฐ ์คํ ํ์ผ์ ๋ง๋ค ๋ ์๋
ํ์ธ์, ์์ ์คํฌ๋ฆฝํธ๋ฅผ ์คํ ํ ์์๋ ๊ฒ echo "echo test" > script.fish
์คํ fish ./script.fish
: ์ค๋ฅ ๋ฉ์์ง์ ๊ฒฐ๊ณผ ./script.fish: No such file or directory
.
์ด๋ค ์ด์ ๋ก sh -c 'env HOME=$(mktemp -d) fish'
์ ์ ์๋ํฉ๋๋ค.
link/.config/fish $ tree
.
โโโ completions
โย ย โโโ fisher.fish
โย ย โโโ get.fish -> /home/limeth/.config/fisherman/get/completions/get.fish
โย ย โโโ git.fish -> /home/limeth/.config/fisherman/git-flow/completions/git.fish
โโโ conf.d
โย ย โโโ git-flow.init.fish -> /home/limeth/.config/fisherman/git-flow/init.fish
โโโ config.fish
โโโ fish_colors
โโโ fishd.limebox
โโโ fishfile
โโโ fish_history
โโโ fish_read_history
โโโ functions
โโโ cl.fish
โโโ fisher.fish
โโโ fish_greeting.fish -> /home/limeth/.config/fisherman/bobthefish/fish_greeting.fish
โโโ fish_mode_prompt.fish -> /home/limeth/.config/fisherman/bobthefish/fish_mode_prompt.fish
โโโ fish_prompt.fish -> /home/limeth/.config/fisherman/bobthefish/fish_prompt.fish
โโโ fish_right_prompt.fish -> /home/limeth/.config/fisherman/bobthefish/fish_right_prompt.fish
โโโ fish_title.fish -> /home/limeth/.config/fisherman/bobthefish/fish_title.fish
โโโ fish_user_key_bindings.fish
โโโ fzf_key_bindings.fish -> /home/limeth/.fzf/shell/key-bindings.fish
โโโ get.fish -> /home/limeth/.config/fisherman/get/functions/get.fish
โโโ getopts.fish -> /home/limeth/.config/fisherman/getopts/getopts.fish
โโโ set_color_custom.fish -> /home/limeth/.config/fisherman/jellyfish/functions/set_color_custom.fish
3 directories, 22 files
$ cat config.fish
# Source dotfiles scripts
source ~/.dotfiles/bin/source.fish
# Enable terminal colors
set -x TERM "xterm-256color"
# Vi mode
# Automatically enable Vi mode in `~/.config/fish/functions/fish_user_key_bindings.fish`
set -g theme_display_vi yes
~/.dotfiles/bin/source.fish
๋งํฌ: https://gitlab.com/Limeth/dotfiles/blob/master/bin/source.fish
๋ด๊ฐ ๋ฌด์์ ์ฐพ์์ผํ๋์ง์ ๋ํ ๋ชจ๋ ์กฐ์ธ์ ์ฃผ์๋ฉด ๊ฐ์ฌํ๊ฒ ์ต๋๋ค.
fish ./script.fish๋ฅผ ์คํํ๋ฉด ์ค๋ฅ ๋ฉ์์ง๊ฐ ๋ํ๋ฉ๋๋ค. ./script.fish: ํด๋น ํ์ผ์ด๋ ๋๋ ํฐ๋ฆฌ๊ฐ ์์ต๋๋ค.
์ด๊ฒ์ ๊ตฌ์ฑ์์ cd
์ฒ๋ผ ๋ณด์
๋๋ค.
ํด๋น ํ์ผ์ ์คํํด ๋ณด๊ณ ์คํจํ๋ฉด echo $PWD; fish -c 'echo $PWD'
. ๋ ๊ฐ์ง๊ฐ ๋ค๋ฅด๋ค๋ฉด ๊ทธ๊ฒ์ ๋น์ ์ ๋ฌธ์ ์
๋๋ค.
๊ทธ๊ฑฐ์๋ค!
$ echo $PWD
/tmp
$ fish -c "echo \$PWD"
/home/limeth
๋งค์ฐ ๊ฐ์ฌํฉ๋๋ค! :)
๋ง์ต๋๋ค. source.fish ๋ cd ~
๋๋ฉ๋๋ค. ๊ทธ๊ฒ์ ์ผ๋ฐ์ ์ผ๋ก ๋์ ์๊ฐ์
๋๋ค. ๋ก๊ทธ์ธ ์
ธ์๋ ์ด๋ฏธ PWD๊ฐ ํ ๋๋ ํ ๋ฆฌ๋ก ์ค์ ๋์ด ์์ด์ผ ํฉ๋๋ค. ๊ทธ๋ฆฌ๊ณ ๋ค๋ฅธ ๋ฌผ๊ณ ๊ธฐ ์ธ์คํด์ค๋ฅผ ์์ํ๋ ๊ฒฝ์ฐ PWD๋ฅผ ๋ณ๊ฒฝํ๊ณ ์ถ์ง ์์ต๋๋ค. ๊ทธ๋ ๊ฒ ํ๋ ๋ฐ ํฉ๋นํ ์ด์ ๊ฐ ์๋ค๊ณ ์๊ฐ๋๋ฉด ๋ํํ ์
ธ๋ก ์ ํํด์ผ ํฉ๋๋ค.
if status is-interactive
cd ~
end
๊ฐ์ฅ ์ ์ฉํ ๋๊ธ
๋ง์ต๋๋ค. source.fish ๋
cd ~
๋๋ฉ๋๋ค. ๊ทธ๊ฒ์ ์ผ๋ฐ์ ์ผ๋ก ๋์ ์๊ฐ์ ๋๋ค. ๋ก๊ทธ์ธ ์ ธ์๋ ์ด๋ฏธ PWD๊ฐ ํ ๋๋ ํ ๋ฆฌ๋ก ์ค์ ๋์ด ์์ด์ผ ํฉ๋๋ค. ๊ทธ๋ฆฌ๊ณ ๋ค๋ฅธ ๋ฌผ๊ณ ๊ธฐ ์ธ์คํด์ค๋ฅผ ์์ํ๋ ๊ฒฝ์ฐ PWD๋ฅผ ๋ณ๊ฒฝํ๊ณ ์ถ์ง ์์ต๋๋ค. ๊ทธ๋ ๊ฒ ํ๋ ๋ฐ ํฉ๋นํ ์ด์ ๊ฐ ์๋ค๊ณ ์๊ฐ๋๋ฉด ๋ํํ ์ ธ๋ก ์ ํํด์ผ ํฉ๋๋ค.