McTRASH692

. bash_prompt

Aug 31st, 2021
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.03 KB | None | 0 0
  1. # get local ip address
  2. #Ipv4=get_local_ip() {
  3. #           local_ip="$(ip route get 1 | awk -F'src' '{print $2; exit}>
  4. #            local_ip="${local_ip/uid*}"
  5. #            [[ -z "$local_ip" ]] && local_ip="$(ifconfig -a | awk '/br>
  6. #        ;;
  7.  
  8.  
  9.  
  10.  
  11.  
  12. # Define some basic colors using tput (8-bit color: 256 colors)
  13. red="\[$(tput setaf 160)\]"
  14. bright_red="\[$(tput setaf 196)\]"
  15. light_purple="\[$(tput setaf 60)\]"
  16. orange="\[$(tput setaf 172)\]"
  17. blue="\[$(tput setaf 21)\]"
  18. light_blue="\[$(tput setaf 80)\]"
  19. magenta="\[$(tput setaf 162)\]"
  20. hot_pink="\[$(tput setaf 200)\]"
  21. violet="\[$(tput setaf 171)\]"
  22. bold="\[$(tput bold)\]"
  23. start_underline="\[$(tput smul)\]"
  24. end_underline="\[$(tput rmul)\]"
  25. reset="\[$(tput sgr0)\]"
  26.  
  27. # Define basic colors to be used in prompt
  28. ## The color for username (light_blue, for root user: bright_red)
  29. username_color="${reset}${bold}${light_blue}\$([[ \${EUID} == 0 ]] && echo \"${bright_red}\")";
  30. ## Color of @ and ✗ symbols (orange)
  31. at_color=$reset$bold$orange
  32. ## Color of host/pc-name (blue)
  33. host_color=$reset$bold$blue
  34. ## Color of current working directory (light_purple)
  35. directory_color=$reset$light_purple
  36. ## Color for other characters (like the arrow)
  37. etc_color=$reset$red
  38. # If last operation did not succeded, add [✗]- to the prompt
  39. on_error="\$([[ \$? != 0 ]] && echo \"${etc_color}[${at_color}✗${etc_color}]─\")"
  40. # The last symbol in prompt ($, for root user: #)
  41. symbol="${reset}${bold}${bright_red}$(if [[ ${EUID} == 0 ]]; then echo '#'; else echo '$'; fi)"
  42.  
  43. ## Colour of date
  44. date_colour="$reset$bold$magenta"
  45. ## Colour of time
  46. time_colour="$reset$bold$violet"
  47.  
  48.  
  49.  
  50. # Setup the prompt/prefix for linux terminal
  51.  
  52. PS1="${etc_color}┌─${on_error}[";
  53. PS1+="${username_color}ron";
  54. PS1+="${at_color}@";
  55. PS1+="${host_color}\h";
  56. PS1+="${etc_color}]-[";
  57. PS1+="${directory_color}\w";
  58. PS1+="${etc_color}]\n└─╼ ";
  59. PS1+="${date_colour}\d ";
  60. PS1+="${time_colour}\t\n";
  61. PS1+="${etc_color}   └──╼ ";
  62. PS1+="${symbol}${reset}";
  63.  
  64. ## \u=Working directory
  65. ## \n=New Line
  66. ## \u=Username
  67. ## \h=Host
  68. ## \D{%d-%m-%Y}=Date
  69. ## \A=time
  70.  
  71.  
  72. export PS1
Advertisement
Add Comment
Please, Sign In to add comment