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.

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