Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 
 
 

798 строки
20 KiB

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