Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

bashrc 16 KiB

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