Pois é cambada! aqui veremos alguns estilos de PS1 para personalizar o seu .bashrc!.
De imediato vejamos o bashrc padrão do Debian (que pode ser usado em qualquer distro), com suporte a cores…
# ~/.bashrc: executed by bash(1) for non-login shells. # see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) # for examples # If not running interactively, don't do anything case $- in *i*) ;; *) return;; esac # don't put duplicate lines or lines starting with space in the history. # See bash(1) for more options HISTCONTROL=ignoreboth # append to the history file, don't overwrite it shopt -s histappend # for setting history length see HISTSIZE and HISTFILESIZE in bash(1) HISTSIZE=1000 HISTFILESIZE=2000 # check the window size after each command and, if necessary, # update the values of LINES and COLUMNS. shopt -s checkwinsize # If set, the pattern "**" used in a pathname expansion context will # match all files and zero or more directories and subdirectories. #shopt -s globstar # make less more friendly for non-text input files, see lesspipe(1) #[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)" # set variable identifying the chroot you work in (used in the prompt below) if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then debian_chroot=$(cat /etc/debian_chroot) fi # set a fancy prompt (non-color, unless we know we "want" color) case "$TERM" in xterm-color) color_prompt=yes;; esac # uncomment for a colored prompt, if the terminal has the capability; turned # off by default to not distract the user: the focus in a terminal window # should be on the output of commands, not on the prompt force_color_prompt=yes if [ -n "$force_color_prompt" ]; then if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then # We have color support; assume it's compliant with Ecma-48 # (ISO/IEC-6429). (Lack of such support is extremely rare, and such # a case would tend to support setf rather than setaf.) color_prompt=yes else color_prompt= fi fi if [ "$color_prompt" = yes ]; then PS1='${debian_chroot:+($debian_chroot)}[\033[01;32m]u@h[\033[00m]:[\033[01;34m]w[\033[00m]$ ' else PS1='${debian_chroot:+($debian_chroot)}u@h:w$ ' fi unset color_prompt force_color_prompt # If this is an xterm set the title to user@host:dir case "$TERM" in xterm*|rxvt*) PS1="[e]0;${debian_chroot:+($debian_chroot)}u@h: wa]$PS1" ;; *) ;; esac # enable color support of ls and also add handy aliases if [ -x /usr/bin/dircolors ]; then test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" alias ls='ls --color=auto' alias dir='dir --color=auto' alias vdir='vdir --color=auto' alias grep='grep --color=auto' alias fgrep='fgrep --color=auto' alias egrep='egrep --color=auto' fi # some more ls aliases alias ll='ls -l' alias la='ls -A' alias l='ls -CF' # Alias definitions. # You may want to put all your additions into a separate file like # ~/.bash_aliases, instead of adding them here directly. # See /usr/share/doc/bash-doc/examples in the bash-doc package. if [ -f ~/.bash_aliases ]; then . ~/.bash_aliases fi # enable programmable completion features (you don't need to enable # this, if it's already enabled in /etc/bash.bashrc and /etc/profile # sources /etc/bash.bashrc). if ! shopt -oq posix; then if [ -f /usr/share/bash-completion/bash_completion ]; then . /usr/share/bash-completion/bash_completion elif [ -f /etc/bash_completion ]; then . /etc/bash_completion fi fi
A opção que habilita as cores no terminal é a seguinte (já está habilitada):
force_color_prompt=yes
Com este .bashrc, seu terminal ficaria parecido com este::
Outros estilos de PS1.
Adicione quaisquer dos códigos abaixo ao final de seu arquivo ~/.bashrc (alguns deles requerem a instalação do pacote git):
PS1 – I..
#--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # Standard Bash Prompt (PS1) - I. #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# clear cal -3 echo echo -ne "${CYAN}"; echo " " `uptime` echo if [ "$(id -un)" == "root" ]; then PS1='n[e[0;90m][h] [[e[0;33m]w[e[0;90m]]n[e[0;90m][[e[0;31m]u[e[0;90m]] >>[e[0m] ' PS2='[e[0;90m][[e[0;31m]u[e[0;90m]] >>[e[0m] ' else PS2='[e[0;90m][[e[0;32m]u[e[0;90m]] >>[e[0m] ' PS1='n[e[0;90m][h] [[e[0;33m]w[e[0;90m]]$(__git_ps1 " [[e[0;34m]%s[e[0;90m]]")n[e[0;90m][[e[0;32m]u[e[0;90m]] >>[e[0m] ' fi function elite() { local GRAY="[\033[1;30m]" local LIGHT_GRAY="[\033[0;37m]" local CYAN="[\033[0;36m]" local LIGHT_CYAN="[\033[1;36m]" case $TERM in xterm*) local TITLEBAR='[\033]0;u@h:w\007]' ;; *) local TITLEBAR="" ;; esac local GRAD1=$(tty|cut -d/ -f3) PS1="$TITLEBAR $GRAY-$CYAN-$LIGHT_CYAN( $CYANu$GRAY@$CYANh $LIGHT_CYAN)$CYAN-$LIGHT_CYAN( $CYAN#$GRAY/$CYAN$GRAD1 $LIGHT_CYAN)$CYAN-$LIGHT_CYAN( $LIGHT_CYAN)$CYAN-$GRAY- $LIGHT_GRAYn $GRAY-$CYAN-$LIGHT_CYAN( $CYAN$$GRAY:$CYANw $LIGHT_CYAN)$CYAN-$GRAY-$LIGHT_GRAY " PS2="$LIGHT_CYAN-$CYAN-$GRAY-$LIGHT_GRAY " } PROMPT_COMMAND=elite # # END! #
PS1 – II..
#--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # Standard Bash Prompt (PS1) - II. #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# if [ "$(id -un)" == "root" ]; then PS1='n[e[0;90m][h] [[e[0;33m]w[e[0;90m]]n[e[0;90m][[e[0;31m]u[e[0;90m]] >>[e[0m] ' PS2='[e[0;90m][[e[0;31m]u[e[0;90m]] >>[e[0m] ' else PS2='[e[0;90m][[e[0;32m]u[e[0;90m]] >>[e[0m] ' PS1='n[e[0;90m][h] [[e[0;33m]w[e[0;90m]]$(__git_ps1 " [[e[0;34m]%s[e[0;90m]]")n[e[0;90m][[e[0;32m]u[e[0;90m]] >>[e[0m] ' fi # # END! #
PS1 – III..
#--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # Standard Bash Prompt (PS1) - III. #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# PS1="[e[01;31m]┌─[[e[01;35mue[01;31m]]──[[e[00;37m]${HOSTNAME%%.*}[e[01;32m]]:w$[e[01;31m]n[e[01;31m]└──[e[01;36m]>>[e[0m]" # # END! #
PS1 – IV..
#--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # Standard Bash Prompt (PS1) - IV. #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# PROMPT_COMMAND='history -a;echo -en "\033[m\033[38;5;2m"$(( `sed -nu "s/MemFree:[t ]+([0-9]+) kB/1/p" /proc/meminfo`/1024))"\033[38;5;22m/"$((`sed -nu "s/MemTotal:[t ]+([0-9]+) kB/1/Ip" /proc/meminfo`/1024 ))MB"t\033[m\033[38;5;55m$(< /proc/loadavg)\033[m"' PS1='[e[mne[1;30m][$$:$PPID j:![e[1;30m]][e[0;36m] T d [e[1;30m][[e[1;34m]u@H[e[1;30m]:[e[0;37m]${SSH_TTY} [e[0;32m]+${SHLVL}[e[1;30m]] [e[1;37m]w[e[0;37m] n($SHLVL:!)$ ' # # END! #
PS1 – V..
#--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # Standard Bash Prompt (PS1) - V. #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # Stupid Welcome intro. setterm -foreground red -bold on -term linux echo ' _ ' echo ' °v° ** Bem-vindo ao '`cat /etc/*_version`' **' echo ' /(_) ' echo ' ^ ^ ' `date` echo ' ' PS1="[e[01;31m]┌─[[e[01;36mue[01;31m]]──[[e[01;32m]${HOSTNAME%%.*}[e[01;31m]]──[[\033[1;33m]w[\033[1;31m]]-[e[01;33m]$[e[01;31m]n[e[01;31m]└──[e[01;92m]>>[e[0m]" # # END! #
PS1 – VI..
#--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # Standard Bash Prompt (PS1) - VI. #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # Stupid Welcome intro. setterm -foreground red -bold on -term linux echo ' _ ' echo ' °v° ** Bem-vindo ao '`cat /etc/issue`' **' echo ' /(_) ' echo ' ^ ^ ' `date` echo ' ' FGNAMES=('▐▐▐' '▐▐▐' '▐▐▐' '▐▐▐' '▐▐▐' '▐▐▐' '▐▐▐' '▐▐▐') BGNAMES=(' ') for b in $(seq 0 0); do if [ "$b" -gt 0 ]; then bg=$(($b+39)) fi #echo -en "\033[0m ${BGNAMES[$b]}" echo for f in $(seq 0 7); do echo -en "\033[${bg}m\033[$(($f+30))m ${FGNAMES[$f]} " echo -en "\033[${bg}m\033[1;$(($f+30))m ${FGNAMES[$f]} " done echo echo -e "\033[0m" done # # END! #
PS1 – VII..
#--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # Standard Bash Prompt (PS1) - VII. #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # Stupid Welcome intro. setterm -foreground red -bold on -term linux echo ' _ ' echo ' °v° ** Bem-vindo ao Debian '`cat /etc/debian_version`' **' echo ' /(_) ' echo ' ^ ^ ' `date` echo ' ' FGNAMES=('▐▐▐' '▐▐▐' '▐▐▐' '▐▐▐' '▐▐▐' '▐▐▐' '▐▐▐' '▐▐▐') BGNAMES=(' ') for b in $(seq 0 0); do if [ "$b" -gt 0 ]; then bg=$(($b+39)) fi #echo -en "\033[0m ${BGNAMES[$b]}" echo for f in $(seq 0 7); do echo -en "\033[${bg}m\033[$(($f+30))m ${FGNAMES[$f]} " echo -en "\033[${bg}m\033[1;$(($f+30))m ${FGNAMES[$f]} " done echo echo -e "\033[0m" done PROMPT_COMMAND='history -a;echo -en "\033[m\033[38;5;2m"$(( `sed -nu "s/MemFree:[t ]+([0-9]+) kB/1/p" /proc/meminfo`/1024))"\033[38;5;22m/"$((`sed -nu "s/MemTotal:[t ]+([0-9]+) kB/1/Ip" /proc/meminfo`/1024 ))MB"t\033[m\033[38;5;55m$(< /proc/loadavg)\033[m"' PS1='[e[mne[1;30m][$$:$PPID j:![e[1;30m]][e[0;36m] T d [e[1;30m][[e[1;34m]u@H[e[1;30m]:[e[0;37m]${SSH_TTY} [e[0;32m]+${SHLVL}[e[1;30m]] [e[1;37m]w[e[0;37m] n($SHLVL:!)$ ' # # END! #
PS1 – VIII..
#--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # Standard Bash Prompt (PS1) - VIII. #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# PS1="[\033[01;31m]h[\033[00m][\033[01;32m] [\033[01;32m]u [\033[00;33m]wn[\033[01;30m]$ [\033[00m]" # # END! #
PS1 – IX..
#--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# # Standard Bash Prompt (PS1) - IX. #--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--# set_prompt_style () { PS1="┌─[[\033[1;34m]u[\033[1;32m]@[\033[1;34m] h[e[0m]][[e[1;32m]w[e[0m]]n└─╼ " } set_prompt_style # # END! #
like a Ozzy: cheers!.
Com esse Post eu faço uma Limpa no meu Pastebin! Favoritado! Será muto usado! Muito obrigado!
CurtirCurtir
Existe alguma dica para que eu possa fazer um bashrc proprio? Onde posso achar essas opcoes do bash, cores e etc?
CurtirCurtir
Você pode tentar nesse site:
http://bashrcgenerator.com/
CurtirCurtir