.bash_functions 994 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. # ~/.bash_functions
  2. _bash_history_sync() {
  3. builtin history -a
  4. builtin history -c
  5. builtin history -r
  6. }
  7. history() {
  8. _bash_history_sync
  9. builtin history "$@"
  10. }
  11. man() {
  12. env MANWIDTH=95 \
  13. LESS_TERMCAP_mb="$(tput bold; tput setaf 1)" \
  14. LESS_TERMCAP_md="$(tput bold; tput setaf 32)" \
  15. LESS_TERMCAP_me="$(tput sgr0)" \
  16. LESS_TERMCAP_se="$(tput sgr0)" \
  17. LESS_TERMCAP_so="$(tput bold; tput setaf 220)" \
  18. LESS_TERMCAP_ue="$(tput sgr0)" \
  19. LESS_TERMCAP_us="$(tput smul; tput bold; tput setaf 37)" \
  20. man "$@"
  21. }
  22. function swap() {
  23. local TMPFILE="swaptemp.$$"
  24. [ "$#" -ne 2 ] && echo "swap: 2 arguments needed" && return 1
  25. [ ! -e "$1" ] && echo "swap: $1 does not exist" && return 1
  26. [ ! -e "$2" ] && echo "swap: $2 does not exist" && return 1
  27. mv "$1" "$TMPFILE"
  28. mv "$2" "$1"
  29. mv "$TMPFILE" "$2"
  30. }
  31. function bck() {
  32. [ ! -e "$1" ] && echo "bck: $1 file not found" && return 1
  33. cp "$1" "$1_$(date +%Y%m%d-%H%M%S)"
  34. }