Advertisement
mcbazza

modify bash prompt to include IP of tun0 and date

Feb 10th, 2023
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.75 KB | None | 0 0
  1. # By: twitter.com/mcbazza
  2. # On: 2023/02/10
  3. # Desc:
  4. # place this in to ~/.bash_aliases and it will modify your
  5. # bash prompt to include your VPN IP (from tun0) and the date
  6. #   ┌──(bazza[10.10.xx.xx]㉿DESKTOP [2023-02-10])-[~]
  7. #   └─$
  8. #
  9. # Disclaimer: No warranty given, or implied.
  10.  
  11. # Display IP of tun0 (if present)
  12. if [[ ! -d /sys/class/net/tun0 ]]
  13. then
  14.     vpnIP="no-vpn"
  15. else
  16.     vpnIP=$(ifconfig tun0 | grep 'inet ' | awk '{print $2;}')
  17. fi
  18.  
  19. PS1=$prompt_color'┌──${debian_chroot:+($debian_chroot)──}${VIRTUAL_ENV:+(\[\033[0;1m\]$(basename $VIRTUAL_ENV)'$prompt_color')}('$info_color'\u[$vpnIP]${prompt_symbol}\h [\D{%Y-%m-%d}]'$prompt_color')-[\[\033[0;1m\]\w'$prompt_color']\n'$prompt_color'└─'$info_color'\$\[\033[0m\] '
  20.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement