Adding info for bashrc
This commit is contained in:
parent
18673fbcf2
commit
00dfa3678e
60
Bashrc.wiki
60
Bashrc.wiki
|
@ -1,15 +1,73 @@
|
|||
=Bashrc=
|
||||
|
||||
Current configuration can always be found at https://git.thurstylark.com/vcsh/bashrc.git
|
||||
Source: https://git.thurstylark.com/vcsh/bashrc.git
|
||||
|
||||
----
|
||||
|
||||
==Prompt==
|
||||
|
||||
I originally built my prompt using http://bashrcgenerator.com and, while it's a nice tool for visually building a prompt, it has several limitations on what you're able to create with it. But more importantly to me, it generates a rediculously long string, defines and resets color for every single character, uses both a color and bold escape sequence to use light/bright colors, mixes raw escape sequences and subshells running tput, and as a result is utterly unreadable and unmaintainable.
|
||||
|
||||
So, I replaced it:
|
||||
|
||||
{{{class="prettyprint"
|
||||
### PROMPT ###
|
||||
|
||||
promptsetup() {
|
||||
# Color definitions for prompt
|
||||
local fg_brightred='\[$(tput setaf 9)\]'
|
||||
local fg_blue='\[$(tput setaf 4)\]'
|
||||
local fg_magenta='\[$(tput setaf 13)\]'
|
||||
local fg_cyan='\[$(tput setaf 6)\]'
|
||||
local fg_brightcyan='\[$(tput setaf 14)\]'
|
||||
local reset='\[$(tput sgr0)\]'
|
||||
|
||||
# [hh:mm][username@hostname pwd]$
|
||||
if [ -n "$SSH_CLIENT" ]; then
|
||||
# Remotely, hostname is red.
|
||||
PS1="${fg_blue}[\A]${fg_cyan}[${fg_brightcyan}\u${fg_cyan}@${fg_brightred}\h ${fg_cyan}\W]${reset}\$ "
|
||||
|
||||
elif [ -n "$VCSH_REPO_NAME" ]; then
|
||||
# If in a vcsh repo env, add repo name in magenta.
|
||||
PS1="${fg_blue}[\A]${fg_cyan}[${fg_brightcyan}\u${fg_cyan}@\h ${fg_magenta}$VCSH_REPO_NAME ${fg_cyan}\W]${reset}\$ "
|
||||
|
||||
else
|
||||
# Locally, hostname is cyan.
|
||||
PS1="${fg_blue}[\A]${fg_cyan}[${fg_brightcyan}\u${fg_cyan}@\h \W]${reset}\$ "
|
||||
fi
|
||||
}
|
||||
|
||||
promptsetup
|
||||
}}}
|
||||
|
||||
I intentionally put everything in a function and call it immediately so I may use local vars for the color definitions. I didn't really want to leave them around just in case.
|
||||
|
||||
----
|
||||
|
||||
==Profile==
|
||||
|
||||
Bash chooses which dotfile to source based on how it gets run. If starting from a login shell, `~/.bash_profile` will get sourced, but if there's not a command in there to source your `~/.bashrc`, you may find yourself having to `exec bash` after starting bash. This can be fixed by adding the following line to your `~/.bash_profile`:
|
||||
|
||||
{{{class="prettyprint"
|
||||
[[ -f ~/.bashrc ]] && . ~/.bashrc
|
||||
}}}
|
||||
|
||||
I also use `~/.bash_profile` for setting numlock while in a tty:
|
||||
|
||||
{{{class="prettyprint"
|
||||
case $(tty) in /dev/tty[0-9]*)
|
||||
setleds -D +num # (numlock for X is set in ~/.xinitrc)
|
||||
;;
|
||||
esac
|
||||
}}}
|
||||
|
||||
The last thing of note in my `~/.bash_profile` is a warning:
|
||||
|
||||
{{{class="prettyprint"
|
||||
# Temporary fix for a systemd bug related to systemd --user timers that run on login
|
||||
[[ -z "$DBUS_SESSION_BUS_ADDRESS" ]] && printf "%bWARNING: \$DBUS_SESSION_BUS_ADDRESS is unset! %b\n" "$(tput bold)$(tput setab 1)" "$(tput sgr0)"
|
||||
}}}
|
||||
|
||||
----
|
||||
|
||||
==Weechat==
|
||||
|
|
Loading…
Reference in New Issue