terminal.org (4726B)
1 # -*- org-use-property-inheritance: t; -*- 2 #+TITLE: TTY config - bashrc, profile, readline 3 4 * profile 5 :PROPERTIES: 6 :header-args: :tangle "out/.bash_profile" 7 :END: 8 9 This file is loaded in a login shell before .bashrc, so I set 10 environment variables and start some programs. 11 12 ** Environment variables. 13 14 If I'm in a tty, I want my emacsclient instance to fall back to a 15 terminal editor. 16 17 #+begin_src shell 18 export EDITOR='emacsclient --tty -a "mg"' 19 #+end_src 20 21 *** Email 22 23 #+begin_src shell 24 export EMAIL='jdb@jamzattack.xyz' 25 #+end_src 26 27 *** Fixing non-conformant config/data files 28 29 **** Set XDG_CONFIG_HOME if unset. 30 31 #+begin_src shell 32 [ -z "$XDG_CONFIG_HOME" ] && export XDG_CONFIG_HOME="$HOME/.config" 33 #+end_src 34 35 **** nethack 36 37 | ~/.nethackrc | ~/.config/nethack/nethackrc | 38 39 #+begin_src shell 40 export NETHACKOPTIONS="@$XDG_CONFIG_HOME/nethack/nethackrc" 41 #+end_src 42 43 **** password-store 44 45 | ~/.password-store | ~/.local/share/password-store | 46 47 #+begin_src shell 48 export PASSWORD_STORE_DIR="$HOME/.local/share/password-store" 49 #+end_src 50 51 **** screen 52 53 | ~/.screenrc | ~/.config/screen/screenrc | 54 55 #+begin_src shell 56 export SCREENRC="$XDG_CONFIG_HOME/screen/screenrc" 57 #+end_src 58 59 **** notmuch 60 61 | ~/.notmuch-config | ~/.config/notmuch/config | 62 63 #+begin_src shell 64 export NOTMUCH_CONFIG="$XDG_CONFIG_HOME/notmuch/config" 65 #+end_src 66 67 **** less (pager) 68 69 | ~/.lesshst | ~/.local/share/less/history | 70 71 #+begin_src shell 72 export LESSHISTFILE="$HOME/.local/share/less/history" 73 #+end_src 74 75 **** readline 76 77 | ~/.inputrc | ~/.config/readline/inputrc | 78 79 #+begin_src shell 80 export INPUTRC="$XDG_CONFIG_HOME/readline/inputrc" 81 #+end_src 82 83 **** FVWM 84 85 | ~/.fvwm/ | ~/.config/fvwm/ | 86 87 #+begin_src shell 88 export FVWM_USERDIR="$XDG_CONFIG_HOME/fvwm/" 89 #+end_src 90 91 *** Input method 92 93 exwm requires the following environment variables to be set in order 94 for Emacs input methods to work. 95 96 #+begin_src shell 97 export XMODIFIERS=@im=exwm-xim 98 export GTK_IM_MODULE=xim 99 export QT_IM_MODULE=xim 100 export CLUTTER_IM_MODULE=xim 101 #+end_src 102 103 ** bashrc 104 105 Load =~/.bashrc= if it exists. 106 107 #+begin_src shell 108 [ -f ~/.bashrc ] && . ~/.bashrc 109 #+end_src 110 111 ** startx 112 113 If I am on tty1 and emacs isn't running, start the daemon and 114 launch a graphical session. If emacs is already running, show its 115 process. 116 117 #+begin_src shell 118 if [ "$(tty)" == /dev/tty1 ]; then 119 if pidof emacs; then 120 ps `pidof emacs` 121 else 122 emacs --daemon && startx 123 fi 124 fi 125 #+end_src 126 127 ** screen 128 129 If I am on tty2, either recover a screen session or start a new one. 130 131 #+begin_src shell 132 if [ "$(tty)" == /dev/tty2 ]; then 133 exec screen -R || screen 134 fi 135 #+end_src 136 137 * bashrc 138 :PROPERTIES: 139 :header-args: :tangle "out/.bashrc" 140 :END: 141 142 This file is loaded by bash for all interactive shells. 143 144 ** shell variables 145 146 *** prompt 147 148 I want my prompt to display my working directory and not get in the 149 way. i.e. '~ $' 150 151 Spit out an escape sequence that changes the title if $TERM is either 152 st, xterm, or screen. 153 154 #+begin_src shell 155 PS1='\w $ ' 156 #+end_src 157 158 *** autocd 159 160 Type in a directory name and move there. 161 162 #+begin_src shell 163 shopt -s autocd 164 #+end_src 165 166 *** fixing cluttered $HOME 167 168 Move history file to ~/.config/bash/history 169 170 #+begin_src shell 171 HISTFILE="$XDG_CONFIG_HOME/bash/history" 172 #+end_src 173 174 *** History size 175 176 Default history size of 500 is too small, set it to 10,000 177 178 #+begin_src shell 179 HISTFILESIZE=10000 180 #+end_src 181 182 ** aliases 183 184 *** ls 185 186 | ls | use color | 187 | l | long form, show all | 188 | lb | !!, ignore backups | 189 190 #+begin_src shell 191 alias ls='ls --color=auto' 192 alias l='ls -lah' 193 alias lb='ls -lahB' 194 #+end_src 195 196 *** systemctl 197 198 systemctl is a damn long thing to type, so set up some easier aliases. 199 200 #+begin_src shell 201 alias S='systemctl' 202 alias SS='sudo systemctl' 203 alias SU='systemctl --user' 204 #+end_src 205 206 *** general shell usage 207 208 package manager, editor, history 209 210 #+begin_src shell 211 alias pacman='sudo pacman' 212 alias e="$EDITOR" 213 alias hist='history | tail' 214 #+end_src 215 216 ** environment variables 217 218 *** pager 219 220 Because I use emacs for almost everything, I set the PAGER to cat in 221 emacs. This means that, if I start a terminal from emacs, that 222 terminal uses cat as PAGER. In such cases, use less instead. 223 224 #+begin_src shell 225 case $TERM in 226 st-*) 227 export PAGER=less 228 ;; 229 ,*.screen) 230 export PAGER=less 231 esac 232 #+end_src 233 234 * readline 235 :PROPERTIES: 236 :header-args: :tangle "xdg-config/readline/inputrc" :mkdirp yes 237 :END: 238 239 ** Keybindings 240 241 M-p and M-n are bound to totally useless keys by default. 242 243 #+begin_src conf 244 "\ep": history-search-backward 245 "\en": history-search-forward 246 #+end_src 247 248 ** Settings 249 250 Blink matching parentheses, disable bell. 251 252 #+begin_src conf 253 set blink-matching-paren on 254 set bell-style none 255 #+end_src