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.
 
 
 
 
 
 

245 lines
6.3 KiB

  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. o(){
  41. if [ $# -eq 0 ]; then
  42. local f=.
  43. else
  44. local f="$1"
  45. fi
  46. if iswindows; then
  47. cmd.exe //c start "" "$f"
  48. elif isdarwin; then
  49. open "$f"
  50. else
  51. xdg-open "$f"
  52. fi
  53. }
  54. sgcc(){
  55. if iswindows; then
  56. gcc -o win.$1.exe $1
  57. else
  58. gcc -o $(uname).$1.out $1
  59. fi
  60. }
  61. sggcc(){
  62. gcc -g -o $(uname).$1.out $1
  63. }
  64. slmggcc(){
  65. gcc -g -lm -o $(uname).$1.out $1
  66. }
  67. convmv-sjis2utf8-test(){
  68. convmv -r -f sjis -t utf8 *
  69. }
  70. convmv-sjis2utf8-notest(){
  71. convmv -r -f sjis -t utf8 * --notest
  72. }
  73. dl-my-init-files(){
  74. for file in .bashrc .vimrc .emacs
  75. do
  76. local flag=0
  77. if test -f ~/${file}.new
  78. then
  79. mv ~/${file}.new ~/${file}.old
  80. echo "${file}.new already exist. Rename it to ${file}.old."
  81. flag=1
  82. fi
  83. wget https://dl.dropbox.com/u/1751156/${file} -O ~/${file}.new
  84. local wgetreturn=$?
  85. if test ${flag} -eq 1 -a ${wgetreturn} -eq 0
  86. then
  87. rm ~/${file}.old
  88. echo "${file}.old deleted."
  89. fi
  90. done
  91. }
  92. port-auto(){
  93. port selfupdate && port sync && port upgrade installed
  94. }
  95. mygitconfig(){
  96. # export GISTY_DIR="$HOME/dev/gists"
  97. git config --global user.name "10sr"
  98. git config --global user.email sr10@users.sourceforge.jp
  99. git config --global core.autocrlf false
  100. git config --global color.ui auto
  101. git config --global alias.log-all "log --graph --all --color --pretty='%x09%h %cn%x09%s %Cred%d%Creset'"
  102. git config --global alias.log-all2 'log --pretty=format:\"%h %ad | %s%d [%an]\" --graph --date=short'
  103. git config --global alias.log-all3 "log --graph --date-order -C -M --pretty=format:\"<%h> %ad [%an] %Cgreen%d%Creset %s\" --all --date=short"
  104. git config --global alias.cmm "commit -m"
  105. # git config --global github.token **
  106. }
  107. prompt_function(){ # used by PS1
  108. local lastreturn=$?
  109. if test "${TERM}" == dumb
  110. then
  111. local c1=""
  112. local c2=""
  113. local cdef=""
  114. else
  115. local c1="\e[33m"
  116. local c2="\e[32m"
  117. local cdef="\e[0m"
  118. fi
  119. local pwd=$(echo "${PWD}/" | sed -e "s:${HOME}:~:")
  120. local date=$(LANG=C date +"%a, %d %b %Y %T %z")
  121. local jobnum=$(jobs | wc -l)
  122. type __git_ps1 >/dev/null 2>&1 && local gitb=$(__git_ps1 GIT:%s)
  123. type git >/dev/null 2>&1 && local git="[${gitb}]"
  124. printf " [${c1}${pwd}${cdef}]${git}\n"
  125. printf "${c2}${USER}@${HOSTNAME}${cdef} ${date} ${BASH} ${BASH_VERSION}\n"
  126. printf "jobs:${jobnum} last:${lastreturn} "
  127. }
  128. # type date >/dev/null 2>&1 || alias date=":" # "cmd /c echo %time%"
  129. if [ "${EMACS}" = "t" ]; then # emacs shell用
  130. export PS1="\u@\H \d \t \w\nemacs shell\$ "
  131. elif echo "$EMACS" | grep term >/dev/null 2>&1; then # emacs term用
  132. echo "emacs term"
  133. fi
  134. # #Change ANSI Colors
  135. # if [ $TERM = "xterm" ]
  136. # then
  137. # echo -e \
  138. # "\e]P0000000" \
  139. # "\e]P1cd0000" \
  140. # "\e]P200cd00" \
  141. # "\e]P3cdcd00" \
  142. # "\e]P41e90ff" \
  143. # "\e]P5cd00cd" \
  144. # "\e]P600cdcd" \
  145. # "\e]P7353535" \
  146. # "\e]P8666666" \
  147. # "\e]P9ff9999" \
  148. # "\e]Pa99ff99" \
  149. # "\e]Pbffff99" \
  150. # "\e]Pc9999ff" \
  151. # "\e]Pdff99ff" \
  152. # "\e]Pe99ffff" \
  153. # "\e]Pfffffff"
  154. # fi
  155. # printf "\e]P7353535" \
  156. _echocolors(){
  157. echo -e \
  158. "\e[30mBlack\n" \
  159. "\e[31mRed\n" \
  160. "\e[32mGreen\n" \
  161. "\e[33mYellow\n" \
  162. "\e[34mBlue\n" \
  163. "\e[35mMagenta\n" \
  164. "\e[36mCyan\n" \
  165. "\e[37mWhite\n" \
  166. "\e[30;1mBright Black\n" \
  167. "\e[31;1mBright Red\n" \
  168. "\e[32;1mBright Green\n" \
  169. "\e[33;1mBright Yellow\n" \
  170. "\e[34;1mBright Blue\n" \
  171. "\e[35;1mBright Magenta\n" \
  172. "\e[36;1mBright Cyan\n" \
  173. "\e[37;1mBright White\n" \
  174. "\e[0m"
  175. }
  176. ##########################
  177. # system type
  178. # $OSTYPEとか使えるのかな
  179. iswindows(){
  180. uname | grep -iE 'windows|MINGW' >/dev/null 2>&1
  181. }
  182. isdarwin(){
  183. uname | grep -E 'Darwin' >/dev/null 2>&1
  184. }
  185. #########################
  186. # for windose
  187. winln(){
  188. if [ $# -eq 0 ]; then
  189. echo "usage: winln TARGET LINK_NAME"
  190. echo "Create a link to TARGET with the name LINK_NAME (that is, TARGET must already exist)."
  191. echo "About other features run 'junction'."
  192. return 1
  193. else
  194. junction "$2" "$1"
  195. fi
  196. }
  197. ########################
  198. if [ "${CYGWIN}" = "t" ]; then # cygwin判定ってどうやるんだろ 多分unameとか使う
  199. # for cygwin
  200. export TMP=/tmp
  201. export TEMP=/tmp
  202. catclip(){
  203. cat /dev/clipboard | tr -d \\r
  204. }
  205. setclip(){
  206. if [ $# -eq 0 ]; then # 引数があるかを判定
  207. sed -e 's/$/\r/' | tee /dev/clipboard
  208. else
  209. cat $1 | sed -e 's/$/\r/' | tee /dev/clipboard
  210. fi
  211. }
  212. # alias setclip="tee /dev/clipboard"
  213. # alias catclip="cat /dev/clipboard | tr -d \\r"
  214. alias cygsu="cygstart /cygwinsetup.exe"
  215. alias emacs="CYGWIN=tty emacs"
  216. echo "cygwin bash"
  217. fi
  218. echo "Japanese letters are 表示可能"
  219. #######################
  220. type diskinfo >/dev/null 2>&1 && diskinfo
  221. finger $USER
  222. LANG=C id