Commit | Line | Data |
---|---|---|
ca3a844a AB |
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. | |
6 | export SHELL | |
7 | ||
8 | if [[ $- != *i* ]] | |
9 | then | |
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 | |
17 | fi | |
18 | ||
19 | if [ -n "$IS_GUIX_SYSTEM" ]; then | |
20 | # Source the system-wide file. | |
21 | source /etc/bashrc | |
22 | fi | |
23 | ||
24 | # from https://unix.stackexchange.com/a/55935 | |
25 | b_prompt() { | |
26 | cwd=$(sed -e "s:$HOME:~:" -e "s:\(\.\?[^/]\)[^/]*/:\1/:g" <<<$PWD) | |
27 | printf $cwd | |
28 | } | |
29 | ||
30 | if [ $(id -u) == "0" ]; then | |
31 | PS1='`printf "\[\e[1;31m\]\$\[\e[00m\]"` ' | |
32 | else | |
33 | PS1='\$ ' | |
34 | fi | |
35 | PS1="\u@\h:\w/`[ -n "$GUIX_ENVIRONMENT" ] && printf \" [env]\"`\n$PS1" | |
36 | ||
37 | # set terminal title | |
38 | PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: $(b_prompt)\007"' | |
39 | ||
40 | # i-beam cursor | |
41 | # echo -e "\033[5 q" # blinking | |
9867e4bb | 42 | # echo -e "\033[6 q" # non-blinking |
ca3a844a AB |
43 | |
44 | # various bash tweaks | |
810676dd AB |
45 | # disallow overwriting existing file using redirection |
46 | set -o noclobber | |
ca3a844a AB |
47 | # append to the history file, don't overwrite it |
48 | shopt -s histappend | |
49 | shopt -s cmdhist | |
50 | # check the window size after each command and, if necessary, | |
51 | # update the values of LINES and COLUMNS. | |
52 | shopt -s checkwinsize | |
53 | # If set, the pattern "**" used in a pathname expansion context will | |
54 | # match all files and zero or more directories and subdirectories. | |
55 | #shopt -s globstar | |
56 | # for setting history length see HISTSIZE and HISTFILESIZE in bash(1) | |
57 | HISTSIZE= | |
58 | HISTFILESIZE= | |
59 | # don't put duplicate lines or lines starting with space in the | |
60 | # history. | |
61 | HISTCONTROL=ignoreboth | |
62 | # ignore a few very common commands and don't add them to history | |
63 | HISTIGNORE='ls:l:s:g:[bf]g:history' | |
64 | HISTTIMEFORMAT='%F %T ' | |
65 | stty stop "" | |
66 | ||
67 | # aliases | |
68 | alias ls='ls -p --color=auto' | |
69 | alias l='ls -lh' # long format and human-readable sizes | |
70 | alias ll='l -A' # long format, all files | |
71 | alias dir='dir --color=auto' | |
72 | alias vdir='vdir --color=auto' | |
73 | alias grep='grep --color=auto' | |
74 | alias fgrep='fgrep --color=auto' | |
75 | alias egrep='egrep --color=auto' | |
76 | alias mpv="mpv --ytdl-format mp4" | |
77 | alias mv="mv -iv" | |
78 | alias cp="cp -iv" | |
79 | alias mbsync='mbsync -c "$XDG_CONFIG_HOME"/isync/mbsyncrc' | |
80 | alias getmail='getmail --getmaildir "$XDG_CONFIG_HOME"/getmail --rcfile getmailrc' | |
81 | alias m="mbsync csclub; mbsync uwaterloo; mbsync shemshak; mbsync gnub" | |
82 | alias best="youtube-dl -f best" | |
83 | alias e="$EDITOR" | |
84 | alias se="SUDO_EDITOR=\"emacsclient\" sudo -e" | |
1f5c92ff | 85 | alias s="startx" |
ca3a844a | 86 | |
9867e4bb AB |
87 | alias dquilt="quilt --quiltrc=${HOME}/.quiltrc-dpkg" |
88 | complete -F _quilt_completion -o filenames dquilt | |
89 | ||
ca3a844a | 90 | aur() { |
aea662c5 | 91 | cd ~/s |
ca3a844a AB |
92 | [ -d ${1} ] || git clone https://aur.archlinux.org/${1}.git |
93 | cd ${1} | |
94 | } | |
95 | ||
96 | function t { | |
97 | cd $(mktemp -d /tmp/$1.XXXX) | |
98 | } | |
99 | ||
100 | # separate alias definitions file, if exists | |
101 | if [ -f ~/.bash_aliases ]; then | |
102 | . ~/.bash_aliases | |
103 | fi | |
104 | ||
105 | # enable programmable completion features (not needed if already | |
106 | # enabled in /etc/bash.bashrc and if /etc/profile sources | |
107 | # /etc/bash.bashrc). | |
108 | if ! shopt -oq posix; then | |
109 | if [ -f /usr/share/bash-completion/bash_completion ]; then | |
110 | . /usr/share/bash-completion/bash_completion | |
111 | elif [ -f /etc/bash_completion ]; then | |
112 | . /etc/bash_completion | |
113 | fi | |
114 | fi | |
115 | ||
116 | # source Guix shell config dirs, for vte.sh and bash completions | |
117 | GUIX_PROFILES=("${HOME}/.guix-profile" | |
118 | "${HOME}/.config/guix/current") | |
119 | for profile in "${GUIX_PROFILES[@]}"; do | |
120 | for dir in "${profile}/etc/bash_completion.d" "${profile}/etc/profile.d"; do | |
121 | if [ -d "${dir}" ]; then | |
122 | for f in "${dir}"/*; do | |
123 | . $f | |
124 | done | |
125 | fi | |
126 | done | |
127 | done |