No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

.bashrc 6.4 KiB

hace 13 años
hace 13 años
hace 13 años
hace 13 años
hace 13 años
hace 13 años
hace 13 años
hace 13 años
hace 13 años
hace 13 años
hace 13 años
hace 13 años
hace 13 años
hace 13 años
hace 13 años
hace 13 años
hace 13 años
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. #!/bin/bash
  2. # 外部ファイルの読み込み
  3. # test -r ~/filepath && . ~/filepath
  4. # ln SRC DST
  5. ##########################################
  6. test -r /etc/bashrc && . /etc/bashrc
  7. # export PS1="\[\e[32m\]\u@\H \[\e[33m\]\w\[\e[0m\] \d \t\n\s \# \j \$ "
  8. # export PS1="[\[\e[33m\]\w\[\e[0m\]]\n\[\e[32m\]\u@\H\[\e[0m\] \d \t \s.\v\nhist:\# jobs:\j \$ "
  9. export PS1="\$(prompt_function)\$ "
  10. # PROMPT_COMMAND=prompt_function
  11. export PAGER="less"
  12. export EDITOR="vim"
  13. export VISUAL=$EDITOR
  14. export LESS="-iRM"
  15. # export LC_MESSAGES="C"
  16. # export LANG=ja_JP.UTF-8
  17. # export CDPATH=".:~" # 使い方がよく分からない
  18. export GIT_PAGER=$PAGER
  19. export GIT_EDITOR=$EDITOR
  20. mkunfddir(){ # create dir if unfound. ?
  21. test -e "$1" || mkdir "$1"
  22. }
  23. if test "${TERM}" == dumb
  24. then
  25. alias ls="ls -CFG --time-style=long-iso"
  26. else
  27. alias ls="ls -CFG --color=auto --time-style=long-iso"
  28. fi
  29. alias ll="ls -l"
  30. alias la="ls -A"
  31. alias lla="ls -Al"
  32. alias vl=/usr/share/vim/vimcurrent/macros/less.sh
  33. alias emacs="emacs -nw"
  34. alias aptin="sudo apt-get install"
  35. alias ut="slogin t110414@un001.ecc.u-tokyo.ac.jp"
  36. alias rand="echo \$RANDOM"
  37. alias xunp="file-roller -h"
  38. alias pacome="sudo \paco -D"
  39. # type trash >/dev/null 2>&1 && alias rm=trash
  40. safe-cmd(){
  41. type $1 >/dev/null 2>&1 && "$@"
  42. }
  43. o(){
  44. if [ $# -eq 0 ]; then
  45. local f=.
  46. else
  47. local f="$1"
  48. fi
  49. if iswindows; then
  50. cmd.exe //c start "" "$f"
  51. elif isdarwin; then
  52. open "$f"
  53. else
  54. xdg-open "$f"
  55. fi
  56. }
  57. sgcc(){
  58. if iswindows; then
  59. gcc -o win.$1.exe $1
  60. else
  61. gcc -o $(uname).$1.out $1
  62. fi
  63. }
  64. sggcc(){
  65. gcc -g -o $(uname).$1.out $1
  66. }
  67. slmggcc(){
  68. gcc -g -lm -o $(uname).$1.out $1
  69. }
  70. convmv-sjis2utf8-test(){
  71. convmv -r -f sjis -t utf8 *
  72. }
  73. convmv-sjis2utf8-notest(){
  74. convmv -r -f sjis -t utf8 * --notest
  75. }
  76. dl-my-init-files(){
  77. for file in .bashrc .vimrc .emacs
  78. do
  79. local flag=0
  80. if test -f ~/${file}.new
  81. then
  82. mv ~/${file}.new ~/${file}.old
  83. echo "${file}.new already exist. Rename it to ${file}.old."
  84. flag=1
  85. fi
  86. wget https://dl.dropbox.com/u/1751156/${file} -O ~/${file}.new
  87. local wgetreturn=$?
  88. if test ${flag} -eq 1 -a ${wgetreturn} -eq 0
  89. then
  90. rm ~/${file}.old
  91. echo "${file}.old deleted."
  92. fi
  93. done
  94. }
  95. port-autosync(){
  96. port selfupdate && port sync && port upgrade installed
  97. }
  98. _mygitconfig(){
  99. # export GISTY_DIR="$HOME/dev/gists"
  100. git config --global user.name "10sr"
  101. git config --global user.email sr10@users.sourceforge.jp
  102. git config --global core.autocrlf false
  103. git config --global color.ui auto
  104. git config --global alias.log-all "log --graph --all --color --pretty='%x09%h %cn%x09%s %Cred%d%Creset'"
  105. git config --global alias.log-all2 "log --pretty=format:\"%h %ad | %s%d [%an]\" --graph --date=short"
  106. git config --global alias.log-all3 "log --graph --date-order -C -M --pretty=format:\"<%h> %ad [%an] %Cgreen%d%Creset %s\" --all --date=short"
  107. git config --global alias.cmm "commit -m"
  108. git config --global alias.b "branch"
  109. # git config --global github.token **
  110. }
  111. prompt_function(){ # used by PS1
  112. local lastreturn=$?
  113. if test "${TERM}" == dumb
  114. then
  115. local c1=""
  116. local c2=""
  117. local cdef=""
  118. else
  119. local c1="\e[33m"
  120. local c2="\e[32m"
  121. local cdef="\e[0m"
  122. fi
  123. local pwd=$(echo "${PWD}/" | sed -e "s:${HOME}:~:")
  124. local date=$(LANG=C safe-cmd date +"%a, %d %b %Y %T %z")
  125. local jobnum=$(jobs | wc -l)
  126. local git=$(safe-cmd __git_ps1 [GIT:%s])
  127. printf " [${c1}${pwd}${cdef}]${git}\n"
  128. printf "${c2}${USER}@${HOSTNAME}${cdef} ${date} ${BASH} ${BASH_VERSION}\n"
  129. printf "jobs:${jobnum} last:${lastreturn} "
  130. }
  131. # type date >/dev/null 2>&1 || alias date=":" # "cmd /c echo %time%"
  132. if [ "${EMACS}" = "t" ]; then # emacs shell用
  133. export PS1="\u@\H \d \t \w\nemacs shell\$ "
  134. elif echo "$EMACS" | grep term >/dev/null 2>&1; then # emacs term用
  135. echo "emacs term"
  136. fi
  137. # #Change ANSI Colors
  138. # if [ $TERM = "xterm" ]
  139. # then
  140. # echo -e \
  141. # "\e]P0000000" \
  142. # "\e]P1cd0000" \
  143. # "\e]P200cd00" \
  144. # "\e]P3cdcd00" \
  145. # "\e]P41e90ff" \
  146. # "\e]P5cd00cd" \
  147. # "\e]P600cdcd" \
  148. # "\e]P7353535" \
  149. # "\e]P8666666" \
  150. # "\e]P9ff9999" \
  151. # "\e]Pa99ff99" \
  152. # "\e]Pbffff99" \
  153. # "\e]Pc9999ff" \
  154. # "\e]Pdff99ff" \
  155. # "\e]Pe99ffff" \
  156. # "\e]Pfffffff"
  157. # fi
  158. # printf "\e]P7353535" \
  159. _echocolors(){
  160. echo -e \
  161. "\e[30mBlack\n" \
  162. "\e[31mRed\n" \
  163. "\e[32mGreen\n" \
  164. "\e[33mYellow\n" \
  165. "\e[34mBlue\n" \
  166. "\e[35mMagenta\n" \
  167. "\e[36mCyan\n" \
  168. "\e[37mWhite\n" \
  169. "\e[30;1mBright Black\n" \
  170. "\e[31;1mBright Red\n" \
  171. "\e[32;1mBright Green\n" \
  172. "\e[33;1mBright Yellow\n" \
  173. "\e[34;1mBright Blue\n" \
  174. "\e[35;1mBright Magenta\n" \
  175. "\e[36;1mBright Cyan\n" \
  176. "\e[37;1mBright White\n" \
  177. "\e[0m"
  178. }
  179. ##########################
  180. # system type
  181. # $OSTYPEとか使えるのかな
  182. iswindows(){
  183. uname | grep -iE 'windows|MINGW' >/dev/null 2>&1
  184. }
  185. ismsys(){
  186. :
  187. }
  188. iscygwin(){
  189. :
  190. }
  191. isdarwin(){
  192. uname | grep -E 'Darwin' >/dev/null 2>&1
  193. }
  194. #########################
  195. # for windose
  196. winln(){
  197. if [ $# -eq 0 ]; then
  198. echo "usage: winln TARGET LINK_NAME"
  199. echo "Create a link to TARGET with the name LINK_NAME (that is, TARGET must already exist)."
  200. echo "About other features run 'junction'."
  201. return 1
  202. else
  203. junction "$2" "$1"
  204. fi
  205. }
  206. ########################
  207. if [ "${CYGWIN}" = "t" ]; then # cygwin判定ってどうやるんだろ 多分unameとか使う
  208. # for cygwin
  209. export TMP=/tmp
  210. export TEMP=/tmp
  211. catclip(){
  212. cat /dev/clipboard | tr -d \\r
  213. }
  214. setclip(){
  215. if [ $# -eq 0 ]; then # 引数があるかを判定
  216. sed -e 's/$/\r/' | tee /dev/clipboard
  217. else
  218. cat $1 | sed -e 's/$/\r/' | tee /dev/clipboard
  219. fi
  220. }
  221. # alias setclip="tee /dev/clipboard"
  222. # alias catclip="cat /dev/clipboard | tr -d \\r"
  223. alias cygsu="cygstart /cygwinsetup.exe"
  224. alias emacs="CYGWIN=tty emacs"
  225. echo "cygwin bash"
  226. fi
  227. echo "Japanese letters are 表示可能"
  228. #######################
  229. safe-cmd diskinfo
  230. safe-cmd finger $USER
  231. LANG=C safe-cmd id