25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

setup.sh 3.9 KiB

11 yıl önce
12 yıl önce
12 yıl önce
12 yıl önce
11 yıl önce
11 yıl önce
11 yıl önce
11 yıl önce
12 yıl önce
12 yıl önce
12 yıl önce
12 yıl önce
12 yıl önce
12 yıl önce
11 yıl önce
11 yıl önce
11 yıl önce
11 yıl önce
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. #!/bin/sh
  2. mkdir -p ~/.my/log
  3. mkdir -p ~/.local/bin
  4. _iswindows(){
  5. case `uname` in
  6. (CYGWIN*) return 0;;
  7. (MINGW*) return 0;;
  8. esac
  9. return 1
  10. }
  11. gen_source_script(){
  12. # _gen_source_script file lines
  13. test $# -eq 2 || return 1
  14. head -n $2 $1 | \grep -v '^#!' | sed -e 's/^..//g'
  15. }
  16. get_install_script(){
  17. local dir="$HOME/.local/bin"
  18. mkdir -p "$dir"
  19. for f in "$@"
  20. do
  21. bn=$(basename "$f")
  22. type $bn >/dev/null 2>&1 || {
  23. if type wget >/dev/null 2>&1
  24. then
  25. wget "$f" -P "$dir/" &&
  26. chmod u+x "${dir}/${bn}"
  27. elif type curl >/dev/null 2>&1
  28. then
  29. curl --url "$f" --output "${dir}/${bn}" &&
  30. chmod u+x "${dir}/${bn}"
  31. fi
  32. }
  33. done
  34. }
  35. install_symlink_script(){
  36. mkdir -p "$HOME/.local/bin/"
  37. for f in "$@"
  38. do
  39. ln -s "$PWD/$f" "$HOME/.local/bin/"
  40. done
  41. }
  42. git_config(){
  43. type git >/dev/null 2>&1 || return 1
  44. _gitconfig="git config --global"
  45. $_gitconfig user.name '10sr'
  46. $_gitconfig user.email '8slashes+git@gmail.com'
  47. $_gitconfig core.autocrlf false
  48. $_gitconfig core.excludesfile '~/.gitignore'
  49. $_gitconfig color.ui auto
  50. $_gitconfig status.relativePaths false
  51. $_gitconfig status.showUntrackedFiles normal
  52. $_gitconfig log.date iso
  53. type xz && \
  54. $_gitconfig tar.txz.command "xz -c"
  55. $_gitconfig alias.graph "log --graph --date-order -C -M --pretty=tformat:\"%C(green)%h%C(reset) %C(white)%ad%C(reset) %C(red)%an%C(reset)%C(yellow)%d%C(reset) %C(white bold)%s%C(reset)\" --all --date=iso -n 499"
  56. $_gitconfig alias.st "status -s -b"
  57. $_gitconfig alias.b "branch"
  58. $_gitconfig alias.sb "show-branch"
  59. $_gitconfig alias.ci "commit --verbose"
  60. $_gitconfig alias.co "checkout"
  61. $_gitconfig alias.cim "commit --verbose -m"
  62. $_gitconfig alias.di "diff --color"
  63. $_gitconfig alias.me "merge --no-ff --stat -v"
  64. $_gitconfig alias.gr "grep -n"
  65. $_gitconfig alias.ls "ls-files"
  66. # $_gitconfig alias.ls "ls-files -v --full-name"
  67. # $_gitconfig alias.ls "status -u -s ."
  68. $_gitconfig alias.sl "!sl"
  69. # $_gitconfig alias.my-ls "ls-files | xargs ls"
  70. # $_gitconfig alias.ll "!git ls-files | xargs ls -l -CFG --color=auto --time-style=long-iso"
  71. $_gitconfig alias.addi "add -i"
  72. $_gitconfig alias.clean-p "!test -z \"\$(git status -s -uno)\""
  73. $_gitconfig alias.new "checkout -b"
  74. #$_gitconfig alias.wc "!git ls-files -z | xargs -0 wc"
  75. # $_gitconfig push.default "simple"
  76. if _iswindows; then
  77. $_gitconfig core.fileMode false
  78. fi
  79. }
  80. install_files(){
  81. src_hilite_src="`pwd`/conf/src-hilite.style"
  82. src_hilite_dst="$HOME/.local/share/source-highlight/src_hilite.style"
  83. #install -D --backup "$src_hilite_src" "$src_hilite_dst"
  84. }
  85. mac_defaults(){
  86. test "`uname`" = Darwin || return 1
  87. # http://appdrill.net/60641/mac-boot-mute.html
  88. #sudo nvram SystemAudioVolume=%80
  89. # add quit entry in menu
  90. defaults write com.apple.finder QuitMenuItem -bool YES
  91. # show full path on titlebar
  92. defaults write com.apple.finder _FXShowPosixPathInTitle -bool YES
  93. # do not show desktop icons
  94. defaults write com.apple.finder CreateDesktop -boolean false
  95. killall Finder
  96. # disable dashboard
  97. #defaults write com.apple.dashboard mcx-disabled -bool YES
  98. }
  99. mac_start_daemon(){
  100. test "`uname`" = Darwin || return 1
  101. test "`launchctl getenv LC_ALL`" = C || sudo launchctl setenv LC_ALL C
  102. if ! (launchctl list | grep com.apple.locate)
  103. then
  104. sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.locate.plist
  105. fi
  106. }
  107. default(){
  108. get_install_script \
  109. https://gist.github.com/10sr/6852317/raw/colortable16.sh \
  110. https://gist.github.com/10sr/6852331/raw/256colors2.pl
  111. git_config
  112. mac_defaults
  113. mac_start_daemon
  114. install_files
  115. }
  116. if test $# -eq 0
  117. then
  118. default
  119. else
  120. "$@"
  121. fi