|
|
|
@@ -25,7 +25,7 @@ shopt -s checkwinsize
|
|
|
|
|
|
|
|
|
|
|
|
# set variable identifying the chroot you work in (used in the prompt below)
|
|
|
|
# set variable identifying the chroot you work in (used in the prompt below)
|
|
|
|
if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
|
|
|
|
if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
|
|
|
|
debian_chroot=$(cat /etc/debian_chroot)
|
|
|
|
debian_chroot=$(cat /etc/debian_chroot)
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
# set a fancy prompt (non-color, unless we know we "want" color)
|
|
|
|
# set a fancy prompt (non-color, unless we know we "want" color)
|
|
|
|
@@ -39,18 +39,18 @@ esac
|
|
|
|
#force_color_prompt=yes
|
|
|
|
#force_color_prompt=yes
|
|
|
|
|
|
|
|
|
|
|
|
if [ -n "$force_color_prompt" ]; then
|
|
|
|
if [ -n "$force_color_prompt" ]; then
|
|
|
|
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
|
|
|
|
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
|
|
|
|
# We have color support; assume it's compliant with Ecma-48
|
|
|
|
# We have color support; assume it's compliant with Ecma-48
|
|
|
|
# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
|
|
|
|
# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
|
|
|
|
# a case would tend to support setf rather than setaf.)
|
|
|
|
# a case would tend to support setf rather than setaf.)
|
|
|
|
color_prompt=yes
|
|
|
|
color_prompt=yes
|
|
|
|
else
|
|
|
|
else
|
|
|
|
color_prompt=
|
|
|
|
color_prompt=
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
if [ "$color_prompt" != yes ]; then
|
|
|
|
if [ "$color_prompt" != yes ]; then
|
|
|
|
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
|
|
|
|
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
unset color_prompt force_color_prompt
|
|
|
|
unset color_prompt force_color_prompt
|
|
|
|
@@ -58,21 +58,21 @@ unset color_prompt force_color_prompt
|
|
|
|
# If this is an xterm set the title to user@host:dir
|
|
|
|
# If this is an xterm set the title to user@host:dir
|
|
|
|
case "$TERM" in
|
|
|
|
case "$TERM" in
|
|
|
|
xterm* | rxvt*)
|
|
|
|
xterm* | rxvt*)
|
|
|
|
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
|
|
|
|
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
|
|
|
|
;;
|
|
|
|
;;
|
|
|
|
*) ;;
|
|
|
|
*) ;;
|
|
|
|
esac
|
|
|
|
esac
|
|
|
|
|
|
|
|
|
|
|
|
# enable color support of ls and also add handy aliases
|
|
|
|
# enable color support of ls and also add handy aliases
|
|
|
|
if [ -x /usr/bin/dircolors ]; then
|
|
|
|
if [ -x /usr/bin/dircolors ]; then
|
|
|
|
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
|
|
|
|
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
|
|
|
|
alias ls='ls --color=auto'
|
|
|
|
alias ls='ls --color=auto'
|
|
|
|
#alias dir='dir --color=auto'
|
|
|
|
#alias dir='dir --color=auto'
|
|
|
|
#alias vdir='vdir --color=auto'
|
|
|
|
#alias vdir='vdir --color=auto'
|
|
|
|
|
|
|
|
|
|
|
|
alias grep='grep --color=auto'
|
|
|
|
alias grep='grep --color=auto'
|
|
|
|
alias fgrep='fgrep --color=auto'
|
|
|
|
alias fgrep='fgrep --color=auto'
|
|
|
|
alias egrep='egrep --color=auto'
|
|
|
|
alias egrep='egrep --color=auto'
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
# colored GCC warnings and errors
|
|
|
|
# colored GCC warnings and errors
|
|
|
|
@@ -86,16 +86,14 @@ alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo
|
|
|
|
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
|
|
|
|
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
|
|
|
|
# sources /etc/bash.bashrc).
|
|
|
|
# sources /etc/bash.bashrc).
|
|
|
|
if ! shopt -oq posix; then
|
|
|
|
if ! shopt -oq posix; then
|
|
|
|
if [ -f /usr/share/bash-completion/bash_completion ]; then
|
|
|
|
if [ -f /usr/share/bash-completion/bash_completion ]; then
|
|
|
|
. /usr/share/bash-completion/bash_completion
|
|
|
|
. /usr/share/bash-completion/bash_completion
|
|
|
|
elif [ -f /etc/bash_completion ]; then
|
|
|
|
elif [ -f /etc/bash_completion ]; then
|
|
|
|
. /etc/bash_completion
|
|
|
|
. /etc/bash_completion
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
############### Everything below this line are customizations ##################
|
|
|
|
############### Everything below this line are customizations ##################
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Do not let globbing complain on no match
|
|
|
|
# Do not let globbing complain on no match
|
|
|
|
shopt -s nullglob
|
|
|
|
shopt -s nullglob
|
|
|
|
@@ -104,7 +102,7 @@ shopt -s nullglob
|
|
|
|
shopt -s autocd
|
|
|
|
shopt -s autocd
|
|
|
|
|
|
|
|
|
|
|
|
function timer_start {
|
|
|
|
function timer_start {
|
|
|
|
timer=${timer:-$SECONDS}
|
|
|
|
timer=${timer:-$SECONDS}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
trap 'timer_start' DEBUG
|
|
|
|
trap 'timer_start' DEBUG
|
|
|
|
@@ -112,61 +110,61 @@ trap 'timer_start' DEBUG
|
|
|
|
PROMPT_COMMAND=jazz_my_prompt
|
|
|
|
PROMPT_COMMAND=jazz_my_prompt
|
|
|
|
|
|
|
|
|
|
|
|
jazz_my_prompt() {
|
|
|
|
jazz_my_prompt() {
|
|
|
|
# Capture exit code of last command
|
|
|
|
# Capture exit code of last command
|
|
|
|
# Below MUST be the 1st line of the function
|
|
|
|
# Below MUST be the 1st line of the function
|
|
|
|
local ex=$?
|
|
|
|
local ex=$?
|
|
|
|
|
|
|
|
|
|
|
|
# Capture the last command's execution time
|
|
|
|
# Capture the last command's execution time
|
|
|
|
timer_show=$(($SECONDS - $timer))
|
|
|
|
timer_show=$((SECONDS - timer))
|
|
|
|
unset timer
|
|
|
|
unset timer
|
|
|
|
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------------#
|
|
|
|
#----------------------------------------------------------------------------#
|
|
|
|
# Bash text colour specification: \e[<COLOUR>;<STYLE>m
|
|
|
|
# Bash text colour specification: \e[<COLOUR>;<STYLE>m
|
|
|
|
# Colours: 31=red, 32=green, 33=yellow, 34=blue, 35=purple, 36=cyan, 37=white
|
|
|
|
# Colours: 31=red, 32=green, 33=yellow, 34=blue, 35=purple, 36=cyan, 37=white
|
|
|
|
# Styles: 0=normal, 1=bold, 2=dimmed, 4=underlined, 7=highlighted
|
|
|
|
# Styles: 0=normal, 1=bold, 2=dimmed, 4=underlined, 7=highlighted
|
|
|
|
#----------------------------------------------------------------------------#
|
|
|
|
#----------------------------------------------------------------------------#
|
|
|
|
|
|
|
|
|
|
|
|
local reset="\[\e[0m\]"
|
|
|
|
local reset="\[\e[0m\]"
|
|
|
|
local normal=';0m'
|
|
|
|
local normal=';0m'
|
|
|
|
local bold=';1m'
|
|
|
|
local bold=';1m'
|
|
|
|
local boldyellow="\[\e[32${bold}\]"
|
|
|
|
local boldyellow="\[\e[32${bold}\]"
|
|
|
|
local boldwhite="\[\e[37${bold}\]"
|
|
|
|
local boldwhite="\[\e[37${bold}\]"
|
|
|
|
local normalwhite="\[\e[37${normal}\]"
|
|
|
|
local normalwhite="\[\e[37${normal}\]"
|
|
|
|
local yellow_highlight="\[\e[31;7m\]"
|
|
|
|
local yellow_highlight="\[\e[31;7m\]"
|
|
|
|
|
|
|
|
|
|
|
|
# Add color preference BEFORE the item
|
|
|
|
# Add color preference BEFORE the item
|
|
|
|
local hostname="${normalwhite}\h"
|
|
|
|
local hostname="${normalwhite}\h"
|
|
|
|
local username="${boldwhite}\u"
|
|
|
|
local username="${boldwhite}\u"
|
|
|
|
local jobs="${boldwhite}jobs:\j"
|
|
|
|
local jobs="${boldwhite}jobs:\j"
|
|
|
|
local history_cnt="${normalwhite}!\!"
|
|
|
|
local history_cnt="${normalwhite}!\!"
|
|
|
|
local timestamp="${normalwhite}\D{%H:%M:%S(%z) %d%b}"
|
|
|
|
local timestamp="${normalwhite}\D{%H:%M:%S(%z) %d%b}"
|
|
|
|
local session_cmd_cnt="${normalwhite}#\#"
|
|
|
|
local session_cmd_cnt="${normalwhite}#\#"
|
|
|
|
local pwd="${boldwhite}\w"
|
|
|
|
local pwd="${boldwhite}\w"
|
|
|
|
local isroot="${boldwhite}\$"
|
|
|
|
local isroot="${boldwhite}\$"
|
|
|
|
|
|
|
|
|
|
|
|
# Set prompt content
|
|
|
|
# Set prompt content
|
|
|
|
# If exit code of last command is non-zero, prepend this code to the prompt
|
|
|
|
# If exit code of last command is non-zero, prepend this code to the prompt
|
|
|
|
local exit_code=''
|
|
|
|
local exit_code=''
|
|
|
|
if [[ "$ex" -eq 0 ]]; then
|
|
|
|
if [[ "$ex" -eq 0 ]]; then
|
|
|
|
exit_code="${boldwhite}✓"
|
|
|
|
exit_code="${boldwhite}✓"
|
|
|
|
else
|
|
|
|
else
|
|
|
|
exit_code="${yellow_highlight}✗ $ex\a${reset}"
|
|
|
|
exit_code="${yellow_highlight}✗ $ex\a${reset}"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
# Style each group separately
|
|
|
|
# Style each group separately
|
|
|
|
local groupstart="${boldyellow}["
|
|
|
|
local groupstart="${boldyellow}["
|
|
|
|
local groupend="${boldyellow}]"
|
|
|
|
local groupend="${boldyellow}]"
|
|
|
|
group1="${groupstart}${username}@${hostname}${groupend}"
|
|
|
|
group1="${groupstart}${username}@${hostname}${groupend}"
|
|
|
|
group2="${groupstart}${jobs}${groupend}"
|
|
|
|
group2="${groupstart}${jobs}${groupend}"
|
|
|
|
group3="${groupstart}${history_cnt}${groupend}"
|
|
|
|
group3="${groupstart}${history_cnt}${groupend}"
|
|
|
|
group4="${groupstart}${session_cmd_cnt}${groupend}"
|
|
|
|
group4="${groupstart}${session_cmd_cnt}${groupend}"
|
|
|
|
group5="${groupstart}${timestamp}${groupend}"
|
|
|
|
group5="${groupstart}${timestamp}${groupend}"
|
|
|
|
group6="${groupstart}${exit_code}${groupend}"
|
|
|
|
group6="${groupstart}${exit_code}${groupend}"
|
|
|
|
group8="${groupstart}${pwd}${groupend}"
|
|
|
|
group8="${groupstart}${pwd}${groupend}"
|
|
|
|
group9="${groupstart}${normalwhite}${timer_show}s${groupend}"
|
|
|
|
group9="${groupstart}${normalwhite}${timer_show}s${groupend}"
|
|
|
|
|
|
|
|
|
|
|
|
# Position each group where you would like them
|
|
|
|
# Position each group where you would like them
|
|
|
|
PS1="\n${group1}-${group2}-${group3}-${group4}-${group5}\n${group6}-${group9}-${group8}\n${isroot}${reset} "
|
|
|
|
PS1="\n${group1}-${group2}-${group3}-${group4}-${group5}\n${group6}-${group9}-${group8}\n${isroot}${reset} "
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
|
|
|
|
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
|
|
|
|
@@ -178,18 +176,18 @@ HISTFILE="$XDG_STATE_HOME/shell/bash_history"
|
|
|
|
|
|
|
|
|
|
|
|
[ ! -f "$XDG_CONFIG_HOME/exercism/exercism_completion.bash" ] || source "$XDG_CONFIG_HOME/exercism/exercism_completion.bash"
|
|
|
|
[ ! -f "$XDG_CONFIG_HOME/exercism/exercism_completion.bash" ] || source "$XDG_CONFIG_HOME/exercism/exercism_completion.bash"
|
|
|
|
|
|
|
|
|
|
|
|
if command -v zoxide >/dev/null; then
|
|
|
|
|
|
|
|
eval "$(zoxide init --cmd cd bash)"
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# [ctrl+r]:replaces shell command search
|
|
|
|
# [ctrl+r]:replaces shell command search
|
|
|
|
# [ctrl+t]:fzf & over the files & directories under the current one & paste it to prompt
|
|
|
|
# [ctrl+t]:fzf & over the files & directories under the current one & paste it to prompt
|
|
|
|
# [alt+c] :fzf & cd into a directory under the current one
|
|
|
|
# [alt+c] :fzf & cd into a directory under the current one
|
|
|
|
[ -f $XDG_STATE_HOME/shell/fzf.bash ] && source $XDG_STATE_HOME/shell/fzf.bash
|
|
|
|
[ -f "$XDG_STATE_HOME/shell/fzf.bash" ] && source "$XDG_STATE_HOME/shell/fzf.bash"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if command -v zoxide >/dev/null; then
|
|
|
|
|
|
|
|
eval "$(zoxide init --cmd cd bash)"
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
# Source aliases and shell functions
|
|
|
|
# Source aliases and shell functions
|
|
|
|
for alias_file in "$XDG_CONFIG_HOME"/shell/*.sh; do source "$alias_file"; done
|
|
|
|
for alias_file in "$XDG_CONFIG_HOME"/shell/*.sh; do source "$alias_file"; done
|
|
|
|
|
|
|
|
|
|
|
|
# TIP: Following should be executed AFTER the aliases are sourced
|
|
|
|
# TIP: Following should be executed AFTER the aliases are sourced
|
|
|
|
command -v op >/dev/null && bind '"^O":"op\n"' # Fuzzyfind projects and open in nvim
|
|
|
|
command -v op >/dev/null && bind '"^O":"op\n"' # Fuzzyfind projects and open in nvim
|
|
|
|
command -v pnew >/dev/null && bind '"^[o":"pnew\n"' # Create a new project quickly
|
|
|
|
command -v pnew >/dev/null && bind '"^[o":"pnew\n"' # Create a new project quickly
|
|
|
|
|