Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.
 
 
 
 
 
 

260 рядки
6.5 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. 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 status.relativePaths false
  105. git config --global status.showUntrackedFiles no
  106. git config --global alias.log-all "log --graph --all --color --pretty='%x09%h %cn%x09%s %Cred%d%Creset'"
  107. git config --global alias.log-all2 "log --pretty=format:\"%h %ad | %s%d [%an]\" --graph --date=short"
  108. git config --global alias.graph "log --graph --date-order -C -M --pretty=format:\"<%h> %ad [%an] %Cgreen%d%Creset %s\" --all --date=short"
  109. git config --global alias.cmm "commit -m"
  110. git config --global alias.b "branch"
  111. git config --global alias.cm "commit --verbose"
  112. }
  113. prompt_function(){ # used by PS1
  114. local lastreturn=$?
  115. if test "${TERM}" == dumb
  116. then
  117. local c1=""
  118. local c2=""
  119. local cdef=""
  120. else
  121. local c1="\e[33m"
  122. local c2="\e[32m"
  123. local cdef="\e[0m"
  124. fi
  125. local pwd=$(echo "${PWD}/" | sed -e "s:${HOME}:~:")
  126. local date=$(LANG=C safe-cmd date +"%a, %d %b %Y %T %z")
  127. local jobnum=$(jobs | wc -l)
  128. local git=$(safe-cmd __git_ps1 [GIT:%s])
  129. printf " [${c1}${pwd}${cdef}]${git}\n"
  130. printf "${c2}${USER}@${HOSTNAME}${cdef} ${date} ${BASH} ${BASH_VERSION}\n"
  131. printf "jobs:${jobnum} last:${lastreturn} "
  132. }
  133. # type date >/dev/null 2>&1 || alias date=":" # "cmd /c echo %time%"
  134. if [ "${EMACS}" = "t" ]; then # emacs shell用
  135. export PS1="\u@\H \d \t \w\nemacs shell\$ "
  136. elif echo "$EMACS" | grep term >/dev/null 2>&1; then # emacs term用
  137. echo "emacs term"
  138. fi
  139. # #Change ANSI Colors
  140. # if [ $TERM = "xterm" ]
  141. # then
  142. # echo -e \
  143. # "\e]P0000000" \
  144. # "\e]P1cd0000" \
  145. # "\e]P200cd00" \
  146. # "\e]P3cdcd00" \
  147. # "\e]P41e90ff" \
  148. # "\e]P5cd00cd" \
  149. # "\e]P600cdcd" \
  150. # "\e]P7353535" \
  151. # "\e]P8666666" \
  152. # "\e]P9ff9999" \
  153. # "\e]Pa99ff99" \
  154. # "\e]Pbffff99" \
  155. # "\e]Pc9999ff" \
  156. # "\e]Pdff99ff" \
  157. # "\e]Pe99ffff" \
  158. # "\e]Pfffffff"
  159. # fi
  160. # printf "\e]P7353535" \
  161. _echocolors(){
  162. echo -e \
  163. "\e[30mBlack\n" \
  164. "\e[31mRed\n" \
  165. "\e[32mGreen\n" \
  166. "\e[33mYellow\n" \
  167. "\e[34mBlue\n" \
  168. "\e[35mMagenta\n" \
  169. "\e[36mCyan\n" \
  170. "\e[37mWhite\n" \
  171. "\e[30;1mBright Black\n" \
  172. "\e[31;1mBright Red\n" \
  173. "\e[32;1mBright Green\n" \
  174. "\e[33;1mBright Yellow\n" \
  175. "\e[34;1mBright Blue\n" \
  176. "\e[35;1mBright Magenta\n" \
  177. "\e[36;1mBright Cyan\n" \
  178. "\e[37;1mBright White\n" \
  179. "\e[0m"
  180. }
  181. ##########################
  182. # system type
  183. # $OSTYPEとか使えるのかな
  184. iswindows(){
  185. uname | grep -iE 'windows|MINGW' >/dev/null 2>&1
  186. }
  187. ismsys(){
  188. :
  189. }
  190. iscygwin(){
  191. :
  192. }
  193. isdarwin(){
  194. uname | grep -E 'Darwin' >/dev/null 2>&1
  195. }
  196. #########################
  197. # for windose
  198. winln(){
  199. if [ $# -eq 0 ]; then
  200. echo "usage: winln TARGET LINK_NAME"
  201. echo "Create a link to TARGET with the name LINK_NAME (that is, TARGET must already exist)."
  202. echo "About other features run 'junction'."
  203. return 1
  204. else
  205. junction "$2" "$1"
  206. fi
  207. }
  208. ########################
  209. if [ "${CYGWIN}" = "t" ]; then # cygwin判定ってどうやるんだろ 多分unameとか使う
  210. # for cygwin
  211. export TMP=/tmp
  212. export TEMP=/tmp
  213. catclip(){
  214. cat /dev/clipboard | tr -d \\r
  215. }
  216. setclip(){
  217. if [ $# -eq 0 ]; then # 引数があるかを判定
  218. sed -e 's/$/\r/' | tee /dev/clipboard
  219. else
  220. cat $1 | sed -e 's/$/\r/' | tee /dev/clipboard
  221. fi
  222. }
  223. # alias setclip="tee /dev/clipboard"
  224. # alias catclip="cat /dev/clipboard | tr -d \\r"
  225. alias cygsu="cygstart /cygwinsetup.exe"
  226. alias emacs="CYGWIN=tty emacs"
  227. echo "cygwin bash"
  228. fi
  229. echo "Japanese letters are 表示可能"
  230. #######################
  231. safe-cmd diskinfo
  232. safe-cmd finger $USER
  233. LANG=C safe-cmd id