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.
 
 
 
 
 
 

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