You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

bashrc 18 KiB

13 years ago
13 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
13 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
13 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
13 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
13 years ago
12 years ago
13 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
13 years ago
12 years ago
13 years ago
12 years ago
12 years ago
12 years ago
12 years ago
13 years ago
12 years ago
12 years ago
12 years ago
13 years ago
12 years ago
13 years ago
12 years ago
13 years ago
12 years ago
13 years ago
13 years ago
13 years ago
13 years ago
12 years ago
13 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703
  1. #!/bin/bash
  2. # If not running interactively, don't do anything
  3. [[ $- != *i* ]] && return
  4. ##########################################
  5. null(){
  6. "$@" >/dev/null 2>&1
  7. }
  8. __try_exec(){
  9. type $1 >/dev/null 2>&1 && "$@"
  10. }
  11. ##########################
  12. # system type
  13. alias ismsys=false
  14. alias iscygwin=false
  15. alias iswindows=false
  16. alias isdarwin=false
  17. alias islinux=false
  18. alias with_coreutils=false # for mac
  19. case `uname` in
  20. (MINGW*) alias ismsys=true ;;
  21. (CYGWIN*) alias iscygwin=true ;;
  22. (Darwin*) alias isdarwin=true ;;
  23. (Linux*) alias islinux=true ;;
  24. esac
  25. null ls --version && alias with_coreutils=true
  26. ( ismsys || iscygwin ) && alias iswindows=true
  27. #################################
  28. if false iswindows
  29. then
  30. export PAGER='tr -d \\r | less'
  31. else
  32. export PAGER="less"
  33. fi
  34. export LESS="-iRMX"
  35. if null type vim
  36. then
  37. export EDITOR=vim
  38. else
  39. export EDITOR=vi
  40. fi
  41. export LANG=ja_JP.UTF-8
  42. export LC_MESSAGES=C
  43. # export CDPATH=".:~"
  44. export VISUAL="$EDITOR"
  45. export GIT_PAGER="less -F"
  46. export GIT_EDITOR="$EDITOR"
  47. if test -n "$TMUX" && \
  48. test -n "tmux display -p '#{client_termname}' | grep -o 256color"
  49. then
  50. TERM=screen-256color
  51. fi
  52. test -z "$TMP" && export TMP=/tmp/${USER}-tmp
  53. mkdir -p "$TMP"
  54. ! iswindows && null type stty && {
  55. stty stop undef # unbind C-s to stop displaying output
  56. # stty erase '^h'
  57. }
  58. if iswindows; then
  59. # export PS1=" \[\e[32m\]\u@\H \[\e[33m\]\w\[\e[0m\] \d \t\n\s \# \j \$ "
  60. # export PS1=" [\[\e[33m\]\w\[\e[0m\]]\n\[\e[32m\]\u@\H\[\e[0m\] \d \t \s.\v\nhist:\# jobs:\j \$ "
  61. export USER=$USERNAME
  62. fi
  63. _tmux_prefs(){
  64. null type tmux || return 1
  65. tmux set -g mode-keys vi
  66. }
  67. #######################
  68. iswindows && alias tty="echo cmd.exe"
  69. type fortune >/dev/null 2>&1 && {
  70. fortune
  71. echo
  72. fortune -o
  73. echo
  74. }
  75. uname -a
  76. echo TERM $TERM $(tput colors) colors connected to $(tty), running $BASH $BASH_VERSION
  77. echo
  78. ###################################
  79. # some aliases and functions
  80. ( ! with_coreutils && isdarwin ) || test "$TERM" == dumb || _coloroption=" --color=auto"
  81. ( ! with_coreutils && isdarwin ) || iswindows || _timeoption=" --time-style=long-iso"
  82. ( ! with_coreutils && isdarwin ) || _hideoption=" --hide=[A-Z]*" # do not use
  83. _timeformat_iso="%Y-%m-%dT%H:%M:%S%z"
  84. _timeformat_rfc2822="%a, %d %b %Y %T %z"
  85. alias ls="ls -hCF${_coloroption}${_timeoption}"
  86. # export GREP_OPTIONS=""
  87. alias gr="grep -n --color=always"
  88. iswindows && alias grep="grep -n"
  89. # alias ll="ls -l"
  90. # alias la="ls -A"
  91. # alias lla="ls -Al"
  92. alias less="less -F"
  93. alias em="emacs -nw"
  94. null type vim && alias vi=vim
  95. alias pstree="LANG=C pstree"
  96. alias cp="cp -v"
  97. alias mv="mv -v"
  98. alias rm="rm -v"
  99. alias psaux="ps auxww"
  100. alias q=exit
  101. alias e3=e3em
  102. #alias dirs="dirs -v -l | \grep -v \$(printf '%s$' \$PWD)"
  103. alias po=popd
  104. alias pu=pushd
  105. alias sudo="sudo " # use aliases through sudo
  106. alias halt="sudo halt"
  107. alias reboot="sudo reboot"
  108. alias suspend="dbus-send --system --print-reply --dest=org.freedesktop.UPower \
  109. /org/freedesktop/UPower org.freedesktop.UPower.Suspend"
  110. alias hibernate="dbus-send --system --print-reply --dest=org.freedesktop.UPower \
  111. /org/freedesktop/UPower org.freedesktop.UPower.Hibernate"
  112. alias rand="echo \$RANDOM"
  113. alias xunp="file-roller -h"
  114. alias pc="sudo \paco -D"
  115. alias pycalc="python -i -c 'from math import *' "
  116. alias py3=python3
  117. alias py2=python2
  118. alias _reloadrc="test -f ~/.bashrc && source ~/.bashrc"
  119. # alias mytime="date +%Y%m%d-%H%M%S"
  120. alias sh="ENV=$HOME/.shrc PS1=\$\ PROMPT_COMMAND="" sh"
  121. # type trash >/dev/null 2>&1 && alias rm=trash
  122. alias mpg123="mpg123 -C -v --title"
  123. alias xm="xmms2"
  124. #export PLAYER="mpg123 -C -v --title"
  125. null type screen && alias screen="screen -e^z^z"
  126. alias zcd="cd \`zenity --file-selection --directory\`"
  127. null type gtags && alias gtags="gtags --verbose"
  128. null type htags && alias htags="htags --xhtml --symbol --line-number \
  129. --frame --alphabet --verbose"
  130. alias pad=notepad
  131. null type gedit && alias pad=gedit
  132. null type leafpad && alias pad=leafpad
  133. isdarwin && alias pad="open -e"
  134. alias wic=wicd-curses
  135. alias wil="wicd-cli -y -l | head"
  136. #alias wicn="wicd-cli -y -c -n"
  137. wicn(){
  138. if test $# -eq 0
  139. then
  140. local num
  141. wicd-cli -y -l | head
  142. echo -n "input num: "
  143. read num
  144. test -n "$num" && wicd-cli -y -c -n $num
  145. else
  146. wicd-cli -y -c -n $1
  147. fi
  148. }
  149. alias aptin="apt-get install"
  150. alias aptsearch="apt-cache search"
  151. alias aptshow="apt-cache show"
  152. for f in /usr/share/vim/vimcurrent/macros/less.sh \
  153. /usr/share/vim/vim73/macros/less.sh \
  154. /usr/share/vim/vim72/macros/less.sh
  155. do
  156. test -f $f && alias vl=$f && break
  157. done
  158. alias yt=yaourt
  159. null type pacman-color && {
  160. alias pacman=pacman-color
  161. export pacman_program=pacman-color # used by pacmatic
  162. export PACMAN=pacman-color # used by yaourt
  163. }
  164. null type pacmatic && {
  165. alias pacman="pacmatic"
  166. export PACMAN="pacmatic"
  167. }
  168. null type apt-get && \
  169. alias aupgrade="sudo apt-get autoremove --yes && sudo apt-get update --yes && sudo apt-get upgrade --yes"
  170. null type port && \
  171. alias port="port -v"
  172. alias pupgrade="sudo port -v selfupdate && { sudo port -v upgrade outdated; }"
  173. if iscygwin; then
  174. null type windate || alias windate="/c/Windows/System32/cmd.exe //c 'echo %DATE%-%TIME%'"
  175. alias cygsu="cygstart /cygwinsetup.exe"
  176. alias emacs="CYGWIN=tty emacs -nw"
  177. alias ls="ls -CFG $(iswindows || test "$TERM" == dumb || echo --color=auto)"
  178. fi
  179. alias g=git
  180. if null type _git
  181. then
  182. # enable programmable completion for g
  183. complete -o bashdefault -o default -o nospace -F _git g 2>/dev/null \
  184. || complete -o default -o nospace -F _git g
  185. fi
  186. alias setup.py="sudo python3 setup.py install --record files.txt"
  187. scr(){
  188. _tformat="%Y%m%d-%H%M%S%z"
  189. _file=`date +${_tformat}`.script
  190. SCRIPT=${_file} script ${_file} "$@"
  191. }
  192. netwait(){
  193. while ! ping -c 1 -t 1 example.com
  194. do
  195. true
  196. done
  197. echo network works.
  198. }
  199. cd(){
  200. if test $# -eq 0
  201. then
  202. pushd ~/ >/dev/null
  203. elif test $1 = -
  204. then
  205. local pwd="$PWD"
  206. command cd $OLDPWD
  207. pushd -n "$pwd" >/dev/null # stack last dir
  208. elif ! test -d "$1"
  209. then
  210. echo `basename ${SHELL}`: cd: "$1": No such file or directory 1>&2
  211. return 1
  212. else
  213. pushd "$1" >/dev/null
  214. fi
  215. __dirs_rm_dup "$PWD"
  216. echo "$PWD"
  217. }
  218. __dirs_rm_dup(){
  219. for d in "$@"
  220. do
  221. local next="$(__realpath --strip "$d")"
  222. for l in $(\dirs -v -l | cut -d $'\n' -f 2- | \grep -x " *[0-9]\+ \+${next}" | \grep -o "^ *[0-9]\+ " | tac)
  223. do
  224. popd +$l -n >/dev/null
  225. done
  226. done
  227. }
  228. __realpath(){
  229. if type realpath >/dev/null 2>&1
  230. then
  231. command realpath "$@"
  232. else
  233. while ! test -d $1
  234. do
  235. shift
  236. done
  237. local d="$OLDPWD"
  238. command cd "$1"
  239. echo "$PWD"
  240. command cd "$d"
  241. fi
  242. }
  243. dh(){
  244. if test $# -eq 0
  245. then
  246. dirs -v -l
  247. else
  248. local dir="$(dirs -v -l | \grep "^ *$1 \+" | sed "s/^ *[0-9]* *//g")"
  249. cd "$dir"
  250. fi
  251. }
  252. input(){
  253. local foo
  254. stty -echo
  255. read foo
  256. stty echo
  257. echo $foo
  258. }
  259. tmux(){
  260. if test $# -eq 0
  261. then
  262. (cd ~; command tmux start;)
  263. if command tmux has -t main
  264. then
  265. command tmux attach -t main
  266. else
  267. (cd ~; command tmux new -s main;)
  268. fi
  269. else
  270. command tmux "$@"
  271. fi
  272. }
  273. mcrypt-stream(){
  274. test $# -eq 2 || return 1
  275. case $1 in
  276. en)
  277. mcrypt --key $2 | base64 ;;
  278. de)
  279. base64 -d | mcrypt -d --key $2 ;;
  280. esac
  281. }
  282. gpg-stream(){
  283. test $# -eq 2 || return 1
  284. case $1 in
  285. en)
  286. gpg --passphrase $2 -c --batch |base64 ;;
  287. de)
  288. base64 -d|gpg --passphrase $2 -d --batch ;;
  289. esac
  290. }
  291. alias enst="gpg-stream en"
  292. alias dest="gpg-stream de"
  293. showinfo(){
  294. echo "Japanese letters are 表示可能"
  295. __try_exec diskinfo
  296. ! isdarwin && test -n "${DISPLAY}" && {
  297. __try_exec xrandr | \grep --color=never ^Screen
  298. }
  299. iswindows || __try_exec finger $USER
  300. LANG=C __try_exec id
  301. __try_exec xset q
  302. }
  303. x(){
  304. if [[ -z $DISPLAY ]] && ! [[ -e /tmp/.X11-unix/X0 ]] && (( EUID )); then
  305. #mkdir -p ~/.my/log
  306. # nohup startx >~/.my/log/xorg.log 2>&1 &
  307. # exit
  308. exec startx
  309. else
  310. echo "X cant be started! Maybe another X is already running or something." 1>&2
  311. fi
  312. }
  313. bak(){
  314. for file in "$@"
  315. do
  316. cp -v ${file} ${file}.bak
  317. done
  318. }
  319. di(){
  320. if type colordiff >/dev/null 2>&1 && test $TERM != dumb
  321. then
  322. local diffcmd=colordiff
  323. else
  324. local diffcmd=diff
  325. fi
  326. ${diffcmd} -u "$@" | ${PAGER}
  327. }
  328. tb(){
  329. local tb="$HOME/.my/tb"
  330. mkdir -p "$tb"
  331. for file in "$@"
  332. do
  333. mv -t "$tb" "$file"
  334. done
  335. }
  336. mkcd(){
  337. mkdir -p $1
  338. cd $1
  339. }
  340. if test -n "$TMUX" && null type reattach-to-user-namespace
  341. then
  342. alias pbpaste="reattach-to-user-namespace pbpaste"
  343. alias pbcopy="reattach-to-user-namespace pbcopy"
  344. fi
  345. catclip(){
  346. if iswindows
  347. then
  348. cat /dev/clipboard | tr -d \\r
  349. elif isdarwin
  350. then
  351. pbpaste
  352. else
  353. xclip -o -selection "clipboard"
  354. fi
  355. }
  356. setclip(){
  357. if iswindows
  358. then
  359. if test $# -eq 0
  360. then
  361. sed -e 's/$/\r/' | tee /dev/clipboard
  362. else
  363. cat "$@" | sed -e 's/$/\r/' | tee /dev/clipboard
  364. fi
  365. elif isdarwin
  366. then
  367. if test $# -eq 0
  368. then
  369. pbcopy
  370. else
  371. cat "$@" | pbcopy
  372. fi
  373. else
  374. if test $# -eq 0
  375. then
  376. xclip -i -f -selection "primary" | xclip -i -f -selection "clipboard"
  377. else
  378. cat "$@" | xclip -i -f -selection "primary" | xclip -i -f -selection "clipboard"
  379. fi
  380. fi
  381. }
  382. open_file(){
  383. if iswindows
  384. then
  385. cmd.exe //c start "" "$@"
  386. elif isdarwin
  387. then
  388. touch "$@"
  389. open "$@"
  390. elif islinux
  391. then
  392. touch "$@"
  393. if null type pcmanfm; then
  394. LC_MESSAGES= pcmanfm "$@"
  395. else
  396. LC_MESSAGES= xdg-open "$@" &
  397. fi
  398. else
  399. cat "$@"
  400. fi
  401. }
  402. o(){
  403. if test $# -eq 0
  404. then
  405. open_file .
  406. else
  407. for f in "$@"
  408. do
  409. open_file "$(realpath "$f")"
  410. done
  411. fi
  412. }
  413. convmv-sjis2utf8-test(){
  414. convmv -r -f sjis -t utf8 *
  415. }
  416. convmv-sjis2utf8-notest(){
  417. convmv -r -f sjis -t utf8 * --notest
  418. }
  419. __my_moc_state(){
  420. type mocp >/dev/null 2>&1 || return
  421. test "`mocp -Q %state 2>/dev/null`" == PLAY || return
  422. printf "$1" "`mocp -Q %title 2>/dev/null`"
  423. }
  424. __my_parse_svn_branch() {
  425. local LANG=C
  426. local svn_url=$(svn info 2>/dev/null | sed -ne 's#^URL: ##p')
  427. local svn_repository_root=$(svn info 2>/dev/null | sed -ne 's#^Repository Root: ##p')
  428. echo ${svn_url} | sed -e 's#^'"${svn_repository_root}"'##g' | awk '{print $1}'
  429. }
  430. __my_svn_ps1(){
  431. if svn status >/dev/null 2>&1
  432. then
  433. local svn_branch=$(__my_parse_svn_branch)
  434. test -n "${svn_branch}" && printf "$1" "{$svn_branch}"
  435. fi
  436. }
  437. #Change ANSI Colors
  438. _chengecolors(){
  439. echo -e \
  440. "\e]P0000000" \
  441. "\e]P1cd0000" \
  442. "\e]P200cd00" \
  443. "\e]P3cdcd00" \
  444. "\e]P41e90ff" \
  445. "\e]P5cd00cd" \
  446. "\e]P600cdcd" \
  447. "\e]P7353535" \
  448. "\e]P8666666" \
  449. "\e]P9ff9999" \
  450. "\e]Pa99ff99" \
  451. "\e]Pbffff99" \
  452. "\e]Pc9999ff" \
  453. "\e]Pdff99ff" \
  454. "\e]Pe99ffff" \
  455. "\e]Pfffffff"
  456. }
  457. # printf "\e]P7353535" \
  458. _colors(){
  459. echo -e \
  460. "\e[30mBlack" \
  461. "\e[31mRed" \
  462. "\e[32mGreen" \
  463. "\e[33mYellow" \
  464. "\e[34mBlue" \
  465. "\e[35mMagenta" \
  466. "\e[36mCyan" \
  467. "\e[37mWhite"
  468. echo -e \
  469. "\e[30;1mBright Black" \
  470. "\e[31;1mBright Red" \
  471. "\e[32;1mBright Green" \
  472. "\e[33;1mBright Yellow" \
  473. "\e[34;1mBright Blue" \
  474. "\e[35;1mBright Magenta" \
  475. "\e[36;1mBright Cyan" \
  476. "\e[37;1mBright White\n" \
  477. "\e[0m"
  478. }
  479. winln(){
  480. # for windose make link (actually junction)
  481. if test $# -eq 0
  482. then
  483. {
  484. echo "usage: winln TARGET LINK_NAME"
  485. echo "Create a link to TARGET with the name LINK_NAME (that is, TARGET must already exist)."
  486. echo "About other features run 'junction'."
  487. } 1>&2
  488. return 1
  489. else
  490. junction "$2" "$1"
  491. fi
  492. }
  493. __my_battery_status(){
  494. local dir=/sys/class/power_supply/BAT0
  495. if test -d $dir && test -r $dir/status && test -r $dir/charge_full && test -r $dir/charge_now
  496. then
  497. local st=$(cat $dir/status)
  498. local full=$(cat $dir/charge_full)
  499. local now=$(cat $dir/charge_now)
  500. local rate=$(expr $now \* 100 / $full)
  501. printf "$1" "${st}:${rate}%"
  502. fi
  503. }
  504. alias bat='__my_battery_status %s\\n'
  505. ip-address(){
  506. type ip >/dev/null 2>&1 || return 1
  507. local ip=$(LANG=C ip addr show scope global | \grep --color=never --only-matching 'inet [^ ]*' | cut -d " " -f 2)
  508. test -n "$ip" && printf $1 $ip
  509. }
  510. __my_ps1_script(){
  511. local last=$?
  512. test -n "$SCRIPT" && echo "${__my_c5}SCR${__my_cdef} "
  513. return $last
  514. }
  515. __my_ps1_scale(){
  516. local last=$?
  517. echo "[LC:${LINES}x${COLUMNS}]"
  518. return $last
  519. }
  520. __my_ps1_tmux(){
  521. local last=$?
  522. null type tmux || return $last
  523. local tmuxc="$(tmux display -p '#S:#I:#W.#P' 2>/dev/null)"
  524. test -n "$TMUX" && echo "[TMUX:$tmuxc]"
  525. return $last
  526. }
  527. __my_ps1_moc(){
  528. local last=$?
  529. __my_moc_state "[MOC:%s]"
  530. return $last
  531. }
  532. for f in /usr/share/git/git-prompt.sh \
  533. /opt/local/share/doc/git-core/contrib/completion/git-prompt.sh
  534. do
  535. test -r $f && . $f && break
  536. done
  537. GIT_PS1_SHOWDIRTYSTATE=t
  538. GIT_PS1_SHOWUPSTREAM=t
  539. __my_ps1_git(){
  540. local last=$?
  541. null type __git_ps1 || return $last
  542. null __gitdir || return $last
  543. __git_ps1 "[GIT:$(__try_exec git config --get user.name):%s]"
  544. return $last
  545. }
  546. __my_ps1_ipaddr(){
  547. local last=$?
  548. ! iswindows && ip-address [Addr:%s]
  549. return $last
  550. }
  551. __my_ps1_bttry(){
  552. local last=$?
  553. local bst="${TMP}/batterystatus"
  554. if test -z "$DISPLAY" && ! iswindows
  555. then
  556. test -f $bst && local bstr="$(cat $bst)"
  557. test -n "$bstr" && echo "[Battery:$bstr]"
  558. __my_battery_status %s >$bst &
  559. fi
  560. return $last
  561. }
  562. __my_ps1_dirs(){
  563. dirs | wc -l
  564. }
  565. __my_ps1_jobs(){
  566. jobs | wc -l
  567. }
  568. if test "$TERM" != dumb
  569. then
  570. __my_c1="\[\e[1;31m\]" # color for PWD
  571. __my_c2="\[\e[0;36m\]" # color for user
  572. __my_c3="\[\e[1;30m\]" # color for OLDPWD
  573. if test "`hostname`" = arch-aspireone; then __my_c4="\[\e[1;34m\]"
  574. elif test "`hostname`" = darwin-mba.local; then __my_c4="\[\e[1;33m\]"
  575. elif test "`hostname`" = newkiwi; then __my_c4="\[\e[1;35m\]"
  576. else __my_c4="\[\e[1;32m\]" # color for ::
  577. fi
  578. __my_c5="\[\e[30;47m\]" # color for SCR
  579. __my_cdef="\[\e[0m\]"
  580. fi
  581. _PS1="\
  582. ${__my_c4}:: ${__my_cdef}[${__my_c2}\u@\H${__my_cdef}:${__my_c1}\w/${__my_cdef}]\$(__my_ps1_scale)\$(__my_ps1_tmux)\$(__my_ps1_git)\$(__my_ps1_bttry)\$(__my_ps1_ipaddr)\$(__my_ps1_moc)\n\
  583. ${__my_c4}:: ${__my_cdef}l${SHLVL}n\#j\js\$? \D{%T} $(__my_ps1_script)\$ "
  584. PS1=$_PS1
  585. __my_set_title(){
  586. title="$(echo $@)"
  587. case $TERM in
  588. (rxvt*|xterm*|aterm|screen*)
  589. test -t 1 &&
  590. test -n "$DISPLAY" &&
  591. test -z "$EMACS" &&
  592. echo -n -e "\033]0;${title}\007"
  593. ;;
  594. esac
  595. }
  596. PROMPT_COMMAND="__my_set_title \${USER}@\${HOSTNAME}\ \${PWD}"
  597. # copied from https://wiki.archlinux.org/index.php/X_resources
  598. invader(){
  599. # ANSI color scheme script featuring Space Invaders
  600. #
  601. # Original: http://crunchbanglinux.org/forums/post/126921/#p126921
  602. # Modified by lolilolicon
  603. #
  604. f=3 b=4
  605. for j in f b; do
  606. for i in {0..7}; do
  607. printf -v $j$i %b "\e[${!j}${i}m"
  608. done
  609. done
  610. bld=$'\e[1m'
  611. rst=$'\e[0m'
  612. cat << EOF
  613. $f1 ▀▄ ▄▀ $f2 ▄▄▄████▄▄▄ $f3 ▄██▄ $f4 ▀▄ ▄▀ $f5 ▄▄▄████▄▄▄ $f6 ▄██▄ $rst
  614. $f1 ▄█▀███▀█▄ $f2███▀▀██▀▀███ $f3▄█▀██▀█▄ $f4 ▄█▀███▀█▄ $f5███▀▀██▀▀███ $f6▄█▀██▀█▄$rst
  615. $f1█▀███████▀█ $f2▀▀███▀▀███▀▀ $f3▀█▀██▀█▀ $f4█▀███████▀█ $f5▀▀███▀▀███▀▀ $f6▀█▀██▀█▀$rst
  616. $f1▀ ▀▄▄ ▄▄▀ ▀ $f2 ▀█▄ ▀▀ ▄█▀ $f3▀▄ ▄▀ $f4▀ ▀▄▄ ▄▄▀ ▀ $f5 ▀█▄ ▀▀ ▄█▀ $f6▀▄ ▄▀$rst
  617. $bld$f1▄ ▀▄ ▄▀ ▄ $f2 ▄▄▄████▄▄▄ $f3 ▄██▄ $f4▄ ▀▄ ▄▀ ▄ $f5 ▄▄▄████▄▄▄ $f6 ▄██▄ $rst
  618. $bld$f1█▄█▀███▀█▄█ $f2███▀▀██▀▀███ $f3▄█▀██▀█▄ $f4█▄█▀███▀█▄█ $f5███▀▀██▀▀███ $f6▄█▀██▀█▄$rst
  619. $bld$f1▀█████████▀ $f2▀▀▀██▀▀██▀▀▀ $f3▀▀█▀▀█▀▀ $f4▀█████████▀ $f5▀▀▀██▀▀██▀▀▀ $f6▀▀█▀▀█▀▀$rst
  620. $bld$f1 ▄▀ ▀▄ $f2▄▄▀▀ ▀▀ ▀▀▄▄ $f3▄▀▄▀▀▄▀▄ $f4 ▄▀ ▀▄ $f5▄▄▀▀ ▀▀ ▀▀▄▄ $f6▄▀▄▀▀▄▀▄$rst
  621. $f7▌$rst
  622. $f7▌$rst
  623. $f7 ▄█▄ $rst
  624. $f7▄█████████▄$rst
  625. $f7▀▀▀▀▀▀▀▀▀▀▀$rst
  626. EOF
  627. }
  628. #/etc/lsb-release