Advertisement
sidneystreith1985

bashrc

Mar 4th, 2025
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.49 KB | None | 0 0
  1. # ~/.bashrc
  2.  
  3. # Set the default editor
  4. export EDITOR='vim'
  5.  
  6. # Enable color support for the terminal
  7. force_color_prompt=yes
  8.  
  9. # Git integration: Check for the current git branch and show it in the prompt
  10. parse_git_branch() {
  11.   git branch 2>/dev/null | grep '\*' | sed 's/\* \(.*\)/ (\1)/'
  12. }
  13.  
  14. # Set up the prompt
  15. if [ -n "$force_color_prompt" ]; then
  16.   PS1='\[\e[0;32m\]\u@\h'    # Username and hostname in green
  17.   PS1+='\[\e[0;34m\] \w'      # Current directory in blue
  18.   PS1+='\[\e[0;31m\]$(parse_git_branch)'  # Git branch in red
  19.   PS1+='\[\e[0m\] \$ '         # Reset color and add dollar prompt
  20. else
  21.   PS1='\u@\h \w $(parse_git_branch) \$ '
  22. fi
  23.  
  24. # Enable Git prompt if we're in a Git repo
  25. source /usr/share/git/completion/git-prompt.sh
  26.  
  27. # Add aliases
  28. alias ll='ls -la'
  29. alias gs='git status'
  30. alias gc='git commit'
  31. alias ga='git add'
  32. alias gp='git push'
  33. alias gl='git pull'
  34.  
  35. # Enable colored output for `ls` and `grep`
  36. alias ls='ls --color=auto'
  37. alias grep='grep --color=auto'
  38.  
  39. # Custom PATH (example, add your directories here)
  40. export PATH="$HOME/bin:$PATH"
  41.  
  42. # Use 256-color terminal if supported
  43. if tput setaf 1 &>/dev/null; then
  44.     export TERM=xterm-256color
  45. fi
  46.  
  47. # If we have the `dircolors` program, load it
  48. if [ -f "$HOME/.dir_colors" ]; then
  49.     eval "$(dircolors -b $HOME/.dir_colors)"
  50. fi
  51.  
  52. # Use the 'history' command to show timestamps
  53. HISTTIMEFORMAT="%F %T "
  54.  
  55. # Enable command auto-completion
  56. if [ -f /etc/bash_completion ]; then
  57.     . /etc/bash_completion
  58. fi
  59.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement