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.

99 lines
2.4 KiB

  1. #!/bin/bash
  2. ## Requires kal-script
  3. ##
  4. ## More shell configurations (prompt, functions)
  5. ##
  6. mkdir -p /etc/prompt
  7. cat <<EOF > /etc/prompt/prompt.1.rc
  8. PROMPT_COMMAND=""
  9. parse_git_branch() {
  10. ref=\$(git symbolic-ref HEAD 2> /dev/null) || return
  11. echo -en ' (\033[0;32m'\${ref#refs/heads/}'\033[0m)'
  12. }
  13. export PS1="\[\033[0;37m\][\[\033[1;30m\]\u\[\033[0;37m\]@\[\033[1;30m\]\H\[\033[0;37m\]]-[\[\033[1;34m\]\w\[\033[0;37m\]]\\\$(parse_git_branch)\n\[\033[1;37m\]\\$ \[\033[0;37m\]"
  14. EOF
  15. if [ -f /root/.bashrc.pre-install ]; then
  16. cp /root/.bashrc.pre-install /root/.bashrc
  17. else
  18. cp /root/.bashrc /root/.bashrc.pre-install
  19. fi
  20. apt-get install fzf fd-find </dev/null
  21. ln -sf "$(which fdfind)" /usr/local/bin/fd
  22. ## Use C-f instead of C-t for file insertion
  23. sed -r -i.orig 's/C-t/C-f/g' /usr/share/doc/fzf/examples/key-bindings.bash
  24. cat <<EOF >> /root/.bashrc
  25. ## History management
  26. export HISTCONTROL=ignoreboth
  27. export HISTSIZE=500000
  28. export HISTIGNORE="&:[bf]g:exit:ls:history"
  29. export HISTFILESIZE=
  30. export HISTTIMEFORMAT="%Y-%m-%d %T "
  31. shopt -s histappend
  32. ## Prompt easy management
  33. prompt() {
  34. prompt_name="prompt.\$1.rc"
  35. for i in /etc/prompt ~/.prompt; do
  36. [ -f "\$i/\$prompt_name" ] &&
  37. . "\$i/\$prompt_name"
  38. done
  39. }
  40. ## Git log command
  41. function glog() {
  42. git log --graph --pretty=tformat:%C\(yellow\ normal\)%h%Creset\ %C\(blue\ normal\)%an%Creset\ %s\ %Cgreen%d%Creset -n 20 "\$@"
  43. }
  44. prompt 1
  45. PROMPT_COMMAND='history -a' ## after prompt setting as it resets it
  46. ##
  47. ## fzf (apt-get install fzf) and fd (apt-get install fd-find)
  48. ##
  49. if [ -e /usr/share/doc/fzf/examples/key-bindings.bash ]; then
  50. . /usr/share/doc/fzf/examples/key-bindings.bash
  51. fi
  52. if [ -e /usr/share/doc/fzf/examples/completion.bash ]; then
  53. . /usr/share/doc/fzf/examples/completion.bash
  54. fi
  55. #export FZF_DEFAULT_OPTS="--color 'fg:#bbccdd,fg+:#ddeeff,bg:#111820,preview-bg:#223344,border:#778899'"
  56. export FZF_DEFAULT_COMMAND='fd --type f --hidden --follow --exclude .git'
  57. export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
  58. EOF
  59. cat <<EOF >> /root/.bash_profile
  60. ## XXXvlab:
  61. ## http://stackoverflow.com/questions/9652126/bashrc-profile-is-not-loaded-on-new-tmux-session-or-window-why
  62. ## Including ``.bashrc`` if it exists (tmux don't load bashrc, and bashrc
  63. ## don't load profile... so not recursive call)
  64. if [ -f ~/.bashrc ]; then
  65. . ~/.bashrc
  66. fi
  67. EOF