💻
IT Documentation
  • 🥳Welcome!
  • General Concepts
    • SCRUM
      • Workflow
    • DevOps
      • What is DevOps?
      • What is TDD? (Test Driven Development)
      • What is CI? (Continuous Integration)
      • What is code coverage?
      • Linting best practices
      • Ephemeral Environments
      • Rolling Deployments
      • Blue/Geen Deployments
      • Canary Deployments
      • What is autoscaling & serverless?
      • What is service discovery?
      • What is Log Aggregation?
      • Metric Monitoring
  • AI
    • ChatGPT
      • Better prompts for ChatGPT
  • Cloud
    • AWS
      • AWS - 40 most common Services
      • AWS CLI Cheatsheet
      • Account & IAM
        • Create AWS Account
      • Lambda
        • Create Lambda function for Lightsail
      • Route 53
        • Set up R53 DNS Entry for GitBook
      • RDS
        • AWS RDS Burst Balance
      • VPC
        • What is a VPC
      • EC2
        • Removing EC2 user from sudo list
        • Create a Windows Gaming VPS
        • Connecting to a AWS EC2 instance
    • Azure
      • Courses
        • AZ900 Course
          • Overview
            • Describe Core Concepts
            • Cloud Models (IaaS, PaaS, SaaS)
          • Benefits of Cloud Computing
          • Cloud Models and Cloud Types
            • Overview of Cloud Models
            • IaaS, PaaS, SaaS
            • The Serverless Model
            • Cloud Types
          • Core Azure Architectural Components
            • Overview
            • Regions & Availability Zones
            • Resource Groups & Subscriptions & Management Groups
            • Resources & Resource Manager
          • Core Resources available
            • Compute Resources
            • Networking Resources
            • Storage Resources
            • Database Services
            • Azure Marketplace
          • Azure Core Solutions
            • Overview
            • Internet of Things (IoT) Solutions
            • Big Data Solutions
            • AI Solutions
            • Azure Functions & Logic Apps and Event Grid
            • DevOps Solutions
          • Azure Management Tools
            • Overview
            • Managing Azure with ARM Templates
            • Azure Monitor & Azure Service Health
          • Azure Security Features
            • Overview
            • Azure Security Center
            • Azure Key Vault & Azure Sentinel
            • Azure Dedicated Hosts
          • Azure Network Security
            • Network Security Group (NGS), Firewall and DDoS Protection
          • Azure Identity Services
            • Overview
            • Benefits
            • Multi-Factor Authentication (MFA)
            • Authentication vs Authorization
          • Azure Governance Features
            • Authentification and RBAC
            • Resource Locks
            • Azure Policy
            • Azure Blueprints
            • Cloud Adoption Framework (CAF)
          • Compliance Features
            • Core tenets of Security, Privacy and Compliance
            • Privacy Statement and Online Service Terms (OST)
            • Trust Center
            • Azure Sovereign Regions
          • Manage Azure Costs
            • Overview
            • Best practices
            • Pricing calculator
            • Azure Cost Management
          • SLA (Service level Agreements)
      • Virtual Machines
        • VM
          • Create a VM in a VNET
          • Azure VM LVM corruption fix
        • VMSS
          • Add SSH Key to VMSS
  • Containerization
    • Docker
      • Docker Cheatsheet
      • Install docker on Debian
      • Docker misc stuff
    • Docker Swarm
      • Docker Swarm Cheatsheet
      • Set up docker swarm
      • Delete docker swarm
      • Mount and bind volumes
      • Deploy Portainer via docker swarm
    • Docker Compose
      • Jenkins via Docker Compose
      • PostgreSQL via Docker Compose
      • Wireguard via Docker Compose & HTTPS
    • Rancher
      • Rancher installation guide
  • Cluster Computing
    • Slurm
      • Job Manager is not responding
      • Create new user
    • OpsCenter
      • Clear old Snapshots
      • Issues listing snapshots with nodetool
  • Database
    • General SQL
      • Database introduction
      • SQL 101
      • SQL Cheatsheet
      • User rights
      • Table Creation
      • SQL Replication - Best practice
      • SQL Database Design
    • MS SQL
      • Update whole table fast
    • Oracle SQL (PL/SQL)
      • Oracle SQL Cheatsheet
      • Oracle SQL - Kill Sessions
    • PostgreSQL
      • Install PostgreSQL
      • Create PostgreSQL Role and Database
      • Managing Postgres with PgAdmin GUI
      • Enable remote access for PostgreSQL
      • Authentication on PostgreSQL
      • Returning in Postgres
    • SQLite
    • Flyway Overview
    • SSRS Overview
    • Cassandra
      • GC OutOfMemoryError
  • DevOps
    • Ansible
      • Ansible Cheatsheet
      • Common Ansible Tasks
    • Git
      • Git 101
      • Git 1kb files
      • Git Commit changes before merge
      • Git Misc
      • Git Markdown
      • Git Clone Repo via SSH
    • Github
      • How to use multiple accounts
      • Delete commits fully
      • Set up git ignore file
    • Github Actions
      • Install self hosted runner
      • Scheduling jobs cron style
      • Passing ENV variable in script
      • SSH to Server
    • GitLab
      • GitLab Cheatsheet
    • Terraform
      • Terraform components
  • Hardware
    • UPS - Njoy
  • IoT
    • Home Assistant
      • Valetudo configs
      • Mini Media Player
      • HACS
    • Valetudo
      • Roborock Gen 1
      • Roborock quick guide
      • Roborock full Valetudo install guide
    • Tasmota
      • Tuya-Convert
    • LibreELEC
      • Quick LibreELEC guide
      • Configure X96 Mini Remote
  • OS
    • Linux
      • Learning guidelines
        • LPIC1 Notes
        • Linux Academy Notes
      • Install / Update Guides
        • Set up Raspberry PI
        • Update Debian 10 (buster) to Debian 11 (bullseye)
      • Increase disk size
      • umask
      • inodes
      • at jobs
      • yum
        • yum update vs yum upgrade
      • find
      • ssh
        • SSH returns: no matching host key type found. Their offer: ssh-rsa
        • Generate Public Key from Private Key
        • Run local bash scripts on remote server
      • crontab
        • Crontab 1st Sunday of every Month
        • Set crontab to execute after restart
      • vim
        • Use sed inside vim
      • networking
        • Check Port
      • fail2ban
      • bashrc
      • lvm
      • fallocate
        • Generate dummy file with actual size
      • openssl
        • Create Certificate via CNF file
        • OpenSSL cert conversion
    • Windows
      • Windows - Get App port by PID
      • Windows - Upgrade Windows build
      • Windows - Server
    • Android
      • Android - Motorola Unlock
      • Android - /E Project
    • PinePhone
      • PinePhone - Instructions for creating a PureOS image for PinePhone
  • Monitoring
    • Nagios
      • CPU threshold value calculation
    • New Relic
      • New Relic Flex Integration
      • NRQL Alerts examples
    • Zabbix
      • Zabbix Proxy not communicating with Windows Server
  • Microsoft Suite
    • Outlook
      • Change View
    • Excel
      • Excel Shortcuts
    • Windows Subset for Linux
      • WSL no internet connection
  • Networking
    • General Networking
      • IP Classes and Subnet Masks
      • Network CIDR Charts - /-es or IP Prefix
      • OSI Model Overview
      • Three Way Handshake & TCP Overview
    • F5
    • Authelia
      • What is Authelia
    • Nginx Proxy Manager
      • Nginx Proxy Manager - DuckDNS going down
    • Nmap
    • OpenWRT
      • Securing OpenWRT
      • OpenWRT - Read logs
      • OpenWRT - Adding DHCP Entry
      • OpenWRT - Wireguard
      • OpenWRT - Set up OpenVPN
      • OpenWRT - Internal DNS Service
      • OpenWRT - Set up new Wifi Interface
      • OpenWRT - Set up VLAN
      • OpenWRT - VPN Policy Routing
    • Pihole
      • Enabling HTTPS for your Pihole Web Interface
      • Edit Pihole DNS entries
    • RVS
      • RVS - Observer Modification
      • RVS - All Parameters
      • RVS - Adding a station
    • Wireguard
    • FTP
      • Connect to FTP anonymously
  • Pen Testing
    • CTF
      • CTF Links
  • Programming
    • Python
      • Classic Python
        • Python Cheatsheet
        • Python Shortcuts
        • Dunder Methods
        • hasattr(), getattr(), delattr()
        • Useful Exceptions
        • Dictionary
        • isinstance()
        • isdigit(), isdecimal(), isalpha()
        • return
        • Functions
        • Lists
        • ord(), chr()
        • squares, twos, odds
        • Bubble sort
        • append() and insert()
        • Bitwise operators
        • while, for & else
        • Arithmetic Operators
        • equal operators
        • Structure Projects
      • Modules
        • Webscraping
          • BeautifulSoup
        • PySimpleGui
          • Fast Crashcourse on PySimpleGui
        • os
        • python-docx
          • Generate DOCX file
        • psycopg2
          • PostgreSQL Connection
        • Pydantic Model vs SQLAlchemy Model
      • Frameworks
        • FastAPI
          • FastAPI Quick overview
          • Installing FastAPI and Dependencies
          • Starting FastAPI
          • Path Operations
          • Creating HTTP Operation paths
          • Send Data via Body of HTTP Request
          • Schema Validation with Pydantic
          • CRUD Operations
          • Storing in Array
          • Retrieve one individual entry
          • Changing response Status Codes
          • Deleting entries
          • Updating entries
          • API Documentation
          • Setup App Database & connect to database
          • FastAPI Response Model via Pydantic
          • Hashing passwords via FastAPI
          • Getting user by ID
          • FastAPI Routers
          • Router Prefix
          • Router Tags
          • JWT Token Basics
          • Login Process
          • Creating Token with OAuth2
          • OAuth2 PasswordRequestForm
          • Verify user is Logged In
          • Protecting Routes
          • Fetching User in Protected Routes
        • SQLAlchemy
          • What is an ORM
          • SQLAlchemy setup
          • Adding CreatedAt Column
          • CRUD via SQLAlchemy
          • Efficient way of passing params in SQLAlchemy
          • Creating Users Table via SQLAlchemy & FastAPI
      • Virtual Environments (venv)
    • General Programming Concepts
    • Interview Questions & Answers
      • General Programming Questions
      • Python Interview Questions Beginner
    • Courses
      • Python - PCAP-31-03 Course
        • Overview & Introduction
          • Exam Syllabus
          • Basics of variables
          • Basic Data Types
          • Basic Arithmetic in Python
          • Indexing and Slicing Strings
          • Basic String Methods
          • Format Method
          • Strings are Immutable
        • Lists, Tuples and Dictionaries
          • Lists
          • Accessing Elements in Nested Lists
          • Finding Index positions in Lists and counting duplicates
          • Tuples
          • Dictionaries
          • Comparison Operators
        • Functions and Variable Scope
          • Creating functions
          • *args and **kwargs
          • Basic Variable scope
          • Scope and Nested functions
        • Control Flow
          • If & Else Statements
          • Elif Statements
          • For Loops
          • Pass Statement in For Loops
          • While Loops
          • Looping and Unpacking with Dictionaries and Tuples
          • Range, Enumerate and Zip Functions
          • More Handy Functions and the Random Package
          • Accepting Input from User
        • Modules, Packages and OOP
          • Revising the Difference between Methods and Functions
          • Classes and Objects
          • Classes Attributes vs Object Attributes
          • Calling Python Code that is Saved in Another File
          • Inheritance and Polymorphism
          • Abstract Classes and Methods
          • Practical Application of OOP
          • Double Under (Dunder) Methods
          • Python Script Files
          • Python Files
          • Understanding the if __name__ == '__main__' Syntax
        • File IO and Exception Handling
          • Exception Handling
          • File IO
          • File IO with Exception Handling
          • OS Module
          • argv Command Line Arguments and the re Module
        • Misc Stuff and Q&A
    • IDE
      • Virtual Studio Code
        • Cheatsheet
    • Postman
      • Postman Overview
      • Create a GET HTTP request
      • HTTP Requests
      • Saving Postman requests
      • Environment Variables
  • Virtualization
    • Proxmox
      • Proxmox Cheatsheet
      • Proxmox Common Errors
      • Install Home Assistant in Proxmox via script
      • Create cloud-init template
      • Install guest-agent on new VM
      • Proxmox post install script
  • Webservers
    • Apache
      • Redirect 301 - Apache to index.html
    • Glassfish
      • Redirect 301 Glassfish
    • Tomcat
      • Useful tomcat files
  • Storage
    • NetApp
      • Netapp Overview
      • How to create symlinks
    • Nextcloud
      • Nextcloud Snap install and S3 Storage Bucket
      • Nextcloud Fail2Ban Regex
      • Set up OnlyOffice on Nextcloud
      • Set up Joplin and CalDav on Nextcloud
  • Software
    • Ansys
      • Ansys missing libraries
      • Ansys install
    • Jboss
      • Jboss process not working
