From 15609c20cdb9b527071cf39b89e15937f0a79e69 Mon Sep 17 00:00:00 2001 From: Gabriel Ebner Date: Sun, 20 Sep 2015 09:10:00 +0200 Subject: [PATCH] bash: liquidprompt & history sharing --- .gitmodules | 3 + Makefile | 2 +- bashrc | 15 +++-- liquid.ps1 | 56 +++++++++++++++++++ liquid.theme | 134 +++++++++++++++++++++++++++++++++++++++++++++ liquidprompt | 1 + liquidpromptrc | 146 +++++++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 351 insertions(+), 6 deletions(-) create mode 100644 liquid.ps1 create mode 100644 liquid.theme create mode 160000 liquidprompt create mode 100644 liquidpromptrc diff --git a/.gitmodules b/.gitmodules index 461d881..83b09ad 100644 --- a/.gitmodules +++ b/.gitmodules @@ -7,3 +7,6 @@ [submodule "emacs.d"] path = emacs.d url = https://github.com/syl20bnr/spacemacs +[submodule "liquidprompt"] + path = liquidprompt + url = https://github.com/nojhan/liquidprompt diff --git a/Makefile b/Makefile index 4995a30..175a829 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -FILES = bashrc vimrc zshrc gitconfig screenrc commonshrc \ +FILES = bashrc vimrc zshrc gitconfig screenrc commonshrc liquidpromptrc \ gnomerc gvimrc muttrc pentadactylrc mailcap latexmkrc ctags \ i3/config i3status.conf msmtprc spacemacs emacs.d mbsyncrc authinfo diff --git a/bashrc b/bashrc index 84651d3..9565a6d 100644 --- a/bashrc +++ b/bashrc @@ -1,4 +1,4 @@ -# Copyright (C) 2004 Gabriel Ebner +# Copyright (C) 2015 Gabriel Ebner . ~/.commonshrc @@ -7,11 +7,16 @@ if [[ $- != *i* ]]; then return fi -HISTCONTROL=erasedups -HISTFILESIZE=10000 -HISTSIZE=10000 +HISTCONTROL=ignoredups:erasedups +HISTFILESIZE=100000 +HISTSIZE=100000 +HISTFILE=~/.bash_history +shopt -s histappend -PS1='\u@\h:\w\$ ' +. ~/etc/liquidprompt/liquidprompt +PROMPT_COMMAND="history -a; history -c; history -r; $PROMPT_COMMAND" + +shopt -s autocd # Bash completion for i in /etc/profile.d/bash-completion /etc/bash_completion; do diff --git a/liquid.ps1 b/liquid.ps1 new file mode 100644 index 0000000..927c8dc --- /dev/null +++ b/liquid.ps1 @@ -0,0 +1,56 @@ + +####################################### +# LIQUID PROMPT DEFAULT TEMPLATE FILE # +####################################### + +# Available features: +# LP_BATT battery +# LP_LOAD load +# LP_JOBS screen sessions/running jobs/suspended jobs +# LP_USER user +# LP_HOST hostname +# LP_PERM a colon ":" +# LP_PWD current working directory +# LP_VENV Python virtual environment +# LP_PROXY HTTP proxy +# LP_VCS the content of the current repository +# LP_ERR last error code +# LP_MARK prompt mark +# LP_TIME current time +# LP_RUNTIME runtime of last command +# LP_MARK_PREFIX user-defined prompt mark prefix (helpful if you want 2-line prompts) +# LP_PS1_PREFIX user-defined general-purpose prefix (default set a generic prompt as the window title) +# LP_PS1_POSTFIX user-defined general-purpose postfix +# LP_BRACKET_OPEN open bracket +# LP_BRACKET_CLOSE close bracket + +# Remember that most features come with their corresponding colors, +# see the README. + +# add time, jobs, load and battery +LP_PS1="${LP_PS1_PREFIX}${LP_TIME}${LP_BATT}${LP_LOAD}${LP_JOBS}" +# add user, host and permissions colon +LP_PS1="${LP_PS1}${LP_BRACKET_OPEN}${LP_USER}${LP_HOST}${LP_PERM}" + +LP_PS1="${LP_PS1}${LP_PWD}${LP_BRACKET_CLOSE}${LP_VENV}${LP_PROXY}" + +# Add VCS infos +# If root, the info has not been collected unless LP_ENABLE_VCS_ROOT +# is set. +LP_PS1="${LP_PS1}${LP_VCS}" + +# add return code and prompt mark +LP_PS1="${LP_PS1}${LP_RUNTIME}${LP_ERR}${LP_MARK_PREFIX}${LP_MARK}${LP_PS1_POSTFIX}" + +# "invisible" parts +# Get the current prompt on the fly and make it a title +LP_TITLE="$(_lp_title "$LP_PS1")" + +# Insert it in the prompt +LP_PS1="${LP_TITLE}${LP_PS1}" + +if [ -n "${IN_NIX_SHELL}" ]; then + LP_PS1="${LP_COLOR_NIX_SHELL}[nix-shell]${NO_COL} ${LP_PS1}" +fi + +# vim: set et sts=4 sw=4 tw=120 ft=sh: diff --git a/liquid.theme b/liquid.theme new file mode 100644 index 0000000..69fac27 --- /dev/null +++ b/liquid.theme @@ -0,0 +1,134 @@ + +#################################### +# LIQUID PROMPT DEFAULT THEME FILE # +#################################### + +# Special characters +# Be sure to use characters that exists in the font you use. You can use several +# characters at once. +# Below is an example of how to fallback to ASCII if the term is not Unicode-capable. +# Defaults to UTF-8 characters. +if [[ "$(locale -k LC_CTYPE | sed -n 's/^charmap="\(.*\)"/\1/p')" == *"UTF-8"* ]]; then + # If charset is UTF-8. + LP_MARK_BATTERY="⌁" # in front of the battery charge + LP_MARK_ADAPTER="⏚" # displayed when plugged + LP_MARK_LOAD="⌂" # in front of the load + LP_MARK_TEMP="θ" # in front of the temp + LP_MARK_PROXY="↥" # indicate a proxy in use + LP_MARK_HG="☿" # prompt mark in hg repositories + LP_MARK_SVN="‡" # prompt mark in svn repositories + LP_MARK_GIT="±" # prompt mark in git repositories + LP_MARK_FOSSIL="⌘" # prompt mark in fossil repositories + LP_MARK_DISABLED="⌀" # prompt mark in directory with disabled VCS info + LP_MARK_UNTRACKED="*" # if git has untracked files + LP_MARK_STASH="+" # if git has stashs + LP_MARK_SHORTEN_PATH=" … " # prompt mark in shortened paths +else + # If charset is anything else, fallback to ASCII chars + LP_MARK_BATTERY="b" + LP_MARK_ADAPTER="p" + LP_MARK_LOAD="c" + LP_MARK_TEMP="T" + LP_MARK_PROXY="^" + LP_MARK_HG="m" + LP_MARK_SVN="=" + LP_MARK_GIT="+" + LP_MARK_FOSSIL="f" + LP_MARK_DISABLED="!" + LP_MARK_UNTRACKED="*" + LP_MARK_STASH="+" + LP_MARK_SHORTEN_PATH=" ... " +fi + +LP_MARK_BRACKET_OPEN="[" # open bracket +LP_MARK_BRACKET_CLOSE="]" # close bracket +#LP_MARK_DEFAULT="" # default prompt mark +LP_MARK_PREFIX=" " # prompt mark prefix +LP_PS1_PREFIX="" +LP_PS1_POSTFIX="" + +# Colors +# Available colors are: +# BOLD, BLACK, BOLD_GRAY, WHITE, BOLD_WHITE, +# RED, BOLD_RED, WARN_RED, CRIT_RED, DANGER_RED, +# GREEN, BOLD_GREEN, YELLOW, BOLD_YELLOW, BLUE, +# BOLD_BLUE, PURPLE, PINK, CYAN, BOLD_CYAN +# Set to a null string "" if you do not want color. + +# Current working directory +LP_COLOR_PATH="$BOLD" # as normal user +LP_COLOR_PATH_ROOT="$BOLD_YELLOW" # as root + +# Color of the proxy mark +LP_COLOR_PROXY="$BOLD_BLUE" + +# Jobs count +LP_COLOR_JOB_D="$YELLOW" # Detached (aka screen sessions) +LP_COLOR_JOB_R="$BOLD_YELLOW" # Running (xterm &) +LP_COLOR_JOB_Z="$BOLD_YELLOW" # Sleeping (Ctrl-Z) + +# Last error code +LP_COLOR_ERR="$PURPLE" + +# Prompt mark +LP_COLOR_MARK="$BOLD" # as user +LP_COLOR_MARK_ROOT="$BOLD_RED" # as root + +# Current user +LP_COLOR_USER_LOGGED="" # user who logged in +LP_COLOR_USER_ALT="$BOLD" # user but not the one who logged in +LP_COLOR_USER_ROOT="$BOLD_YELLOW" # root + +# Hostname +LP_COLOR_HOST="" # local host +LP_COLOR_SSH="$BLUE" # connected via SSH +LP_COLOR_SU="$BOLD_YELLOW" # connected remotely but in new environment through su/sudo +LP_COLOR_TELNET="$WARN_RED" # connected via telnet +LP_COLOR_X11_ON="$GREEN" # connected with X11 support +LP_COLOR_X11_OFF="$YELLOW" # connected without X11 support + +# Separation mark (aka permission in the working dir) +LP_COLOR_WRITE="$GREEN" # have write permission +LP_COLOR_NOWRITE="$RED" # do not have write permission + +# VCS +LP_COLOR_UP="$GREEN" # repository is up to date / a push have been made +LP_COLOR_COMMITS="$YELLOW" # some commits have not been pushed +LP_COLOR_CHANGES="$RED" # there is some changes to commit +LP_COLOR_DIFF="$PURPLE" # number of lines impacted by current changes + +# Battery +LP_COLOR_CHARGING_ABOVE="$GREEN" # charging and above threshold +LP_COLOR_CHARGING_UNDER="$YELLOW" # charging but under threshold +LP_COLOR_DISCHARGING_ABOVE="$YELLOW" # discharging but above threshold +LP_COLOR_DISCHARGING_UNDER="$RED" # discharging and under threshold + +# Time +LP_COLOR_TIME="$BLUE" + +# Brackets inside screen/tmux +LP_COLOR_IN_MULTIPLEXER="$BOLD_BLUE" + +# Virtual environment +LP_COLOR_VIRTUALENV="$CYAN" + +# Runtime +LP_COLOR_RUNTIME="$YELLOW" + +# nix-shell indicator +LP_COLOR_NIX_SHELL="$YELLOW" + +# Color maps (battery and load levels) +# Range from 0 (nothing special) to 9 (alert) +LP_COLORMAP_0="" +LP_COLORMAP_1="$GREEN" +LP_COLORMAP_2="$BOLD_GREEN" +LP_COLORMAP_3="$YELLOW" +LP_COLORMAP_4="$BOLD_YELLOW" +LP_COLORMAP_5="$RED" +LP_COLORMAP_6="$BOLD_RED" +LP_COLORMAP_7="$WARN_RED" +LP_COLORMAP_8="$CRIT_RED" +LP_COLORMAP_9="$DANGER_RED" + +# vim: set et sts=4 sw=4 tw=120 ft=sh: diff --git a/liquidprompt b/liquidprompt new file mode 160000 index 0000000..dbe3c15 --- /dev/null +++ b/liquidprompt @@ -0,0 +1 @@ +Subproject commit dbe3c15026afdb8b35d5a758081fdf7c2c860ad0 diff --git a/liquidpromptrc b/liquidpromptrc new file mode 100644 index 0000000..73239fd --- /dev/null +++ b/liquidpromptrc @@ -0,0 +1,146 @@ + +#################################### +# LIQUID PROMPT CONFIGURATION FILE # +#################################### + +# If you want to use different themes and features, +# you can load the corresponding files here: +source ~/etc/liquid.theme +LP_PS1_FILE=~/etc/liquid.ps1 + +############# +# BEHAVIOUR # +############# + +# Maximal value under which the battery level is displayed +# Recommended value is 75 +LP_BATTERY_THRESHOLD=75 + +# Minimal value after which the load average is displayed +# Recommended value is 60 +LP_LOAD_THRESHOLD=60 + +# Minimal value after which the temperature is displayed (in degrees Celsius) +# Recommended value is 60 +LP_TEMP_THRESHOLD=60 + +# The maximum percentage of the screen width used to display the path +# Recommended value is 35 +LP_PATH_LENGTH=35 + +# How many directories to keep at the beginning of a shortened path +# Recommended value is 2 +LP_PATH_KEEP=2 + +# Do you want to display the hostname, even if not connected through network? +# Defaults to 0 (do not display hostname when locally connected) +# set to 1 if you want to always see the hostname +LP_HOSTNAME_ALWAYS=0 + +# Do you want to display the user, even if the user is the same as the one logged in? +# Defaults to 1 (always display the user) +# set to 0 if you want to hide the logged user (it will always display different users) +LP_USER_ALWAYS=1 + +# Do you want to display the percentages of load/batteries along with their +# corresponding marks? Set to 0 to only print the colored marks. +# Defaults to 1 (display percentages) +LP_PERCENTS_ALWAYS=1 + +# Do you want to use the permissions feature? +# Recommended value is 1 +LP_ENABLE_PERM=1 + +# Do you want to use the shorten path feature? +# Recommended value is 1 +LP_ENABLE_SHORTEN_PATH=1 + +# Do you want to use the proxy detection feature? +# Recommended value is 1 +LP_ENABLE_PROXY=1 + +# Do you want to use the jobs feature? +# Recommended value is 1 +LP_ENABLE_JOBS=1 + +# Do you want to use the load feature? +# Recommended value is 1 +LP_ENABLE_LOAD=1 + +# Do you want to use the battery feature? +# Recommended value is 1 +LP_ENABLE_BATT=1 + +# Do you want to use VCS features with the root account? +# Recommended value is 0 +LP_ENABLE_VCS_ROOT=0 + +# Do you want to use the Git special features? +# Recommended value is 1 +LP_ENABLE_GIT=1 + +# Do you want to use the Subversion special features? +# Recommended value is 1 +LP_ENABLE_SVN=1 + +# Do you want to use the Mercurial special features? +# Recommended value is 1 +LP_ENABLE_HG=1 + +# Do you want to use the Fossil special features? +# Recommended value is 1 +LP_ENABLE_FOSSIL=1 + +# Do you want to use the Bazaar special features? +# Recommanded value is 1 +LP_ENABLE_BZR=1 + +# Show time of the last prompt display +# Recommended value is 0 +LP_ENABLE_TIME=0 + +# Show runtime of the last command if over LP_RUNTIME_THRESHOLD +# Recommended value is 0 +LP_ENABLE_RUNTIME=0 + +# Minimal runtime to be displayed +# Recommended value is 2 +LP_RUNTIME_THRESHOLD=2 + +# Display the virtualenv that is currently activated, if any +# Recommended value is 1 +LP_ENABLE_VIRTUALENV=1 + +# Display the enabled software collections, if any +# Recommended value is 1 +LP_ENABLE_SCLS=1 + +# Show average system temperature +LP_ENABLE_TEMP=1 + +# When showing time, use an analog clock instead of numeric values. +# The analog clock is "accurate" to the nearest half hour. +# You must have a unicode-capable terminal and a font with the "CLOCK" +# characters. +# Recommended value is 0 +LP_TIME_ANALOG=0 + +# Use the prompt as the title of the terminal window +# The content is not customizable, the implementation is very basic, +# and this may not work properly on exotic terminals, thus the +# recommended value is 0 +# See LP_TITLE_OPEN and LP_TITLE_CLOSE to change escape characters to adapt this +# feature to your specific terminal. +LP_ENABLE_TITLE=0 + +# Enable Title for screen and byobu +LP_ENABLE_SCREEN_TITLE=0 + +# Use differents colors for differents hosts you SSH in +LP_ENABLE_SSH_COLORS=0 + +# Specify a list of complete and colon (":") separated paths in which, all vcs +# will be disabled +LP_DISABLED_VCS_PATH="" + +# vim: set et sts=4 sw=4 tw=120 ft=sh: