Updates for profile and bashrc; PS1 simplification
This commit is contained in:
parent
cee344c569
commit
fe260899ba
@ -6,21 +6,24 @@
|
|||||||
[[ $- != *i* ]] && return
|
[[ $- != *i* ]] && return
|
||||||
|
|
||||||
### Prompt ###
|
### Prompt ###
|
||||||
organization="$(hostname | rev | cut -f 2 -d '.' | rev)"
|
organization="$(echo $HOSTNAME | rev | cut -f 2 -d '.' | rev)"
|
||||||
PS1='\[\033[00;31m\][ '"${organization^^}"'::\h/\[\033[01;32m\]\u \[\033[00;31m\]\\\\\\\\ ${SHELL} {\[\033[m\]$? \[\033[00;36m\]\D{%F-%R} \[\033[00;35m\]\w\[\033[00;31m\]\[\033[00;31m\]\[\033[00;33m\]$(git_prompt_var)\[\033[00;31m\]} ]\n|\[\033[m\]> '
|
PS1='\[\033[00;31m\][ \[\033[01;32m\]\u\[\033[00;31m\]@\H:${SHELL} {\[\033[m\]$? \[\033[00;36m\]\D{%F-%R} \[\033[00;35m\]\w\[\033[00;31m\]\[\033[00;31m\]\[\033[00;33m\]$(git_prompt_var)\[\033[00;31m\]} ]\n|\[\033[m\]> '
|
||||||
PS2='> '
|
PS2='> '
|
||||||
PS3='> '
|
PS3='> '
|
||||||
PS4='+ '
|
PS4='+ '
|
||||||
case ${TERM} in
|
case ${TERM} in
|
||||||
xterm*|rxvt*|Eterm|aterm|kterm|gnome*)
|
screen|xterm*|rxvt*|Eterm|aterm|kterm|gnome*)
|
||||||
PROMPT_COMMAND=${PROMPT_COMMAND:+$PROMPT_COMMAND; }'printf "\033]0;'${organization^^}'::%s \134\134 %s in %s\007" "${HOSTNAME%%.*}" "${USER}" "${PWD/#$HOME/\~}"'
|
PROMPT_COMMAND=${PROMPT_COMMAND:+$PROMPT_COMMAND; }'printf "\033]0;'${organization^^}'/${HOSTNAME%%.*}"'
|
||||||
|
|
||||||
;;
|
|
||||||
screen)
|
|
||||||
PROMPT_COMMAND=${PROMPT_COMMAND:+$PROMPT_COMMAND; }'printf "\033]0;'${organization^^}'::%s \134\134 %s in %s\007" "${HOSTNAME%%.*}" "${USER}" "${PWD/#$HOME/\~}"'
|
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
# Terminal settings
|
||||||
|
export TERM=xterm-256color
|
||||||
|
alias weechat="TERM=screen weechat"
|
||||||
|
|
||||||
|
# Disable bracketed paste mode
|
||||||
|
printf "\e[?2004l"
|
||||||
|
|
||||||
### MOTD ###
|
### MOTD ###
|
||||||
[ -f /etc/bash.motd ] && cat /etc/bash.motd
|
[ -f /etc/bash.motd ] && cat /etc/bash.motd
|
||||||
|
|
||||||
@ -51,7 +54,7 @@ IFS="
|
|||||||
"
|
"
|
||||||
|
|
||||||
### GIT ###
|
### GIT ###
|
||||||
source /usr/share/git-core/contrib/completion/git-prompt.sh
|
source /usr/share/git/completion/git-prompt.sh
|
||||||
|
|
||||||
function git_prompt_var() {
|
function git_prompt_var() {
|
||||||
### If $PWD is a Git repo, add URL and branch to PS1
|
### If $PWD is a Git repo, add URL and branch to PS1
|
||||||
@ -65,7 +68,7 @@ function git_prompt_var() {
|
|||||||
|
|
||||||
### SSH ###
|
### SSH ###
|
||||||
# Tell shell about ssh-agent -- enable with 'systemctl enable ssh-agent@$USER.service'
|
# Tell shell about ssh-agent -- enable with 'systemctl enable ssh-agent@$USER.service'
|
||||||
export SSH_AGENT_PID="$(ps -fu "$USER" | grep -v grep | grep -m 1 ssh-agent | awk '{ print $2; }')"
|
export SSH_AGENT_PID="$(pgrep -fu "$USER" ssh-agent)"
|
||||||
if [ -n "$SSH_AGENT_PID" ]; then
|
if [ -n "$SSH_AGENT_PID" ]; then
|
||||||
export SSH_AUTH_SOCK="$(ls -ld /tmp/ssh-*/agent.* | grep -m 1 "$USER" | awk '{ print $9; }')"
|
export SSH_AUTH_SOCK="$(ls -ld /tmp/ssh-*/agent.* | grep -m 1 "$USER" | awk '{ print $9; }')"
|
||||||
echo ssh-agent PID is $SSH_AGENT_PID
|
echo ssh-agent PID is $SSH_AGENT_PID
|
||||||
@ -75,6 +78,13 @@ if [ -n "$SSH_AUTH_SOCK" ] && [ `ssh-add -L | grep -c no\ identities` -eq 1 ]; t
|
|||||||
ssh-add -L
|
ssh-add -L
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
### GPG ###
|
||||||
|
export GPG_TTY=$(tty)
|
||||||
|
|
||||||
|
### Ansible ###
|
||||||
|
export ANSIBLE_VAULT_PASSWORD_FILE=$HOME/password-store/${organization}.vault.password
|
||||||
|
export ANSIBLE_VAULT_FILE=$HOME/password-store/${organization}.vault
|
||||||
|
|
||||||
# ### User-directory .gitbare Support (Git) ###
|
# ### User-directory .gitbare Support (Git) ###
|
||||||
# if [ -d ~/.git ]; then
|
# if [ -d ~/.git ]; then
|
||||||
# cd
|
# cd
|
||||||
@ -88,7 +98,7 @@ fi
|
|||||||
# fi
|
# fi
|
||||||
#
|
#
|
||||||
# Set up screen/tmux safety nest by default for remote sessions
|
# Set up screen/tmux safety nest by default for remote sessions
|
||||||
if [ ! -z "$SSH_CLIENT" ]; then
|
if [ -n "$SSH_CLIENT" ]; then
|
||||||
# Prefer tmux
|
# Prefer tmux
|
||||||
if [ -x "$(which tmux 2>/dev/null)" ] && [ -z "$TMUX" ]; then
|
if [ -x "$(which tmux 2>/dev/null)" ] && [ -z "$TMUX" ]; then
|
||||||
if [ `tmux list-sessions | grep created | wc -l` -eq 0 ]; then
|
if [ `tmux list-sessions | grep created | wc -l` -eq 0 ]; then
|
||||||
@ -99,20 +109,9 @@ if [ ! -z "$SSH_CLIENT" ]; then
|
|||||||
tmux list-sessions
|
tmux list-sessions
|
||||||
fi
|
fi
|
||||||
alias tat="exec tmux a -d -t"
|
alias tat="exec tmux a -d -t"
|
||||||
# Fallback on Screen
|
|
||||||
elif [ -x "$(which screen 2>/dev/null)" ] && [ "$TERM" != "screen" ]; then
|
|
||||||
if [ `screen -list | grep -c 'Detached'` -eq 1 ]; then
|
|
||||||
exec screen -r
|
|
||||||
elif [ `screen -list | grep -c 'No Sockets found in '` -eq 1 ] && [ "$TERM" != "screen" ]; then
|
|
||||||
exec /usr/bin/screen /bin/bash
|
|
||||||
else
|
|
||||||
screen -list
|
|
||||||
fi
|
|
||||||
alias sdr="screen -d -r"
|
|
||||||
fi;
|
fi;
|
||||||
|
|
||||||
### XFCE4 ###
|
### XFCE4 ###
|
||||||
elif [ `who -m | egrep "^$(whoami)" | awk '{ print $2; }' | egrep -c "^tty"` -eq 1 ] && [ -x /usr/sbin/startxfce4 ] && [ `pgrep -ac xinit` -eq 0 ] && [ `whoami` != 'root' ]; then
|
elif [ `who -m | egrep "^$(whoami)" | awk '{ print $2; }' | egrep -c "^tty"` -eq 1 ] && [ -x /usr/sbin/startxfce4 ] && [ `pgrep -ac xinit` -eq 0 ] && [ `whoami` != 'root' ]; then
|
||||||
exec startxfce4
|
exec startxfce4
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -3,9 +3,30 @@
|
|||||||
#Set our umask
|
#Set our umask
|
||||||
umask 022
|
umask 022
|
||||||
|
|
||||||
# Set our default path
|
# Append "$1" to $PATH when not already in.
|
||||||
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:~/bin"
|
# This function API is accessible to scripts in /etc/profile.d
|
||||||
|
append_path () {
|
||||||
|
case ":$PATH:" in
|
||||||
|
*:"$1":*)
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
PATH="${PATH:+$PATH:}$1"
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
# Append our default paths
|
||||||
|
append_path '/usr/local/sbin'
|
||||||
|
append_path '/usr/local/bin'
|
||||||
|
append_path '/usr/sbin'
|
||||||
|
append_path '/usr/bin'
|
||||||
|
append_path '/sbin'
|
||||||
|
append_path '/bin'
|
||||||
|
append_path '~/bin'
|
||||||
|
|
||||||
|
# Force PATH to be environment
|
||||||
export PATH
|
export PATH
|
||||||
|
|
||||||
|
# Set IFS to be newline delimited
|
||||||
IFS="
|
IFS="
|
||||||
"
|
"
|
||||||
export IFS
|
export IFS
|
||||||
@ -18,8 +39,16 @@ if test -d /etc/profile.d/; then
|
|||||||
unset profile
|
unset profile
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Source global bash config
|
# Unload our profile API functions
|
||||||
if test "$PS1" && test "$BASH" && test -r /etc/bashrc; then
|
unset -f append_path
|
||||||
|
|
||||||
|
# Source global bash config, when interactive but not posix or sh mode
|
||||||
|
if test "$BASH" &&\
|
||||||
|
test "$PS1" &&\
|
||||||
|
test -z "$POSIXLY_CORRECT" &&\
|
||||||
|
test "${0#-}" != sh &&\
|
||||||
|
test -r /etc/bashrc
|
||||||
|
then
|
||||||
. /etc/bashrc
|
. /etc/bashrc
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -28,5 +57,3 @@ unset TERMCAP
|
|||||||
|
|
||||||
# Man is much better than us at figuring this out
|
# Man is much better than us at figuring this out
|
||||||
unset MANPATH
|
unset MANPATH
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user