# 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 export LC_ALL="en_AU.utf8" # Shorter version of a common command that it used herein. _checkexec () { command -v "$1" > /dev/null } # Machine-specific and personal settings if [[ -f ~/.bashrc_local ]]; then source ~/.bashrc_local fi ## prompts # git prompt if [[ -f /usr/share/git/completion/git-prompt.sh ]]; then source /usr/share/git/completion/git-prompt.sh elif [[ -f /etc/bash_completion.d/git-prompt ]]; then source /etc/bash_completion.d/git-prompt elif [[ -f /usr/share/git-core/contrib/completion/git-prompt.sh ]]; then source /usr/share/git-core/contrib/completion/git-prompt.sh fi # 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 if [[ $(type -t my_local_add_path) == function ]]; then my_local_add_path fi 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" # 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 " 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 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" # get url behind one redirection alias wgre="wget --spider --max-redirect=0" # wget with spoofing googlebot alias wggb='wget --header="X-Forwarded-For: 66.249.66.1" --user-agent="Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)"' # 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' # git alias gcgrep='git log --pretty=format:"%h %ad - %an: %<(80,trunc)%s" | grep' # 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 alias pU="sudo pacman -U" # install local user package # 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 alias pQe="pacman -Qe" # explicitly installed packages # 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 alias pQo="pacman -Qo" # which package owns this file alias pQc="pacman -Qc" # show changelog # Remove packages alias pRs="sudo pacman -Rs" # remove package alias pRnsc="sudo pacman -Rnsc" # remove package recursively # similar to apt autoremove alias pRat="sudo pacman -Qdtq | sudo pacman -Rs -" # Clear cache alias pcache1="sudo paccache -rk 1" # remove cache except last item alias pcache0="sudo paccache -ruk0" # remove all cache # make an aur package paur () { pkg_name="${1%.tar.gz}" tar xvf "$pkg_name.tar.gz" cd "$pkg_name" makepkg } fi alias systart="sudo systemctl start" alias systop="sudo systemctl stop" alias sysnow="sudo systemctl enable --now" alias sysdis="sudo systemctl disable" alias systat="systemctl status" alias sysres="sudo systemctl restart" alias sysrelo="sudo systemctl reload" # from ~/.bashrc_local, more aliases if [[ $(type -t my_local_aliases) == function ]]; then my_local_aliases 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 # ensure $XDG_RUNTIME_DIR is set if [ -z "$XDG_RUNTIME_DIR" ]; then # It's not already set XDG_RUNTIME_DIR=/run/user/$UID # Try systemd created path if [ ! -d "$XDG_RUNTIME_DIR" ]; then # systemd-created directory doesn't exist XDG_RUNTIME_DIR=/tmp/$USER-runtime if [ ! -d "$XDG_RUNTIME_DIR" ]; then # Doesn't already exist mkdir -m 0700 "$XDG_RUNTIME_DIR" fi fi fi # Check dir has got the correct type, ownership, and permissions if ! [[ -d "$XDG_RUNTIME_DIR" && -O "$XDG_RUNTIME_DIR" && "$(stat -c '%a' "$XDG_RUNTIME_DIR")" = 700 ]]; then echo "\$XDG_RUNTIME_DIR: permissions problem with $XDG_RUNTIME_DIR:" >&2 ls -ld "$XDG_RUNTIME_DIR" >&2 XDG_RUNTIME_DIR=$(mktemp -d /tmp/"$USER"-runtime-XXXXXX) echo "Set \$XDG_RUNTIME_DIR=$XDG_RUNTIME_DIR" >&2 fi # 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 if [[ $(type -t my_local_export) == function ]]; then my_local_export fi # ghostscript, extract pages into a new file # gs-extract 4 11 page-4-thru-11.pdf original.pdf gs-extract() { gs -sDEVICE=pdfwrite -dNOPAUSE -dBATCH -dSAFER -dFirstPage=$1 -dLastPage=$2 \ -sOutputFile=$3 $4 } # ghostscript, merge files: gs-merge merged.pdf 1.pdf 2.pdf gs-merge() { gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile="$@" } # dptrp1 alias quaderno="dptrp1 --addr $QUADERNO_IP"