顯示具有 Fishshell 標籤的文章。 顯示所有文章
顯示具有 Fishshell 標籤的文章。 顯示所有文章

2010年7月26日 星期一

[OSX 10.6]The Note! Cont.

接續上一篇

進入 fish_prompt.fish
> sudo vim fish_prompt.fish
fish_prompt.fish裡面描述了不同user登入以後prompt的長相。
預設上是"(user)@(hostname)(prompt_pwd)>"這樣一串。
P.S.只是prompt_pwd是縮短以後的pwd。

[增加顏色]
使用 set -l ooxx (set_color color) 增加區域色彩變數
顏色設定的方式基本上就是直接用%s輸出給printf

[換行]
在printf後面的'ooxx'加入 \n

[縮減user/hostname]
使用whoami或hostname,後面再接上 | cut -c 1-n

[顯示時間日期]
直接在prontf後面的參數中呼叫 date "+format"



我目前的設定
set -l _clrB (set_color blue)
set -l _clrC (set_color white)
set -l _clrR (set_color red)
set -l _clrY (set_color yellow)
printf '\n%s%s%s[' "$_clrR" (whoami|cut -c 1-3) "$_clrY"
printf '%s%s%s]%s[' "$_clrC" (date "+%H:%M") "$_clrY" "$_clrB"
printf '%s%s%s]%s' "$__fish_prompt_cwd" (prompt_pwd) "$_clrB" "$__fish_prompt_normal"
printf '\n> '
結果如下

P.S.色彩設定方面的補完就期待godfat來分享一下了 :)

[OSX 10.6]The Note!

前兩天重灌了一下Mac OS X 10.6。真的各方面都蠻不錯的,
除了那該死的中文字體。真的是難看死了...。

這次針對一些工具方面做了更新:首先是package managemant。
從原本的Macport換成Homebrew。這是因為我在手動make install ghc
以後突然想用port裝一下darcs,結果port竟然開開心心的開始幫
我build好久以前的ghc版本,囧。一怒之下就聽從godfat的讒言把port
及其他一堆自己make install(包括我記憶中我用.pkg裝的東西)給暴力
砍了,因為make install都去了/usr/local/下面,而port install都進了
/opt/local/底下,所以在godfat的鼓吹之下rm -R就給他用力打下去
啦~~~。而.pkg的部份我只記得我ghc-6.12.3是.pkg裝起來的,
所以就去/usr/bin/下面把ghc*的東西砍乾淨。最後才再灌上brew。
> ruby -e "$(curl -fsS http://gist.github.com/\
raw/323731/install_homebrew.rb)"

當然, 要順便開開心心的把用習慣的東西一併裝一裝。
> brew install fish
> brew install git
> brew install haskell-platform

Fish with Multiline Prompt:
fish shell本身沒有支援multiline prompt的處理,因為fish在
讀入自己內部用來存prompt訊息的prompt_list時,會將'\n'給忽略。
也就造成了在fish_prompt.fish裡面插入'\n'於printf後面會無效
這樣的問題。找了好一會以後,google到一個仁兄的解決辦法
[1] 砍掉原本的fish: > brew uninstall fish
[2] 下載fish的source code
[3] 修改裡面的reader.c檔(細節)
[4] 重編fish
> ./configure --prefix=/usr/local/Cellar/fish/1.23.1 --without-xsel
> sudo make install
[5] 把brew連到自己裝的fish上面
> brew link fish
應該要有類似這樣的結果
30 links created for /usr/local/Cellar/fish/1.23.1
[6] 順便 > chsh -s /usr/local/bin/fish 一下。

灌好fish之後就可以開始改fish shell裡面的東西,也就是prompt
的output設定。fish相關的一些function都放置在/usr/local
/Cellar/fish/1.23.1/share/fish/functions目錄下,
而這裡的目的是要改有關prompt的設定,也就是檔案: fish_prompt.fish。

P.S. 有關fish_prompt.fish的設定就下回分解吧 XD