Last active
February 26, 2016 16:14
-
-
Save kanufy/63d3e899face3677f781 to your computer and use it in GitHub Desktop.
お天気をzshのプロンプトに表示させる部分の.zshrc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Weather ### | |
#kyoto = 260010 | |
#tokyo = 130010 | |
#shiga = 250010 | |
WEATHER=$(curl -s http://weather.livedoor.com/forecast/webservice/json/v1\?city\=260010 | jq -r '.forecasts[] | select(.dateLabe\ | |
l == "今日").telop' ); | |
case $WEATHER in | |
曇時々晴) WE="☁ /☀";; | |
曇時々雨) WE="☁ /☂";; | |
曇時々雪) WE="☁ /☃";; | |
晴時々曇) WE="☀ /☁";; | |
晴時々雨) WE="☀ /☂";; | |
雨時々曇) WE="☂ /☁";; | |
晴のち曇) WE="☀ ->☁";; | |
晴のち雨) WE="☀ ->☂";; | |
曇のち晴) WE="☁ ->☀";; | |
曇のち雨) WE="☁ ->☂";; | |
雨のち晴) WE="☂ ->☀";; | |
雨のち曇) WE="☂ ->☁";; | |
雪のち曇) WE="☃ ->☁";; | |
曇のち雪) WE="☁ ->☃";; | |
雨) WE="☂";; | |
晴れ) WE="☀";; | |
曇り) WE="☁";; | |
雪) WE="☃";; | |
*) WE="♡";; | |
esac | |
### Prompt ### | |
# プロンプトに色を付ける | |
autoload -U colors; colors | |
# vcs_infoロード | |
autoload -Uz vcs_info | |
# gitのみ有効にする | |
zstyle ":vcs_info:*" enable git | |
# 一般ユーザ時(host% >) | |
tmp_prompt="%{${fg[cyan]}%}%n%{${reset_color}%} %{${fg[red]}%}${WE}%{${reset_color}%} %{${fg[magenta]}%}>%{${reset_color}%}" | |
tmp_prompt2="%{${fg[cyan]}%}%_> %{${rtmeset_color}%}" | |
tmp_rprompt="%{${fg[green]}%}[%~]%{${reset_color}%}" | |
tmp_sprompt="%{${fg[yellow]}%}%r is correct? [Yes, No, Abort, Edit]:%{${reset_color}%}" | |
# rootユーザ時(太字にし、アンダーバーをつける) | |
if [ ${UID} -eq 0 ]; then | |
tmp_prompt="%B%U${tmp_prompt}%u%b" | |
tmp_prompt2="%B%U${tmp_prompt2}%u%b" | |
tmp_rprompt="%B%U${tmp_rprompt}%u%b" | |
tmp_sprompt="%B%U${tmp_sprompt}%u%b" | |
fi | |
PROMPT=$tmp_prompt # 通常のプロンプト | |
PROMPT2=$tmp_prompt2 # セカンダリのプロンプト(コマンドが2行以上の時に表示される) | |
RPROMPT=$tmp_rprompt # 右側のプロンプト | |
SPROMPT=$tmp_sprompt # スペル訂正用プロンプト | |
# SSHログイン時のプロンプト | |
[ -n "${REMOTEHOST}${SSH_CONNECTION}" ] && | |
PROMPT="%{${fg[white]}%}${HOST%%.*} ${PROMPT}" | |
; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment