Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

vor 13 Jahren
vor 13 Jahren
vor 13 Jahren
vor 13 Jahren
vor 13 Jahren
vor 13 Jahren
vor 13 Jahren
vor 13 Jahren
vor 13 Jahren
vor 13 Jahren
vor 13 Jahren
vor 13 Jahren
vor 13 Jahren
vor 13 Jahren
vor 13 Jahren
vor 13 Jahren
vor 13 Jahren
vor 13 Jahren
vor 13 Jahren
vor 13 Jahren
vor 13 Jahren
vor 13 Jahren
vor 13 Jahren
vor 13 Jahren
vor 13 Jahren
vor 13 Jahren
vor 13 Jahren
vor 13 Jahren
vor 13 Jahren
vor 13 Jahren
vor 13 Jahren
vor 13 Jahren
vor 13 Jahren
vor 13 Jahren
vor 13 Jahren
vor 13 Jahren
vor 13 Jahren
vor 13 Jahren
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  1. #!/bin/bash
  2. # 外部ファイルの読み込み
  3. # test -r ~/filepath && . ~/filepath
  4. # ln SRC DST
  5. ##########################################
  6. safe-cmd(){
  7. type $1 >/dev/null 2>&1 && "$@"
  8. }
  9. test -r /etc/bashrc && . /etc/bashrc
  10. export PS1="\$(prompt_function)\$ "
  11. # PROMPT_COMMAND=prompt_function
  12. export PAGER="less"
  13. export EDITOR="vim"
  14. export VISUAL=$EDITOR
  15. export LESS="-iRM"
  16. # export LC_MESSAGES="C"
  17. # export LANG=ja_JP.UTF-8
  18. # export CDPATH=".:~" # 使い方がよく分からない
  19. export GIT_PAGER=$PAGER
  20. export GIT_EDITOR=$EDITOR
  21. alias ls="ls -CFG $(test "$TERM" == dumb || echo --color=auto) --time-style=long-iso"
  22. alias ll="ls -l"
  23. alias la="ls -A"
  24. alias lla="ls -Al"
  25. alias vl=/usr/share/vim/vimcurrent/macros/less.sh
  26. alias em="emacs -nw"
  27. alias apt-get="sudo apt-get"
  28. alias aptin="apt-get install"
  29. alias aptsearch="apt-cache search"
  30. alias aptshow="apt-cache show"
  31. alias ut="slogin t110414@un001.ecc.u-tokyo.ac.jp"
  32. alias rand="echo \$RANDOM"
  33. alias xunp="file-roller -h"
  34. alias pacome="sudo \paco -D"
  35. alias destroy="rm -rf"
  36. alias psall="ps auxww"
  37. alias g=git
  38. alias q=exit
  39. alias pcalc="python -i -c 'from math import *' "
  40. # alias diff="$(type colordiff >/dev/null 2>&1 && test $TERM != dumb && echo color)diff -u"
  41. # type trash >/dev/null 2>&1 && alias rm=trash
  42. bak(){
  43. for file in "$@"
  44. do
  45. cp ${file} ${file}.bak
  46. done
  47. }
  48. di(){
  49. if type colordiff >/dev/null 2>&1 && test $TERM != dumb
  50. then
  51. local diffcmd=colordiff
  52. else
  53. local diffcmd=diff
  54. fi
  55. ${diffcmd} -u "$@" | ${PAGER}
  56. }
  57. memo(){
  58. _MEMO="# $*\n"
  59. }
  60. rmmemo(){
  61. _MEMO=""
  62. }
  63. throw-away(){
  64. for file in "$@"
  65. do
  66. mv $file ~/bu/tb
  67. done
  68. }
  69. mkcd(){
  70. mkdir $1
  71. cd $1
  72. }
  73. mkunfddir(){ # create dir if unfound. ?
  74. test -e "$1" || mkdir "$1"
  75. }
  76. gitls(){
  77. for file in `\ls`
  78. do
  79. :
  80. done
  81. }
  82. catclip(){
  83. if iscygwin
  84. then
  85. cat /dev/clipboard | tr -d \\r
  86. else
  87. xclip -o -selection "clipboard"
  88. fi
  89. }
  90. setclip(){
  91. if iscygwin
  92. then
  93. if test $# -eq 0
  94. then
  95. sed -e 's/$/\r/' | tee /dev/clipboard
  96. else
  97. cat "$@" | sed -e 's/$/\r/' | tee /dev/clipboard
  98. fi
  99. else
  100. if test $# -eq 0
  101. then
  102. xclip -i -f -selection "primary" | xclip -i -f -selection "clipboard"
  103. else
  104. cat "$@" | xclip -i -f -selection "primary" | xclip -i -f -selection "clipboard"
  105. fi
  106. fi
  107. }
  108. p(){
  109. "$@" | $PAGER
  110. }
  111. c(){
  112. "$@" | cat
  113. }
  114. o(){
  115. if [ $# -eq 0 ]
  116. then
  117. local f=.
  118. else
  119. local f="$1"
  120. fi
  121. if iswindows
  122. then
  123. cmd.exe //c start "" "$f"
  124. elif isdarwin
  125. then
  126. open "$f"
  127. else
  128. xdg-open "$f"
  129. fi
  130. }
  131. convmv-sjis2utf8-test(){
  132. convmv -r -f sjis -t utf8 *
  133. }
  134. convmv-sjis2utf8-notest(){
  135. convmv -r -f sjis -t utf8 * --notest
  136. }
  137. dl-my-init-files(){
  138. for file in .bashrc .vimrc .emacs
  139. do
  140. local flag=0
  141. if test -f ~/${file}.new
  142. then
  143. mv ~/${file}.new ~/${file}.old
  144. echo "${file}.new already exist. Rename it to ${file}.old."
  145. flag=1
  146. fi
  147. wget https://dl.dropbox.com/u/1751156/${file} -O ~/${file}.new
  148. local wgetreturn=$?
  149. if test ${flag} -eq 1 -a ${wgetreturn} -eq 0
  150. then
  151. rm ~/${file}.old
  152. echo "${file}.old deleted."
  153. fi
  154. done
  155. }
  156. port-autosync(){
  157. port selfupdate && port sync && port upgrade installed
  158. }
  159. _mygitconfig(){
  160. git config --global user.name "10sr"
  161. git config --global user.email sr10@users.sourceforge.jp
  162. git config --global core.autocrlf false
  163. git config --global color.ui auto
  164. git config --global status.relativePaths false
  165. git config --global status.showUntrackedFiles no
  166. git config --global alias.graph "log --graph --date-order -C -M --pretty=format:\"<%h> %ad [%an] %Cgreen%d%Creset %s\" --all --date=short"
  167. git config --global alias.st "status -s"
  168. git config --global alias.b "branch"
  169. git config --global alias.ci "commit --verbose"
  170. git config --global alias.co "checkout"
  171. git config --global alias.cim "commit --verbose -m"
  172. git config --global alias.di "diff"
  173. git config --global alias.me "merge --no-ff --stat -v"
  174. git config --global alias.ls "!git ls-files | xargs ls -CFG --color=auto --time-style=long-iso"
  175. git config --global alias.ll "!git ls-files | xargs ls -l -CFG --color=auto --time-style=long-iso"
  176. git config --global alias.addi "add -i"
  177. }
  178. __my_parse_svn_branch() {
  179. local LANG=C
  180. local svn_url=$(svn info 2>/dev/null | sed -ne 's#^URL: ##p')
  181. local svn_repository_root=$(svn info 2>/dev/null | sed -ne 's#^Repository Root: ##p')
  182. echo ${svn_url} | sed -e 's#^'"${svn_repository_root}"'##g' | awk '{print $1}'
  183. }
  184. __my_svn_ps1(){
  185. local svn_branch=$(__my_parse_svn_branch)
  186. test "${svn_branch}" == "" || echo ${svn_branch} | xargs printf "$1"
  187. }
  188. prompt_function(){ # used by PS1
  189. local lastreturn=$?
  190. if test "${TERM}" == dumb
  191. then
  192. local c1=""
  193. local c2=""
  194. local c3=""
  195. local cdef=""
  196. else
  197. local c1="\e[33m"
  198. local c2="\e[36m"
  199. local c3="\e[37m"
  200. local cdef="\e[0m"
  201. fi
  202. iscygwin || {
  203. local pwd=$(echo "${PWD}/" | sed -e "s:${HOME}:~:")
  204. local oldpwd=$(echo "${OLDPWD}/" | sed -e "s:${HOME}:~:")
  205. local date=$(LANG=C safe-cmd date +"%a, %d %b %Y %T %z")
  206. local jobnum=$(jobs | wc -l)
  207. }
  208. local git=$(safe-cmd __git_ps1 [GIT:%s])
  209. local svn=$(type svn >/dev/null 2>&1 && safe-cmd __my_svn_ps1 [SVN:%s])
  210. printf "${_MEMO}"
  211. printf " [${c1}${pwd}${cdef}<${c3}${oldpwd}${cdef}]${git}${svn}\n"
  212. printf "${c2}${USER}@${HOSTNAME}${cdef} ${date} ${BASH} ${BASH_VERSION}\n"
  213. printf "shlv:${SHLVL} jobs:${jobnum} last:${lastreturn} "
  214. }
  215. # type date >/dev/null 2>&1 || alias date=":" # "cmd /c echo %time%"
  216. if [ "${EMACS}" = "t" ]; then # emacs shell用
  217. : export PS1="\u@\H \d \t \w\nemacs shell\$ "
  218. elif echo "$EMACS" | grep term >/dev/null 2>&1; then # emacs term用
  219. echo "emacs term"
  220. fi
  221. #Change ANSI Colors
  222. _chengecolors(){
  223. echo -e \
  224. "\e]P0000000" \
  225. "\e]P1cd0000" \
  226. "\e]P200cd00" \
  227. "\e]P3cdcd00" \
  228. "\e]P41e90ff" \
  229. "\e]P5cd00cd" \
  230. "\e]P600cdcd" \
  231. "\e]P7353535" \
  232. "\e]P8666666" \
  233. "\e]P9ff9999" \
  234. "\e]Pa99ff99" \
  235. "\e]Pbffff99" \
  236. "\e]Pc9999ff" \
  237. "\e]Pdff99ff" \
  238. "\e]Pe99ffff" \
  239. "\e]Pfffffff"
  240. }
  241. # printf "\e]P7353535" \
  242. _echocolors(){
  243. echo -e \
  244. "\e[30mBlack\n" \
  245. "\e[31mRed\n" \
  246. "\e[32mGreen\n" \
  247. "\e[33mYellow\n" \
  248. "\e[34mBlue\n" \
  249. "\e[35mMagenta\n" \
  250. "\e[36mCyan\n" \
  251. "\e[37mWhite\n" \
  252. "\e[30;1mBright Black\n" \
  253. "\e[31;1mBright Red\n" \
  254. "\e[32;1mBright Green\n" \
  255. "\e[33;1mBright Yellow\n" \
  256. "\e[34;1mBright Blue\n" \
  257. "\e[35;1mBright Magenta\n" \
  258. "\e[36;1mBright Cyan\n" \
  259. "\e[37;1mBright White\n" \
  260. "\e[0m"
  261. }
  262. safe-cmd stty stop undef # unbind C-s to stop displaying output
  263. ##########################
  264. # system type
  265. # $OSTYPEとか使えるのかな
  266. iswindows(){
  267. # uname | grep -iE 'windows|MINGW' >/dev/null 2>&1
  268. iscygwin || ismsys
  269. }
  270. ismsys(){
  271. uname | grep -E "^MINGW32" >/dev/null 2>&1
  272. }
  273. iscygwin(){
  274. uname | grep -E "^CYGWIN" >/dev/null 2>&1
  275. }
  276. isdarwin(){
  277. uname | grep -E 'Darwin' >/dev/null 2>&1
  278. }
  279. #########################
  280. # for windose
  281. winln(){
  282. if test $# -eq 0
  283. then
  284. {
  285. echo "usage: winln TARGET LINK_NAME"
  286. echo "Create a link to TARGET with the name LINK_NAME (that is, TARGET must already exist)."
  287. echo "About other features run 'junction'."
  288. } 1>&2
  289. return 1
  290. else
  291. junction "$2" "$1"
  292. fi
  293. }
  294. ########################
  295. if iscygwin; then
  296. # for cygwin
  297. export TMP=/tmp
  298. export TEMP=/tmp
  299. : alias setclip="tee /dev/clipboard"
  300. : alias catclip="cat /dev/clipboard | tr -d \\r"
  301. alias cygsu="cygstart /cygwinsetup.exe"
  302. alias emacs="CYGWIN=tty emacs -nw"
  303. echo "cygwin bash"
  304. fi
  305. if iswindows; then
  306. # export PS1=" \[\e[32m\]\u@\H \[\e[33m\]\w\[\e[0m\] \d \t\n\s \# \j \$ "
  307. export PS1=" [\[\e[33m\]\w\[\e[0m\]]\n\[\e[32m\]\u@\H\[\e[0m\] \d \t \s.\v\nhist:\# jobs:\j \$ "
  308. alias ls="ls -CFG $(test "$TERM" == dumb || echo --color=auto)"
  309. fi
  310. #######################
  311. echo "Japanese letters are 表示可能"
  312. safe-cmd diskinfo
  313. type xrandr >/dev/null 2>&1 && {
  314. xrandr | grep --color=never ^Screen
  315. }
  316. safe-cmd finger $USER
  317. LANG=C safe-cmd id