bash

IPアドレスを取得

ip-address(){ local ip=$(LANG=C ifconfig | grep "inet " | grep -v "127.0.0.1" | awk '{print $2}') test -n "$ip" && printf $1 $ip } ip-address [Addr:%s] 参考 http://d.hatena.ne.jp/gunshot/20081216/p1

バッテリーの状態をパーセントで取得

ただしとってもおそい battery-status(){ local dir=/sys/class/power_supply/BAT0 if test -d $dir then local st=$(cat $dir/status) local full=$(cat $dir/charge_full) local now=$(cat $dir/charge_now) local rate=$(expr $now \* 100 / $full) print…

bashプロンプトの設定

見やすさ重視で。 あんまり横に伸ばしたくないから三行。 export PS1="\$(prompt_function)\$ " prompt_function(){ # used by PS1 local lastreturn=$? local pwd=$(echo "${PWD}" | sed -e "s:${HOME}:~:") local date=$(LANG=C date +"%a, %d %b %Y %T %z…