emacs: better simulation keys for abrowser, fix s-N bindings
[~bandali/configs] / .bashrc
... / ...
CommitLineData
1# Bash initialization for interactive non-login shells and
2# for remote shells (info "(bash) Bash Startup Files").
3
4# Export 'SHELL' to child processes. Programs such as 'screen'
5# honor it and otherwise use /bin/sh.
6export SHELL
7
8if [[ $- != *i* ]]
9then
10 # We are being invoked from a non-interactive shell. If this
11 # is an SSH session (as in "ssh host command"), source
12 # /etc/profile so we get PATH and other essential variables.
13 [[ -n "$SSH_CLIENT" ]] && source /etc/profile
14
15 # Don't do anything else.
16 return
17fi
18
19if [ -n "$IS_GUIX_SYSTEM" ]; then
20 # Source the system-wide file.
21 source /etc/bashrc
22fi
23
24# from https://unix.stackexchange.com/a/55935
25a_prompt() {
26 cwd=$(sed -e "s:$HOME:~:" -e "s:\(\.\?[^/]\)[^/]*/:\1/:g" <<<$PWD)
27 printf $cwd
28}
29# Adjust the prompt depending on whether we're in 'guix environment'.
30if [ -n "$GUIX_ENVIRONMENT" ]
31then
32 PS1="\u@\h [env] \$(a_prompt)> "
33else
34 PS1="\u@\h \$(a_prompt)> "
35fi
36
37# set terminal title
38PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: $(a_prompt)\007"'
39
40# i-beam cursor
41# echo -e "\033[5 q" # blinking
42# echo -e "\033[6 q" # non-blinking
43
44# various bash tweaks
45# append to the history file, don't overwrite it
46shopt -s histappend
47shopt -s cmdhist
48# check the window size after each command and, if necessary,
49# update the values of LINES and COLUMNS.
50shopt -s checkwinsize
51# If set, the pattern "**" used in a pathname expansion context will
52# match all files and zero or more directories and subdirectories.
53#shopt -s globstar
54# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
55HISTSIZE=
56HISTFILESIZE=
57# don't put duplicate lines or lines starting with space in the
58# history.
59HISTCONTROL=ignoreboth
60# ignore a few very common commands and don't add them to history
61HISTIGNORE='ls:l:s:g:[bf]g:history'
62HISTTIMEFORMAT='%F %T '
63stty stop ""
64
65# aliases
66alias ls='ls -p --color=auto'
67alias l='ls -lh' # long format and human-readable sizes
68alias ll='l -A' # long format, all files
69alias dir='dir --color=auto'
70alias vdir='vdir --color=auto'
71alias grep='grep --color=auto'
72alias fgrep='fgrep --color=auto'
73alias egrep='egrep --color=auto'
74alias mpv="mpv --ytdl-format mp4"
75alias mv="mv -iv"
76alias cp="cp -iv"
77alias mbsync='mbsync -c "$XDG_CONFIG_HOME"/isync/mbsyncrc'
78alias getmail='getmail --getmaildir "$XDG_CONFIG_HOME"/getmail --rcfile getmailrc'
79alias m="mbsync csclub; mbsync uwaterloo; mbsync shemshak; mbsync gnub"
80alias best="youtube-dl -f best"
81alias e="$EDITOR"
82alias se="SUDO_EDITOR=\"emacsclient\" sudo -e"
83
84aur() {
85 cd ~/usr/builds
86 [ -d ${1} ] || git clone https://aur.archlinux.org/${1}.git
87 cd ${1}
88}
89
90# separate alias definitions file, if exists
91if [ -f ~/.bash_aliases ]; then
92 . ~/.bash_aliases
93fi
94
95# enable programmable completion features (not needed if already
96# enabled in /etc/bash.bashrc and if /etc/profile sources
97# /etc/bash.bashrc).
98if ! shopt -oq posix; then
99 if [ -f /usr/share/bash-completion/bash_completion ]; then
100 . /usr/share/bash-completion/bash_completion
101 elif [ -f /etc/bash_completion ]; then
102 . /etc/bash_completion
103 fi
104fi