diff options
-rw-r--r-- | misc/.bashrc | 206 |
1 files changed, 206 insertions, 0 deletions
diff --git a/misc/.bashrc b/misc/.bashrc new file mode 100644 index 0000000..976451d --- /dev/null +++ b/misc/.bashrc @@ -0,0 +1,206 @@ +# If not running interactively, don't do anything. This too is taken +# from Debian 9's bashrc. +case $- in + *i*) ;; + *) return;; +esac + +# use emacs for editor +export EDITOR="emacsclient -c -a emacs" # $EDITOR opens in terminal +export VISUAL="emacsclient -c -a emacs" # $VISUAL opens in GUI mode + +# Shorter version of a common command that it used herein. +_checkexec () +{ + command -v "$1" > /dev/null +} + +# Machine-specific and personal settings +source ~/.bashrc_local + +## prompts +# git prompt +source /usr/share/git/completion/git-prompt.sh + +# prompt +RESET="\[\033[0m\]" +RED="\[\033[0;31m\]" +GREEN="\[\033[01;32m\]" +BLUE="\[\033[01;34m\]" +YELLOW="\[\033[0;33m\]" +if [ -n "$SSH_CONNECTION" ]; then + PS_INFO="$GREEN\u@\h$RESET:$BLUE\w" +else + PS_INFO="$RESET$BLUE\w" +fi +PS_GIT="$YELLOW\$(__git_ps1)" +PS_TIME="\[\033[\$((COLUMNS-10))G\] $RED[\t]" +PS1="\${PS_FILL}\[\033[0G\]${PS_INFO}${PS_GIT}${PS_TIME}\n${RESET}\$ " +export PS1 + +# Use bash-completion, if available +[[ $PS1 && -f /usr/share/bash-completion/bash_completion ]] && \ + . /usr/share/bash-completion/bash_completion + +# Enable tab completion when starting a command with 'sudo' +[ "$PS1" ] && complete -cf sudo + +# Include my scripts in the PATH. +if [ -d "$HOME"/bin ] +then + PATH=$PATH:"$HOME"/bin +fi + +if [ -d "$HOME"/.local/bin ] +then + PATH=$PATH:"$HOME"/.local/bin +fi + +# from ~/.bashrc_local, adding more to PATH +my_local_add_path + +export PATH + +# Default pager. Note that the option I pass to it will quit once you +# try to scroll past the end of the file. +if [ "$TERM" = "dumb" ] +then + export PAGER="cat" + alias less="cat" +else + export PAGER="less --quit-at-eof" +fi + +export MANPAGER="$PAGER" + +export LC_ALL=en_GB.utf8 + +# Enter directory and list contents +cd () +{ + if [ -n "$1" ] + then + builtin cd "$@" && ls -pvA --color=auto --group-directories-first + else + builtin cd ~ && ls -pvA --color=auto --group-directories-first + fi +} + +# Back up a file. Usage "backupthis <filename>" +backupthis () +{ + cp -riv $1 ${1}-$(date +%Y%m%d%H%M).backup; +} + +# append to history file. don't overwrite it. +shopt -s histappend +# increase history size to infinity +export HISTSIZE=-1 +export HISTFILESIZE=-1 +# ignore ls and history in history +export HISTIGNORE="ls:history" +export HISTTIMEFORMAT="[%F %T] " +export HISTCONTROL=ignoreboth + +# aliases +test -s ~/.alias && . ~/.alias || true +alias shutdown='sudo /sbin/shutdown -hP now' +alias reboot='sudo /sbin/reboot' +alias wifi-menu='sudo /usr/bin/wifi-menu' +alias cd-='cd -' +alias cd#='cd ~' +alias cd..='cd ..' +alias ..='cd ..' +alias ...='cd ../..' +alias ....='cd ../../..' +alias ls='ls --color=always' +alias l.='ls -d .* --color=auto' +alias ll='ls -l' +alias updatedb='sudo updatedb' +# wget it like it's curl +alias wgets="wget -O- 2>/dev/null" +# this allows to open an url with tor-browser from within emacs, see +# `my-browse-url-tor-browser' +alias tor-browser="tor-browser --allow-remote" +alias which='alias | which -i' +alias chx="chmod +x" +# dedicated emacs instances for emms and erc, see `my-profile' in my +# emacs init files +alias emms='EMACS_PROFILE=emms emacs' +alias erc='EMACS_PROFILE=erc emacs' + +# Safer default for cp, mv, rm. These will print a verbose output of +# the operations. If an existing file is affected, they will ask for +# confirmation. This can make things a bit more cumbersome, but is a +# generally safer option. +alias cp='cp -iv' +alias mv='mv -iv' +alias rm='rm -iv' + +# pacman package manager +if _checkexec pacman +then + # General package management + alias pSyu="sudo pacman -Syu" # system upgrade + alias pSyyu="sudo pacman -Syyu" # when updating mirrors + alias pD="sudo pacman -D" # set `--asdeps` or `--asexplicit` + + # Search remote database and download packages + alias pSs="pacman -Ss" # search remote for package + alias pS="sudo pacman -S" # sync download + + # Query the file database + alias pF="pacman -F" + pFw() + { + pacman -F $(which "$1") + } + + # Search local database + alias pQs="pacman -Qs" # query list + alias pQmq="pacman -Qmq" # list foreign packages + alias pQdt="pacman -Qdt" # list orphans + + # Inspect packages (remote and local) + alias pSi="pacman -Si" # remote package details + alias pQi="pacman -Qi" # local package details + alias pQl="pacman -Ql" # local package file lists + + # Remove packages + alias pRs="sudo pacman -Rs" # remove package + alias pRnsc="sudo pacman -Rnsc" # remove package recursively + + # Clear cache + alias pcache1="sudo paccache -rk 1" # remove cache except last item + alias pcache0="sudo paccache -ruk0" # remove all cache +fi + +#ibus +export GTK_IM_MODULE=ibus +export XMODIFIERS=@im=ibus +export QT_IM_MODULE=ibus + +#fix small vlc interface +export QT_AUTO_SCREEN_SCALE_FACTOR=0 + +# start the agent automatically and make sure that only one +# ssh-agent process runs at a time +if ! pgrep -u "$USER" ssh-agent > /dev/null; then + ssh-agent -t 600 > "$XDG_RUNTIME_DIR/ssh-agent.env" +fi +if [[ ! "$SSH_AUTH_SOCK" ]]; then + source "$XDG_RUNTIME_DIR/ssh-agent.env" >/dev/null +fi + +# calibre +export CALIBRE_TEMP_DIR=$HOME/tmp + +# ccache +export USE_CCACHE=1 +export CCACHE_EXEC=/usr/bin/ccache + +# cvs +export CVS_RSH="ssh" + +# from ~/.bashrc_local, export more stuff +my_local_export |