25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 
 
 
 
 

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