fork 0k-charms
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.

58 lines
1.2 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. cat <<EOF >> /root/.bashrc
  21. ## History management
  22. export HISTCONTROL=ignoredups
  23. export HISTSIZE=50000
  24. shopt -s histappend
  25. PROMPT_COMMAND='history -a'
  26. ## Prompt easy management
  27. prompt() {
  28. prompt_name="prompt.\$1.rc"
  29. for i in /etc/prompt ~/.prompt; do
  30. [ -f "\$i/\$prompt_name" ] &&
  31. . "\$i/\$prompt_name"
  32. done
  33. }
  34. ## Git log command
  35. function glog() {
  36. git log --graph --pretty=tformat:%C\(yellow\ normal\)%h%Creset\ %C\(blue\ normal\)%an%Creset\ %s\ %Cgreen%d%Creset -n 20 "\$@"
  37. }
  38. prompt 1
  39. EOF