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.

.bashrc 7.0 KiB

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