Outils pour utilisateurs

Outils du site


informatique:bash

La commande "bash"

La page de man de bash.

Configuration (.bashrc)

Pour la gestion de l'historique, j'ai installé hstr et configuré ceci dans ~/.bashrc :

#Gestion de l'historique
HISTTIMEFORMAT="%F %T: "
HISTCONTROL=ignoredups:erasedups
export HISTFILESIZE=10000        # increase history file size (default is 500)
export HISTSIZE=${HISTFILESIZE}  # increase history size (default is 500)
 
# HSTR configuration
alias hh=hstr                                   # hh to be alias for hstr
#export HSTR_CONFIG=hicolor                     # get more colors
export HSTR_CONFIG=hicolor,raw-history-view     # get more colors
# ensure synchronization between bash memory and history file
export PROMPT_COMMAND="history -n; history -w; history -c; history -r; $PROMPT_COMMAND"
# if this is interactive shell, then bind hstr to Ctrl-r (for Vi mode check doc)
if [[ $- =~ .*i.* ]]; then bind '"\C-r": "\C-a hstr -- \C-j"'; fi
# if this is interactive shell, then bind 'kill last command' to Ctrl-x k
if [[ $- =~ .*i.* ]]; then bind '"\C-xk": "\C-a hstr -k \C-j"'; fi

Dans ~/.inputrc, on rajoute ceci pour pouvoir remonter dans l'historique avec les flèches après avoir tapé un début de commande. Les deux dernières lignes permettent de ne pas devoir taper “tab” deux fois pour avoir les propositions d'autocomplétion et d'ignorer les majuscule pour la complétion.

$include /etc/inputrc
 
"\e[A":history-search-backward
"\e[B":history-search-forward
 
set show-all-if-ambiguous on
set completion-ignore-case on

Sources :

Alias

alias upgrade='sudo apt update && sudo apt upgrade -y'
 
#nnn
#alias nnn='nnn -S -c 1'
 
#cal
alias cal='ncal -M -A 1 -B 1'
alias calendar='ncal -M -A 1 -B 1'
alias khal='khal calendar `date "+%Y-%m-%d"` `date -d next-month "+%Y-%m-%d"`'
 
#NeoVim
alias v='nvim'
alias vi='nvim'
alias vim='nvim'
alias neovim='nvim'
 
#grep
alias grep='grep -i --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
 
#ls
alias ls='ls --color=auto'
alias ll='ls -alF --color=auto'
alias la='ls -alh --color=auto'
alias l='ls -CF --color=auto'
 
# otp
# exemple pour générer un code OTP :
alias otp-site='secret="BLABLABLABLABLA" && oathtool --totp --base32 $secret'
 
#sudo
alias fuck='eval "sudo $(fc -ln -1)"'
 
#pip 
alias pip-up="pip freeze --local | grep -v '^\-e' | cut -d = -f 1  | xargs -n1 pip install -U"
 
#cargo
alias cargo-up='cargo install-update -a'
 
# Add an "alert" alias for long running commands.  Use like so:
#   sleep 10; alert
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
informatique/bash.txt · Dernière modification : 2024/03/19 11:45 de simon