Add history sync capability (sync history between multiple active sessions)

- rename enabcol variable to enable_colors
- make colorshell independent from whether using BashStyle-NG prompts
parent 3b108e7c
......@@ -39,6 +39,10 @@ Overview of changes in v9.1 "Dial T for TNT"
* add GLOBIGNORE: everything to ignore from globbing. Default value: empty.
++ if you set it to ".:.." issueing '$ ls .*' will not include '.' and '..'
* add History Sync: sync history between simultaneously running sessions.
++ commands from other sessions become available to history upon immediately,
++ to bash after reloading prompt ([ENTER])
* add dotglob: include hidden files (with leading dot) by default during
pathname expansion
* add extglob: enable extending globbing with regular expression like
......
ini_version = 16
ini_version = 17
[Style]
use_bashstyle = False
......@@ -48,6 +48,7 @@ history_control = erasedups
history_ignore = bg *:fg *:exit:cd *:source *:. *:clear:sudo *:su *:
history_size = 1000
history_timeformat = ""
history_sync = False
separator = |
ps234 = »
pwdcut = «
......
......@@ -25,7 +25,7 @@ case ${1} in
[[ ! ${trunc_symbol} ]] && trunc_symbol="«"
[[ ! ${trunc_length} ]] && trunc_length=25
if [[ ${enabcol} == "True" && ${pstyle_supported} == "True" ]]; then
if [[ ${enable_colors} == "True" && ${pstyle_supported} == "True" ]]; then
if [[ $pwdmaxlen != 0 && ${#PWD} -gt $pwdmaxlen ]]; then
pwdoffset=$(( ${#PWD} - $pwdmaxlen ))
xPWD="$newpscolor${trunc_symbol}${PWD:$pwdoffset:$pwdmaxlen}"
......
......@@ -17,7 +17,7 @@ export BSNG_DATA_DIR=@DATADIR@
export BSNG_RC_DIR=${BSNG_DATA_DIR}/bashstyle-ng/rc
export BSNG_VERSION=@VERSION@
export BSNG_YEAR="2007 - 2015"
INI_VERSION=11
INI_VERSION=17
if [[ ! -f ${HOME}/.bs-ng.ini ]]; then
if [[ -f /etc/bs-ng_vendor.ini && $(grep ini_version /etc/bs-ng_vendor.ini) == *${INI_VERSION} ]]; then
......@@ -57,7 +57,7 @@ dbg_log shopt -s checkwinsize
[[ $(ini_get enable_colors) == True ]] && \
dbg_log source ${BSNG_RC_DIR}/settings/color-rc
[[ $(ini_get use_lscolors) == True && ${enabcol} == True ]] && \
[[ $(ini_get use_lscolors) == True && ${enable_colors} == True ]] && \
dbg_log source ${BSNG_RC_DIR}/settings/ls-rc
[[ $(ini_get use_gitcfg) == True ]] && \
......@@ -146,14 +146,60 @@ if [[ $(ini_get use_bashstyle) == True ]]; then
PS3="$pscolor $ps234char$ps234char$fontcolor "
PS4="$pscolor $ps234char$ps234char$ps234char$fontcolor "
if [[ $(ini_get colorshell) == True && ${enabcol} == True ]]; then
source ${BSNG_RC_DIR}/settings/colorshell
fi
fi
dbg_log source ${BSNG_RC_DIR}/settings/options-rc
[[ ! ${PROMPT_COMMAND} ]] && USE_PROMPT_COMMAND=True
if [[ $(ini_get colorshell) && ${enable_colors} == True ]]; then
USE_COLORSHELL=True
fi
if [[ $(ini_get history_sync) == True && ${USE_COLORSHELL} == True ]]; then
if [[ ${USE_PROMPT_COMMAND} ]]; then
PROMPT_COMMAND () {
_colorshell
_sync_history
}
else
PRE_PROMPT_COMMAND () {
_colorshell
_sync_history
}
fi
history () {
_sync_history
builtin history
}
elif [[ ${USE_COLORSHELL} == True ]]; then
if [[ ${USE_PROMPT_COMMAND} ]]; then
PROMPT_COMMAND () {
_colorshell
}
else
PRE_PROMPT_COMMAND () {
_colorshell
}
fi
elif [[ $(ini_get history_sync) ]]; then
if [[ ${USE_PROMPT_COMMAND} ]]; then
PROMPT_COMMAND () {
_sync_history
}
else
PRE_PROMPT_COMMAND () {
_sync_history
}
fi
history () {
_sync_history
builtin history
}
fi
WelcomeMessage=$(ini_get welcome_message)
if [[ ${USER_BIRTHDAY} == $(date +%m-%d) && ! -e ~/.bday ]]; then
......
......@@ -9,7 +9,7 @@
# #
#########################################################
if [[ $(ini_get colored_ls) == True && ${enabcol} == True ]]; then
if [[ $(ini_get colored_ls) == True && ${enable_colors} == True ]]; then
dbg_msg $"BashStyle-NG Setting:" $"Colored ls" $"On"
dbg_log alias ls="ls -CF --color=auto --group-directories-first"
else
......
......@@ -9,7 +9,7 @@
# #
#########################################################
enabcol=True
enable_colors=True
dbg_msg $"BashStyle-NG Setting:" $"Colors" $"On"
dbg_msg $"BashStyle-NG Setting:" $"Color-Style" $(ini_get color_style)
......@@ -128,4 +128,4 @@ eval sepacolor=$(ini_get color_separator)
eval upcolor=$(ini_get color_uptime)
eval pscolor=$(ini_get color_ps234)
dbg_log export enabcol colstyle black red green yellow blue magenta cyan white coldblue smoothblue iceblue turqoise smoothgreen winered brown silver ocher orange purple pink cream eblack ered egreen eyellow eblue emagenta ecyan ewhite ecoldblue esmoothblue eiceblue eturqoise esmoothgreen ewinered ebrown esilver eocher eorange epurple epink ecream
dbg_log export enable_colors colstyle black red green yellow blue magenta cyan white coldblue smoothblue iceblue turqoise smoothgreen winered brown silver ocher orange purple pink cream eblack ered egreen eyellow eblue emagenta ecyan ewhite ecoldblue esmoothblue eiceblue eturqoise esmoothgreen ewinered ebrown esilver eocher eorange epurple epink ecream
#!/bin/bash
#########################################################
# #
# This is BashStyle-NG #
# #
# Licensed under GNU GENERAL PUBLIC LICENSE v3 #
# #
# Copyright 2007 - 2015 Christopher Bratusek #
# Copyright 2006 Philip Endecott #
# #
#########################################################
colorshell_revert=$(ini_get colorshell_revert)
if [[ ! ${PROMPT_COMMAND} ]]; then
PROMPT_COMMAND () {
cmd_text_colour='\[`tput setaf $((RANDOM%7))`\]'
shopt -s promptvars
PS1="${PS1}${cmd_text_colour}"
PS2="${PS2}${cmd_text_colour}"
PS3="${PS3}${cmd_text_colour}"
PS4="${PS4}${cmd_text_colour}"
[[ ${colorshell_revert} == True ]] && trap 'echo -ne "\e[0m"' DEBUG
PRE_PROMPT_COMMAND
}
else
PRE_PROMPT_COMMAND () {
cmd_text_colour='\[`tput setaf $((RANDOM%7))`\]'
shopt -s promptvars
PS1="${PS1}${cmd_text_colour}"
PS2="${PS2}${cmd_text_colour}"
PS3="${PS3}${cmd_text_colour}"
PS4="${PS4}${cmd_text_colour}"
[[ ${colorshell_revert} == True ]] && trap 'echo -ne "\e[0m"' DEBUG
}
fi
......@@ -9,7 +9,7 @@
# #
#########################################################
if [[ ${enabcol} == True ]]; then
if [[ ${enable_colors} == True ]]; then
if [[ -f ${BSNG_DATA_DIR}/bashstyle-ng/termcap/bar/$(ini_get termcap_bar).termcap ]]; then
dbg_msg $"BashStyle-NG Setting: Termcap (bar)" $(ini_get termcap_bar)
dbg_log source ${BSNG_DATA_DIR}/bashstyle-ng/termcap/bar/$(ini_get termcap_bar).termcap
......
......@@ -34,6 +34,12 @@ else
export TMOUT=$(ini_get timeout)
fi
_sync_history() {
builtin history -a
builtin history -c
builtin history -r
}
dbg_log export HISTSIZE=$(ini_get history_size)
dbg_msg $"BashStyle-NG Setting:" $"HISTSIZE" "$HISTSIZE"
......@@ -52,7 +58,7 @@ if [[ $(ini_get restore_directory) == True ]]; then
fi
fi
if [[ $(ini_get colored_grep) == True && ${enabcol} == True ]]; then
if [[ $(ini_get colored_grep) == True && ${enable_colors} == True ]]; then
dbg_msg $"BashStyle-NG Setting:" $"Colored grep" $"On"
alias grep="grep --color=auto"
GREP_COLOR=$(ini_get grep_color);
......@@ -66,7 +72,7 @@ fi
if [[ $(ini_get use_lscd) == True ]]; then
dbg_log alias cd=lscd
dbg_log export LSCD_OPTS="$(ini_get lscd_opts)"
[[ ${enabcol} != True ]] && dbg_log export LSCD_OPTS+=" --color=no"
[[ ${enable_colors} != True ]] && dbg_log export LSCD_OPTS+=" --color=no"
fi
dbg_log export USER_BIRTHDAY=$(ini_get user_birthday)
......@@ -77,3 +83,19 @@ dbg_log export dirchar=$(ini_get directory_indicator)
dbg_log export GLOBIGNORE=$(ini_get globignore)
dbg_msg $"BashStyle-NG Setting:" $"GLOBIGNORE" "$GLOBIGNORE"
colorshell_revert=$(ini_get colorshell_revert)
_colorshell() {
cmd_text_colour='\[`tput setaf $((RANDOM%7))`\]'
shopt -s promptvars
PS1="${PS1}${cmd_text_colour}"
PS2="${PS2}${cmd_text_colour}"
PS3="${PS3}${cmd_text_colour}"
PS4="${PS4}${cmd_text_colour}"
[[ ${colorshell_revert} == True ]] && trap 'echo -ne "\e[0m"' DEBUG
}
......@@ -39,7 +39,7 @@ PRE_PROMPT_COMMAND
PROMPT_COMMAND=pre_prompt
if [[ $enabcol == "True" ]]; then
if [[ $enable_colors == "True" ]]; then
PS1="$sepacolor┌─($usercolor \u$fontcolor @ $hostcolor\h\
$datecolor \$(date \"+%a, %d %b %y\")$sepacolor )─\${fill}─($wdircolor \$newPWD \
......
......@@ -9,7 +9,7 @@
# #
#########################################################
if [[ $enabcol == "True" ]]; then
if [[ $enable_colors == "True" ]]; then
function pre_prompt {
......
......@@ -11,7 +11,7 @@
export pstyle_supported=True
if [[ $enabcol == "True" ]]; then
if [[ $enable_colors == "True" ]]; then
PS1="\n\
$pscolor┌─$sepacolor[ $wdircolor\$(truncpwd)$DIRKS_1_COLOR\$(DIRKS_1) $sepacolor]\n\
......
......@@ -11,7 +11,7 @@
export pstyle_supported=True
if [[ $enabcol == "True" ]]; then
if [[ $enable_colors == "True" ]]; then
PS1="\n$pscolor.:$sepacolor[ $usercolor\u$pscolor @ $hostcolor\h$sepacolor ]$pscolor:. .:$sepacolor[ $wdircolor\$(truncpwd)$sepacolor ]$pscolor:.\n.:$sepacolor[·>$fontcolor "
......
......@@ -9,7 +9,7 @@
# #
#########################################################
if [[ $enabcol == "True" ]]; then
if [[ $enable_colors == "True" ]]; then
PS1="\n\
$pscolor┌─$sepacolor[ $usercolor\u $fontcolor@ $hostcolor\h$sepacolor ]$pscolor\
......
......@@ -18,7 +18,7 @@ k=6
l=8
m=10
if [[ $enabcol == "True" ]]; then
if [[ $enable_colors == "True" ]]; then
esepacolor=$(echo $sepacolor | sed -e 's/\\\[//g' -e 's/\\\]//g')
edatecolor=$(echo $datecolor | sed -e 's/\\\[//g' -e 's/\\\]//g')
......
......@@ -45,7 +45,7 @@ PRE_PROMPT_COMMAND
PROMPT_COMMAND=prompt_command
if [[ $enabcol == "True" ]]; then
if [[ $enable_colors == "True" ]]; then
PS1="\n\
$sepacolor[ $timecolor\$(date +%T) $fontcolor-$datecolor \$(date +%D) $sepacolor]\
......
......@@ -9,7 +9,7 @@
# #
#########################################################
if [[ $enabcol == "True" ]]; then
if [[ $enable_colors == "True" ]]; then
PS1="\n$sepacolor -$pscolor( $usercolor\u$sepacolor /$hostcolor \h$pscolor )$sepacolor-$pscolor( \$(systemkit tty) )$sepacolor-$pscolor($upcolor uptime: \$(systemkit uptime)$pscolor )$sepacolor-$pscolor($timecolor \$(date +%H:%M)$datecolor \$(date +%d-%b-%y)$pscolor )$sepacolor-$pscolor($wdircolor files: \$(systemkit countvisiblefiles)$sepacolor /$wdircolor folders: \$(systemkit countvisibledirs)$pscolor )$sepacolor-\n -$pscolor<$wdircolor \$(truncpwd)$QUIRK_1_COLOR\$(QUIRK_1) $pscolor>$sepacolor-$fontcolor "
......
......@@ -9,7 +9,7 @@
# #
#########################################################
if [[ $enabcol == "True" ]]; then
if [[ $enable_colors == "True" ]]; then
PS1="\n$sepacolor⊏⁅ $usercolor\u$pscolor$hostcolor\h $sepacolor⁆⁅ $datecolor\d $pscolor$timecolor\t$pscolor$upcolor\$(systemkit uptime)$sepacolor ⁆⊐
⊏⁅$wdircolor \$(truncpwd)$SEPA_NG_1_COLOR\$(SEPA_NG_1) $sepacolor⁆⊐≻$fontcolor "
......
......@@ -12,7 +12,7 @@
sepa=$(ini_get separator)
export pstyle_supported=True
if [[ $enabcol == "True" ]]; then
if [[ $enable_colors == "True" ]]; then
PS1="\n$usercolor\u$fontcolor @$hostcolor \h$sepacolor $sepa $datecolor\d$sepacolor $sepa $timecolor\t$sepacolor $sepa $wdircolor\$(truncpwd)"
[[ $(ini_get files_amount) == "True" ]] && PS1+=" files: \$(systemkit countvisiblefiles)"
......
......@@ -11,7 +11,7 @@
export pstyle_supported=True
if [[ $enabcol == true ]]; then
if [[ $enable_colors == true ]]; then
PS1="\n$pscolor$sepacolor♦($usercolor \u$fontcolor @$hostcolor \h $fontcolor: Space on /: $pscolor\$(systemkit usedspace /)$fontcolor used of$pscolor \$(systemkit totalspace /)$sepacolor )♦♦($wdircolor \$(truncpwd)$sepacolor )♦$pscolor\n\
$pscolor$sepacolor♦($timecolor \$(date +%H:%M)$sepacolor$datecolor \$(date \"+%a, %d %b %y\")$sepacolor : uptime :$upcolor \$(systemkit uptime)$sepacolor :$usercolor \$$sepacolor )♦$pscolor$fontcolor "
......
......@@ -9,7 +9,7 @@
# #
#########################################################
if [[ $enabcol == "True" ]]; then
if [[ $enable_colors == "True" ]]; then
PS1="\n$pscolor$sepacolor($usercolor \u$sepacolor @ $hostcolor\h \
$sepacolor)$pscolor$sepacolor( $timecolor\$(date +%I:%M%P)$VECTOR_1_COLOR\$(VECTOR_1)\
......
This diff is collapsed.
......@@ -134,6 +134,7 @@ class BashStyleNG(object):
WidgetHandler.InitWidget("restore_pwd", "Advanced", "restore_directory", "bool", None)
WidgetHandler.InitWidget("debug_verbose", "Advanced", "debug_verbose", "bool", None)
WidgetHandler.InitWidget("globignore", "Advanced", "glob_ignore", "text", None)
WidgetHandler.InitWidget("history_sync", "Advanced", "history_sync", "bool", None)
####################### Readline stuff #############################################
WidgetHandler.InitWidget("readline", "Readline", "use_readlinecfg", "bool", None)
......
......@@ -31,7 +31,7 @@ USER_DEFAULTS_SAVE = (os.getenv('HOME') + '/.bs-ng.ini.save')
FACTORY_DEFAULTS = (DATADIR + '/bashstyle-ng/bs-ng.ini')
VENDOR_DEFAULTS = ('/etc/bs-ng_vendor.ini')
app_ini_version = 16
app_ini_version = 17
class Config(object):
def InitConfig(self):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment