Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 
 
 

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