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