昨天看 Trending repositories on GitHub today 時,發現了一個不得了的東西:
給終端安上超幾把炫酷的皮神黃皮膚!
作為一個鐵桿口袋迷+程序員,還有什么能比這更打動我的心嗎?
一天后,在一番說麻煩也不麻煩,說不麻煩又學了很多新東西的折騰后,我成功入手了這款至尊皮神黃皮膚!
如果你也是口袋迷,也想給終端安上這款皮膚(或者在 493 只不同的口袋妖怪皮膚中任選一款),那么你可以看看我對這趟折騰之旅的全過程介紹,或許可以少跳幾個坑。
從零開始的項目安裝
打開 Pokemon-Terminal 項目的 github 主頁,我發現安裝前有兩個要求:
- 3.5及以上版本的 python;
- 已安裝 iTerm2。
巧了,這兩個要求我都不符合!
iTerm2 我從來沒有接觸過,根本不知道是什么。而比較久遠的時候,我在試圖將 OS X 系統自帶的 python 2.+ 升級為 3.+ 時,跟著網上不知道靠不靠譜的教程誤操作,以致 2.+ 刪掉了 3.+ 卻沒安好,依賴于 python 的以 Xcode 為首的一系列軟件全部罷工(而且過了一周左右才查出來是這個原因),最后灰溜溜地又下了一遍 2.+,從此留下了對 python 的心理陰影(但是我們這篇教程還是很靠譜的)。
沒關系,作為(準)程序員,要勇于折騰!我們一步一步的搞起。
iTerm2
我是先下載的 iTerm2,官網在此,下載即可。
iTerm2 是 OS X 系統下很好用的一款命令行工具,至于具體怎么好用,敬請百度了解。因為我現在只是為了皮神黃皮膚。當然之后我也會進一步學習使用。
python 3.5+
昨晚吃癟后的我心有不甘,發了一條說說。然后幸得初中同學救駕:
這個允許用戶方便地安裝不同版本的 python 并可以快速切換的 anaconda 幫助我解決了問題。官網提供了圖形化安裝和命令行安裝兩種方式,根據自己的專業程度選擇下載即可。
這個 anaconda 據說也是 python 開發的利器之一,不過我也不會 python。也許之后機緣巧合會深入學習(想了解可以參照這篇文章Anaconda使用總結)。說實話為了給終端換個皮膚,讓我本不寬裕的存儲空間又少了 1G 左右,有些心疼。但是折騰還是給了我很多樂趣,也許之后有用呢。
那么要求都滿足了。按照項目 README 要求,在 iTerm 2 中輸入以下三條語句:
# Pokemon Installation
git clone https://github.com/LazoCoder/Pokemon-Terminal $HOME/.Pokemon-Terminal
echo PATH="$HOME/.Pokemon-Terminal:${PATH}" >> ~/.bash_profile
source ~/.bash_profile
安裝完畢,皮神我來了!
$ pokemon pikachu
然后...出現以下報錯提示:
.Pokemon-Terminal/./Scripts/background.scpt:39:46: script error: Expected end of line but found identifier. (-2741)
翻越最后一座 bug 高山
想去給作者提一個 issue,就發現作者對于這個 bug 已經給出了解決方法。
按照解決方法,我們需要對 .Pokemon-Terminal/scripter.py 文件進行一些修改(當然,不一定每個人都碰上了這個 bug)。其實我也不太會用 vim,所以以下操作參照了這篇文章修改文件內容 vi命令。
用以下命令在終端打開:
vi .Pokemon-Terminal/scripter.py
然后按一下 i,從命令行模式進入插入模式。找到函數__terminal_script
(在比較靠上的位置),將:
content = "tell application \"iTerm\"\n"
修改為:
content = "tell application \"iTerm2\"\n"
按 Esc 鍵進入命令行模式,再按:wq
保存退出。大功告成!
再在 iTerm2 中輸入pokemon pikachu
,就會發現黑漆漆(或者白晃晃)的背景變成了皮神黃!
深度使用
Usage:
pokemon [parameter]
Parameters:
[name] - Change the terminal background to the specified Pokemon.
[index] - Change the terminal background to a Pokemon by its index.
[region] - List all the Pokemon of the specified region.
[one letter] - List all Pokemon who's names begin with a particular letter.
[two letters] - List all Pokemon who's names begin with those two letters.
Other Parameters:
pokemon all - List all the Pokemon supported.
pokemon regions - List all the available regions.
pokemon extra - List all the Pokemon from the 'Extra' folder.
pokemon random - Change the terminal background to a random Pokemon.
pokemon random-kanto - Change the terminal background to a random Pokemon from the specified region.
pokemon ? - Identify the current Pokemon in the terminal.
pokemon _pikachu - Change the wallpaper to the specified Pokemon.
pokemon _random - Change the wallpaper to a random Pokemon.
pokemon _random-kanto - Change the wallpaper to a random Pokemon from the specified region.
pokemon _? - Identify the current Pokemon in the wallpaper.
pokemon slideshow - Iterate through each Pokemon.
pokemon slideshow-kanto - Iterate through each Pokemon in the specified region.
pokemon help - Display this menu.
以上是作者提供的用法。可以通過口袋妖怪的英文名或者編號切換皮膚,或者用pokemon random
來切換成隨機的皮膚。
我們現在還得每次打開 iTerm 后輸入命令來切換皮膚。作者同樣提供了點開就換的方法,只用在 iTerm 的 Preferences 里做一點配置:
想一想,通過配置為pokemon random
,每次打開都是不同皮膚說不定更爽到。
最后作者建議你改變一下透明度之類的,使皮神看起來更酷炫有范:
我的配置是這樣的:
結語
其實一個皮膚也沒有那么重要(還是有那么一點爽的啦),重要的是通過這一番折騰,接觸到了很多常規學習中可能不會接觸的東西,包括 iTerm 和 anaconda。這也是我第一次有目的性地去看項目的 issue。希望自己以后能多一點這樣地非常規學習。
最后推薦一下我的個人博客大黃菌的個人博客,包含了一個軟工大學狗、前端小菜鳥的學習筆記、心路歷程,以及一些奇怪(?)的東西。現在有一些筆記做的還不是很好,以后會輔以新的學習成果加以修改。
歡迎大佬指點,共同進步。