Powered by GitBook
On this page
  1. OS
  2. Linux

bashrc

Interesting profile:

```
# ~/.bashrc
#

# If not running interactively, don't do anything
[[ $- != *i* ]] && return

alias ls='ls --color=auto'
alias ll='ls -al --color=auto'

# ssh connection sections goes here:


echo 'For multiple tabs: "CTRL + (" and "CTRL + )"'


### Profile Customization ###

#di = directory

LS_COLORS=$LS_COLORS:'di=1;33'; export LS_COLORS

#Blue = 34
#Green = 32
#Light Green = 1;32
#Cyan = 36
#Red = 31
#Purple = 35
#Brown = 33
#Yellow = 1;33
#Bold White = 1;37
#Light Grey = 0;37
#Black = 30
#Dark Grey= 1;30

#0   = default colour
#1   = bold
#4   = underlined
#5   = flashing text (disabled on some terminals)
#7   = reverse field (exchange foreground and background color)
#8   = concealed (invisible)

# All Possbile Colors

#30  = black
#31  = red
#32  = green
#33  = orange
#34  = blue
#35  = purple
#36  = cyan
#37  = grey
#90  = dark grey
#91  = light red
#92  = light green
#93  = yellow
#94  = light blue
#95  = light purple
#96  = turquoise
#97  = white



PS1='[\u@\h \W]\$ '

################################################################################
##  FUNCTIONS                                                                 ##
################################################################################

##
##      ARRANGE $PWD AND STORE IT IN $NEW_PWD
##      * The home directory (HOME) is replaced with a ~
##      * The last pwdmaxlen characters of the PWD are displayed
##      * Leading partial directory names are striped off
##              /home/me/stuff -> ~/stuff (if USER=me)
##              /usr/share/big_dir_name -> ../share/big_dir_name (if pwdmaxlen=20)
##
##      Original source: WOLFMAN'S color bash promt
##      https://wiki.chakralinux.org/index.php?title=Color_Bash_Prompt#Wolfman.27s
##
bash_prompt_command() {
        # How many characters of the $PWD should be kept
        local pwdmaxlen=25

        # Indicate that there has been dir truncation
        local trunc_symbol=".."

        # Store local dir
        local dir=${PWD##*/}

        # Which length to use
        pwdmaxlen=$(( ( pwdmaxlen < ${#dir} ) ? ${#dir} : pwdmaxlen ))

        NEW_PWD=${PWD/#$HOME/\~}

        local pwdoffset=$(( ${#NEW_PWD} - pwdmaxlen ))

        # Generate name
        if [ ${pwdoffset} -gt "0" ]
        then
                NEW_PWD=${NEW_PWD:$pwdoffset:$pwdmaxlen}
                NEW_PWD=${trunc_symbol}/${NEW_PWD#*/}
        fi
}




##
##      GENERATE A FORMAT SEQUENCE
##
format_font()
{
        ## FIRST ARGUMENT TO RETURN FORMAT STRING
        local output=$1


        case $# in
        2)
                eval $output="'\[\033[0;${2}m\]'"
                ;;
        3)
                eval $output="'\[\033[0;${2};${3}m\]'"
                ;;
        4)
                eval $output="'\[\033[0;${2};${3};${4}m\]'"
                ;;
        *)
                eval $output="'\[\033[0m\]'"
                ;;
        esac
}



##
## COLORIZE BASH PROMT
##
bash_prompt() {

        ############################################################################
        ## COLOR CODES                                                            ##
        ## These can be used in the configuration below                           ##
        ############################################################################

        ## FONT EFFECT
        local      NONE='0'
        local      BOLD='1'
        local       DIM='2'
        local UNDERLINE='4'
        local     BLINK='5'
        local    INVERT='7'
        local    HIDDEN='8'


        ## COLORS
        local   DEFAULT='9'
        local     BLACK='0'
        local       RED='1'
        local     GREEN='2'
        local    YELLOW='3'
        local      BLUE='4'
        local   MAGENTA='5'
        local      CYAN='6'
        local    L_GRAY='7'
        local    D_GRAY='60'
        local     L_RED='61'
        local   L_GREEN='62'
        local  L_YELLOW='63'
        local    L_BLUE='64'
        local L_MAGENTA='65'
        local    L_CYAN='66'
        local     WHITE='67'


        ## TYPE
        local     RESET='0'
        local    EFFECT='0'
        local     COLOR='30'
        local        BG='40'


        ## 256 COLOR CODES
        local NO_FORMAT="\[\033[0m\]"
        local ORANGE_BOLD="\[\033[1;38;5;208m\]"
        local TOXIC_GREEN_BOLD="\[\033[1;38;5;118m\]"
        local RED_BOLD="\[\033[1;38;5;1m\]"
        local CYAN_BOLD="\[\033[1;38;5;87m\]"
        local BLACK_BOLD="\[\033[1;38;5;0m\]"
        local WHITE_BOLD="\[\033[1;38;5;15m\]"
        local GRAY_BOLD="\[\033[1;90m\]"
        local BLUE_BOLD="\[\033[1;38;5;74m\]"





        ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  
          ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##
        ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ## 



        ##                          CONFIGURE HERE                                ##



        ############################################################################
        ## CONFIGURATION                                                          ##
        ## Choose your color combination here                                     ##
        ############################################################################
        local FONT_COLOR_1=$WHITE
        local BACKGROUND_1=$BLUE
        local TEXTEFFECT_1=$BOLD

        local FONT_COLOR_2=$WHITE
        local BACKGROUND_2=$L_BLUE
        local TEXTEFFECT_2=$BOLD

        local FONT_COLOR_3=$D_GRAY
        local BACKGROUND_3=$WHITE
        local TEXTEFFECT_3=$BOLD

        local PROMT_FORMAT=$BLUE_BOLD


        ############################################################################
        ## EXAMPLE CONFIGURATIONS                                                 ##
        ## I use them for different hosts. Test them out ;)                       ##
        ############################################################################

        ## CONFIGURATION: BLUE-WHITE
        if [ "$HOSTNAME" = dell ]; then
                FONT_COLOR_1=$WHITE; BACKGROUND_1=$BLUE; TEXTEFFECT_1=$BOLD
                FONT_COLOR_2=$WHITE; BACKGROUND_2=$L_BLUE; TEXTEFFECT_2=$BOLD
                FONT_COLOR_3=$D_GRAY; BACKGROUND_3=$WHITE; TEXTEFFECT_3=$BOLD
                PROMT_FORMAT=$CYAN_BOLD
        fi

        ## CONFIGURATION: BLACK-RED
        if [ "$HOSTNAME" = giraff6 ]; then
                FONT_COLOR_1=$WHITE; BACKGROUND_1=$BLACK; TEXTEFFECT_1=$BOLD
                FONT_COLOR_2=$WHITE; BACKGROUND_2=$D_GRAY; TEXTEFFECT_2=$BOLD
                FONT_COLOR_3=$WHITE; BACKGROUND_3=$RED; TEXTEFFECT_3=$BOLD
                PROMT_FORMAT=$RED_BOLD
        fi

        ## CONFIGURATION: RED-BLACK
        #FONT_COLOR_1=$WHITE; BACKGROUND_1=$RED; TEXTEFFECT_1=$BOLD
        #FONT_COLOR_2=$WHITE; BACKGROUND_2=$D_GRAY; TEXTEFFECT_2=$BOLD
        #FONT_COLOR_3=$WHITE; BACKGROUND_3=$BLACK; TEXTEFFECT_3=$BOLD
        #PROMT_FORMAT=$RED_BOLD

        ## CONFIGURATION: CYAN-BLUE
        if [ "$HOSTNAME" = sharkoon ]; then
                FONT_COLOR_1=$BLACK; BACKGROUND_1=$L_CYAN; TEXTEFFECT_1=$BOLD
                FONT_COLOR_2=$WHITE; BACKGROUND_2=$L_BLUE; TEXTEFFECT_2=$BOLD
                FONT_COLOR_3=$WHITE; BACKGROUND_3=$BLUE; TEXTEFFECT_3=$BOLD
                PROMT_FORMAT=$CYAN_BOLD
        fi

        ## CONFIGURATION: GRAY-SCALE
        if [ "$HOSTNAME" = giraff ]; then
                FONT_COLOR_1=$WHITE; BACKGROUND_1=$BLACK; TEXTEFFECT_1=$BOLD
                FONT_COLOR_2=$WHITE; BACKGROUND_2=$D_GRAY; TEXTEFFECT_2=$BOLD
                FONT_COLOR_3=$WHITE; BACKGROUND_3=$L_GRAY; TEXTEFFECT_3=$BOLD
                PROMT_FORMAT=$BLACK_BOLD
        fi

        ## CONFIGURATION: GRAY-CYAN
        if [ "$HOSTNAME" = light ]; then
                FONT_COLOR_1=$WHITE; BACKGROUND_1=$BLACK; TEXTEFFECT_1=$BOLD
                FONT_COLOR_2=$WHITE; BACKGROUND_2=$D_GRAY; TEXTEFFECT_2=$BOLD
                FONT_COLOR_3=$BLACK; BACKGROUND_3=$L_CYAN; TEXTEFFECT_3=$BOLD
                PROMT_FORMAT=$CYAN_BOLD
        fi


        ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  
          ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##
        ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ## 




        ############################################################################
        ## TEXT FORMATING                                                         ##
        ## Generate the text formating according to configuration                 ##
        ############################################################################

        ## CONVERT CODES: add offset
        FC1=$(($FONT_COLOR_1+$COLOR))
        BG1=$(($BACKGROUND_1+$BG))
        FE1=$(($TEXTEFFECT_1+$EFFECT))

        FC2=$(($FONT_COLOR_2+$COLOR))
        BG2=$(($BACKGROUND_2+$BG))
        FE2=$(($TEXTEFFECT_2+$EFFECT))

        FC3=$(($FONT_COLOR_3+$COLOR))
        BG3=$(($BACKGROUND_3+$BG))
        FE3=$(($TEXTEFFECT_3+$EFFECT))

        FC4=$(($FONT_COLOR_4+$COLOR))
        BG4=$(($BACKGROUND_4+$BG))
        FE4=$(($TEXTEFFECT_4+$EFFECT))


        ## CALL FORMATING HELPER FUNCTION: effect + font color + BG color
        local TEXT_FORMAT_1
        local TEXT_FORMAT_2
        local TEXT_FORMAT_3
        local TEXT_FORMAT_4
        format_font TEXT_FORMAT_1 $FE1 $FC1 $BG1
        format_font TEXT_FORMAT_2 $FE2 $FC2 $BG2
        format_font TEXT_FORMAT_3 $FC3 $FE3 $BG3
        format_font TEXT_FORMAT_4 $FC4 $FE4 $BG4


        # GENERATE PROMT SECTIONS
        local PROMT_USER=$"$TEXT_FORMAT_1 \u "
        local PROMT_HOST=$"$TEXT_FORMAT_2 \h "
        local PROMT_PWD=$"$TEXT_FORMAT_3 \${NEW_PWD} "
        local PROMT_INPUT=$"$PROMT_FORMAT "


        ############################################################################
        ## SEPARATOR FORMATING                                                    ##
        ## Generate the separators between sections                               ##
        ## Uses background colors of the sections                                 ##
        ############################################################################

        ## CONVERT CODES
        TSFC1=$(($BACKGROUND_1+$COLOR))
        TSBG1=$(($BACKGROUND_2+$BG))

        TSFC2=$(($BACKGROUND_2+$COLOR))
        TSBG2=$(($BACKGROUND_3+$BG))

        TSFC3=$(($BACKGROUND_3+$COLOR))
        TSBG3=$(($DEFAULT+$BG))


        ## CALL FORMATING HELPER FUNCTION: effect + font color + BG color
        local SEPARATOR_FORMAT_1
        local SEPARATOR_FORMAT_2
        local SEPARATOR_FORMAT_3
        format_font SEPARATOR_FORMAT_1 $TSFC1 $TSBG1
        format_font SEPARATOR_FORMAT_2 $TSFC2 $TSBG2
        format_font SEPARATOR_FORMAT_3 $TSFC3 $TSBG3


        # GENERATE SEPARATORS WITH FANCY TRIANGLE
        local TRIANGLE=$'\uE0B0'
        local SEPARATOR_1=$SEPARATOR_FORMAT_1$TRIANGLE
        local SEPARATOR_2=$SEPARATOR_FORMAT_2$TRIANGLE
        local SEPARATOR_3=$SEPARATOR_FORMAT_3$TRIANGLE



        ############################################################################
        ## WINDOW TITLE                                                           ##
        ## Prevent messed up terminal-window titles                               ##
        ############################################################################
        case $TERM in
        xterm*|rxvt*)
                local TITLEBAR='\[\033]0;\u:${NEW_PWD}\007\]'
                ;;
        *)
                local TITLEBAR=""
                ;;
        esac



        ############################################################################
        ## BASH PROMT                                                             ##
        ## Generate promt and remove format from the rest                         ##
        ############################################################################
        PS1="$TITLEBAR\n${PROMT_USER}${SEPARATOR_1}${PROMT_HOST}${SEPARATOR_2}${PROMT_PWD}${SEPARATOR_3}${PROMT_INPUT}"



        ## For terminal line coloring, leaving the rest standard
        none="$(tput sgr0)"
        trap 'echo -ne "${none}"' DEBUG
}




################################################################################
##  MAIN                                                                      ##
################################################################################

##      Bash provides an environment variable called PROMPT_COMMAND. 
##      The contents of this variable are executed as a regular Bash command 
##      just before Bash displays a prompt. 
##      We want it to call our own command to truncate PWD and store it in NEW_PWD
PROMPT_COMMAND=bash_prompt_command

##      Call bash_promnt only once, then unset it (not needed any more)
##      It will set $PS1 with colors and relative to $NEW_PWD, 
##      which gets updated by $PROMT_COMMAND on behalf of the terminal
bash_prompt
unset bash_prompt



### EOF ###
```
Previousfail2banNextlvm

Last updated 3 years ago