Skip to content

Latest commit

 

History

History
137 lines (117 loc) · 3.79 KB

Bash.org

File metadata and controls

137 lines (117 loc) · 3.79 KB

Bash Configuration

If not running interactively, don’t do anything.

case $- in
    *i*) ;;
    *) return;;
esac

Allow automatic cd (change directory), i.e., typing just the directory name is enough.

shopt -s autocd

Check the window size after each command and, if necessary, update the values of LINES and COLUMNS.

shopt -s checkwinsize

Globstar matching.

shopt -s globstar

Enable completion features for the following commands.

complete -c man which whereis
complete -cf sudo

Update “PATH” variable so scripts inside .local/bin/global can be executed.

PATH="$PATH:$HOME/.local/bin/global"

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

Bash prompt configuration.

if [ "$EUID" -ne 0 ]
then
    export PS1="\[$(tput bold)\]\[$(tput setaf 1)\][\[$(tput setaf 3)\]\u\[$(tput setaf 2)\]@\[$(tput setaf 4)\]\h\[$(tput setaf 7)\] Arch Linux  \[$(tput setaf 5)\]\w\[$(tput setaf 1)\]]\[$(tput setaf 7)\]\n  \\$ \[$(tput sgr0)\]"
else
    export PS1="\[$(tput bold)\]\[$(tput setaf 1)\][\[$(tput setaf 3)\]ROOT\[$(tput setaf 2)\]@\[$(tput setaf 4)\]$(hostname | awk '{print toupper($0)}')\[$(tput setaf 7)\] Arch Linux  \[$(tput setaf 5)\]\w\[$(tput setaf 1)\]]\[$(tput setaf 7)\]\n  \\$ \[$(tput sgr0)\]"
fi

Configure bash history.

export HISTCONTROL=ignoreboth
shopt -s histappend
export HISTSIZE=5000
export HISTFILESIZE=5000

Enable colors for the following commands.

# Colores
eval "$(dircolors)"
alias ls="ls -hN --color=auto --group-directories-first -v --time-style='+%d %b %H:%M'"
alias l="exa --icons --group-directories-first"
alias ll="l -lag"
alias grep="grep --color"
alias diff="diff --color"

Set aliases for basic commands (among them, make mv and cp interactive).

alias sp-Syu="sp -Syu --noconfirm && pkill -RTMIN+1 i3blocks"
alias ..='cd ..'
alias ...='cd ../../'
alias mv="mv -i"
alias cp="cp -i"

More aliases.

alias cpc="xclip -selection clipboard"
alias yt="youtube-dl --add-metadata -ic --output \"%(uploader)s%(title)s.%(ext)s\"" # Download video link
alias yta="yt -x -f bestaudio/best" # Download only audio

Set up XDG Base Directory specification.

export XDG_CONFIG_HOME="$HOME/.config"
export XDG_CACHE_HOME="$HOME/.cache"
export XDG_DATA_HOME="$HOME/.local/share/"

Cleanup programs.

export LESSHISTFILE=-
export HISTFILE="$XDG_DATA_HOME"/history
export INPUTRC="$XDG_CONFIG_HOME"/shell/inputrc
export UNISON="$XDG_CONFIG_HOME"/unison
export XAUTHORITY="$XDG_RUNTIME_DIR"/Xauthority
export XINITRC="$XDG_CONFIG_HOME"/X11/xinitrc
export GNUPGHOME="$XDG_DATA_HOME"/gnupg

Use neovim for vim if present.

[ -x "$(command -v nvim)" ] && alias vim="nvim" vimdiff="nvim -d"
export EDITOR="nvim"
export TERMINAL="alacritty"
export BROWSER="qutebrowser"

Sometimes ssh doesn’t work correctly without this.

export TERM=xterm-256color