25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

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