Let's install linuxbrew and pyenv
sh -c "$(curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/install.sh)"
brew install pyenv pyenv-virtualenv pyenv-which-ext
pyenv install miniconda3-latest
pyenv global miniconda3-latest
then we need to add into .bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/.local/bin:$HOME/bin
export PATH
# Not all machines at snm work with brew, and example of three of them.
if [[ $(hostname) =~ a00769|a00643|a00710|a00789|a00790|a00810|a00811|a00812|a00813|a00814|a00815 ]]; then export PATH="${HOME}/.linuxbrew/bin:$PATH"
export MANPATH="${HOME}/.linuxbrew/share/man:$MANPATH"
export INFOPATH="${HOME}/.linuxbrew/share/info:$INFOPATH"
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
if which pyenv-virtualenv-init > /dev/null; then eval "$(pyenv virtualenv-init -)"; fi
. ${HOME}/.pyenv/versions/miniconda3-latest/etc/profile.d/conda.sh
#conda activate
export PYENV_VIRTUALENV_DISABLE_PROMPT=1
pyenvVirtualenvUpdatePrompt() {
RED='\[\e[0;31m\]'
GREEN='\[\e[0;32m\]'
BLUE='\[\e[0;34m\]'
RESET='\[\e[0m\]'
[ -z "$PYENV_VIRTUALENV_ORIGINAL_PS1" ] && export PYENV_VIRTUALENV_ORIGINAL_PS1="$PS1"
[ -z "$PYENV_VIRTUALENV_GLOBAL_NAME" ] && export PYENV_VIRTUALENV_GLOBAL_NAME="$(pyenv global)"
VENV_NAME="$(pyenv version-name)"
VENV_NAME="${VENV_NAME##*/}"
GLOBAL_NAME="$PYENV_VIRTUALENV_GLOBAL_NAME"
# non-global versions:
COLOR="$BLUE"
# global version:
[ "$VENV_NAME" == "$GLOBAL_NAME" ] && COLOR="$RED"
# virtual envs:
[ "${VIRTUAL_ENV##*/}" == "$VENV_NAME" ] && COLOR="$GREEN"
if [ -z "$COLOR" ]; then
PS1="$PYENV_VIRTUALENV_ORIGINAL_PS1"
else
#conda activate
PS1="($CONDA_DEFAULT_ENV)($COLOR${VENV_NAME}$RESET)$PYENV_VIRTUALENV_ORIGINAL_PS1"
fi
export PS1
}
export PROMPT_COMMAND="$PROMPT_COMMAND pyenvVirtualenvUpdatePrompt;"
fi
and comment in .bashrc
# .bashrc
# Source global definitions
# Uncomment the following line if you don't like systemctl's auto-paging feature:
# export SYSTEMD_PAGER=
# User specific aliases and functions
export COLOR_BOLD="\[\033[1;35m\]"
export COLOR_DEFAULT="\[\e[0m\]"
export PROMPT_DIRTRIM=8
export HNAME=$(grep PS1= /etc/profile.d/bashpromt.sh | sed -r -e 's|PS1=\S+@(\S+)\s.*|\1|')
export PS1="$COLOR_BOLD[\u@$HNAME \w]\$ \e[m\n"
export HISTCONTROL=ignoredups:erasedups
export HISTSIZE=100000000000
export HISTFILESIZE=10000000000
shopt -s histappend
HISTTIMEFORMAT="%d/%m/%y %T "
log_bash_persistent_history()
{
[[
$(history 1) =~ ^\ *[0-9]+\ +([^\ ]+\ [^\ ]+)\ +(.*)$
]]
local date_part="${BASH_REMATCH[1]}"
local command_part="${BASH_REMATCH[2]}"
local host="$(grep PS1= /etc/profile.d/bashpromt.sh | sed -r -e 's|PS1=\S+@(\S+)\s.*|\1|')"
if [ "$command_part" != "$PERSISTENT_HISTORY_LAST" ]
then
echo $host $date_part "|" "$command_part" >> ~/.persistent_history
export PERSISTENT_HISTORY_LAST="$command_part"
fi
}
# Stuff to do on PROMPT_COMMAND
run_on_prompt_command()
{
log_bash_persistent_history
}
export PROMPT_COMMAND="history -a; history -c; history -r; run_on_prompt_command; $PROMPT_COMMAND"
#bash history on multiple terminal windows
#avoid duplicates
#append history entries
alias phgrep='cat ~/.persistent_history|grep --color'
alias hgrep='history|grep --color'
export STAY_OFF_MY_LAWN=1
alias fix='reset; stty sane; tput rs1; clear; echo -e "\033c"'