Gehe zum Inhalt

fafanet

Zurück zu Blog
Full screen

Dicas bash

September 5, 2014 18:01 , von Unbekannt - 0no comments yet | No one following this article yet.
Viewed 353 times
Ao usar linhas de comando, muitos sysadmins não dão a mínima para shell's coloridos, mas pode ser interessante se você tem tempo livre para colorir seu terminal. Abaixo, as principais configurações, considerando o bash como shell padrão em um sistema com Debian.

Primeiro, dica para colorir saídas de 'man pagens'. Altere o seu ~/.bashrc com as seguintes linhas:
#begin blinking

export LESS_TERMCAP_mb=#39;\E[01;31m'

# begin bold 

export LESS_TERMCAP_md=#39;\E[01;33m' 

# end mode 

export LESS_TERMCAP_me=#39;\E[0m' 

# begin standout-mode - info box 

export LESS_TERMCAP_so=#39;\E[01;41;37m' 

# end standout-mode 

export LESS_TERMCAP_se=#39;\E[0m' 

# begin underline 

export LESS_TERMCAP_us=#39;\E[01;32m' 

# end underline 

export LESS_TERMCAP_ue=#39;\E[0m' 


Feito isso recarregue seu bashrc com o comando source e teste abrindo uma man page.

Colorindo saídas do grep:
alias grep='grep --colour=auto' 
Alterando a variável PS1 do usuário root, destacando e colorindo para outros usuários do sistema. Esta variável pode estar comentada no seu /etc/bash.bashrc:
#
if ${use_color} ; then

if type -P dircolors & >> /dev/null ; then
if [[ -f ~/.dir_colors ]] ; then
eval $(dircolors -b ~/.dir_colors)
elif [[ -f /etc/DIR_COLORS ]] ; then
eval $(dircolors -b /etc/DIR_COLORS)
fi
fi

if [[ ${EUID} == 0 ]] ; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;31m\]\h\[\033[01;34m\] \W \$\[\033[00m\] '
else
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[01;34m\] \w \$\[\033[00m\] '
fi
else
if [[ ${EUID} == 0 ]] ; then
# show root@ when we don't have colors
PS1='\u@\h \W \$ '
else
PS1='\u@\h \w \$ '
fi
fi

Ajustando tamanho do arquivo de históricos:
HISTFILESIZE=4000
HISTSIZE=4000
HISTCONTROL=ignoredups
export HISTFILESIZE
export HISTSIZE
export HISTCONTROL
Impedindo a remoção acidental por redirecionamentos de saida, tipo >, >&, e >>.
set noclobber
Desligando beep
set bell-style none
Fechando o shell por tempo de inatividade
export TMOUT=10000
Ajustando comandos rm, cp e mv para pedir confirmação ao manipular arquivos:
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
Exemplo de .bashrc pode ser obtido em  http://tldp.org/LDP/abs/html/sample-bashrc.html
Referências: man bash, /usr/share/doc/bash/examples


Quelle: http://feedproxy.google.com/~r/silvaetibr/~3/NOlx3uIu1_M/dicas-bash.html

0no comments yet

    Einen Kommentar schreiben

    The highlighted fields are mandatory.

    Wenn Sie ein registrierter Nutzer sind, dann können Sie sich anmelden und automatisch unter Ihrem Namen arbeiten.

    Abbrechen

    fafanet

    fafanet timeline

    redirection forbidden: http://identi.ca/api/statuses/user_timeline/48009.rss -> https://identi.ca/api/statuses/user_timeline/48009.rss

    Mein Netzwerk

    0 Communities

    keine