profile-util 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. PATH="$HOME/usr/local/bin:$HOME/bin:$HOME/usr/bin:$PATH"
  2. export PATH
  3. export LC_ALL=en_US.UTF-8
  4. if [[ -z "$BASEPATH" ]]; then
  5. export BASEPATH="$PATH"
  6. fi
  7. alias reset-path="export PATH=\"$BASEPATH\""
  8. detach() {
  9. for i; do [ -L "$i" ] && cp --remove-destination $(readlink "$i") "$i"; done
  10. }
  11. link-tools() {
  12. PATH=$HOME/tools/bin:$HOME/tools/usr/bin:$PATH
  13. LD_LIBRARY_PATH=$HOME/tools/lib:$HOME/tools/usr/lib:$LD_LIBRARY_PATH
  14. export PATH
  15. export LD_LIBRARY_PATH
  16. }
  17. unlink-tools() {
  18. PATH=$(echo $PATH | perl -pne "s/(?<=:)$HOME/tools.*://g")
  19. LD_LIBRARY_PATH=$(echo $LD_LIBRARY_PATH | perl -pne "s/(?<=:)$HOME/tools.*://g")
  20. export PATH
  21. export LD_LIBRARY_PATH
  22. }
  23. alias listall="list -A"
  24. alias git-graph="git log --graph --pretty=oneline --abbrev-commit --decorate --all"
  25. alias disk-usage="ls -A | xargs du -shc | sort -h"
  26. alias reload="source ~/.bashrc"
  27. alias crontab="VIM_CRONTAB=true crontab"
  28. refreshterm() {
  29. clear
  30. uname -a
  31. cat /etc/motd
  32. echo ""
  33. pwd
  34. list
  35. }
  36. _mkcd_fun() {
  37. if [ ! -d "$2" ]; then
  38. if [ -e "$2" ]; then
  39. echo "mkcd: file exists and is not a directory"
  40. exit
  41. else
  42. $1 "$2"
  43. fi
  44. fi
  45. cd "$2"
  46. }
  47. alias mkcd="_mkcd_fun mkdir"
  48. mkdirs() {
  49. mkdir -p "$1"
  50. }
  51. alias mkcds="_mkcd_fun mkdirs"
  52. alias diffr="diff --ignore-blank-lines --minimal --side-by-side --report-identical-files --suppress-common-lines"
  53. alias diffl="diff --changed-group-format='%<' --unchanged-group-format=''"
  54. _recall_fun() {
  55. if [ -z "$1" ]; then echo "recall: usage: recall string"; return 1; fi
  56. history | cut -c 8- | grep --extended-regexp "$1" | \
  57. grep --invert-match --extended-regexp "^(history|recall|redo)" | sort | uniq
  58. }
  59. redo() {
  60. IFS=$'\n'
  61. hist=($(_recall_fun $1))
  62. for ((i=0; i<${#hist[@]}; i++));
  63. do
  64. echo "[$i] ${hist[$i]}"
  65. done
  66. printf "Index: "
  67. read idx
  68. if [[ $idx =~ ^[0-9]+$ ]];
  69. then
  70. eval "${hist[$idx]}"
  71. fi
  72. unset IFS
  73. }
  74. recall(){
  75. _recall_fun $1 | sed 's/^/ /'
  76. }
  77. clear() {
  78. /usr/bin/clear
  79. if [[ ! -z "${TMUX}" ]]; then tmux clear-history; fi
  80. }
  81. swap() {
  82. if [[ $# -ne 2 ]]; then
  83. echo "swap file1 file2" >&2
  84. return 1
  85. fi
  86. local tmpfile=$(mktemp)
  87. mv "${1}" "${tmpfile}"
  88. mv "${2}" "${1}"
  89. mv "${tmpfile}" "${2}"
  90. }
  91. alias coms="${HOME}/tools/comstore/commands.sh"
  92. if [[ $(uname) == "Darwin" ]]; then # OSX / FreeBSD
  93. . ${HOME}/.profile-bsd
  94. else
  95. . ${HOME}/.profile-linux
  96. fi
  97. source ${HOME}/.profile-p4