Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # ~/.bashrc: executed by bash(1) for non-login shells.
- # see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
- # for examples
- # We use preexec and precmd hook functions for Bash
- # If you have anything that's using the Debug Trap or PROMPT_COMMAND
- # change it to use preexec or precmd
- # See also https://github.com/rcaloras/bash-preexec
- # If not running interactively, don't do anything
- case $- in
- *i*) ;;
- *) return;;
- esac
- # don't put duplicate lines or lines starting with space in the history.
- # See bash(1) for more options
- HISTCONTROL=ignoreboth
- # append to the history file, don't overwrite it
- shopt -s histappend
- # for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
- HISTSIZE=1000
- HISTFILESIZE=2000
- # check the window size after each command and, if necessary,
- # update the values of LINES and COLUMNS.
- shopt -s checkwinsize
- # If set, the pattern "**" used in a pathname expansion context will
- # match all files and zero or more directories and subdirectories.
- #shopt -s globstar
- # make less more friendly for non-text input files, see lesspipe(1)
- [ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
- # set variable identifying the chroot you work in (used in the prompt below)
- if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
- debian_chroot=$(cat /etc/debian_chroot)
- fi
- # set a fancy prompt (non-color, unless we know we "want" color)
- case "$TERM" in
- xterm-color|*-256color) color_prompt=yes;;
- esac
- # uncomment for a colored prompt, if the terminal has the capability; turned
- # off by default to not distract the user: the focus in a terminal window
- # should be on the output of commands, not on the prompt
- #force_color_prompt=yes
- if [ -n "$force_color_prompt" ]; then
- if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
- # We have color support; assume it's compliant with Ecma-48
- # (ISO/IEC-6429). (Lack of such support is extremely rare, and such
- # a case would tend to support setf rather than setaf.)
- color_prompt=yes
- else
- color_prompt=
- fi
- fi
- if [ "$color_prompt" = yes ]; then
- PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
- else
- PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
- fi
- unset color_prompt force_color_prompt
- # enable color support of ls and also add handy aliases
- if [ -x /usr/bin/dircolors ]; then
- test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
- alias ls='ls --color=auto'
- #alias dir='dir --color=auto'
- #alias vdir='vdir --color=auto'
- alias grep='grep --color=auto'
- alias fgrep='fgrep --color=auto'
- alias egrep='egrep --color=auto'
- fi
- # colored GCC warnings and errors
- #export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
- # some more ls aliases
- alias ll='ls -alF'
- alias la='ls -A'
- alias l='ls -CF'
- ### Start agent
- eval `ssh-agent -s`
- ### Personal Key
- # ssh-add ~/.ssh/freenologies-server-key.pem
- ### Other Key
- # ssh-add ~/.ssh/drv
- function load_freenologies(){
- destroy_ssh
- ssh-add ~/.ssh/freenologies-server-key.pem && git config --global user.email "glisterkaiser@gmail.com" && git config --global user.name "Jorge Fuentes"
- }
- function load_drv(){
- destroy_ssh
- ssh-add ~/.ssh/drv && git config --global user.email "glisterkaiser@gmail.com" && git config --global user.name "Jorge Fuentes"
- }
- # Add an "alert" alias for long running commands. Use like so:
- # sleep 10; alert
- alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
- # Alias definitions.
- # You may want to put all your additions into a separate file like
- # ~/.bash_aliases, instead of adding them here directly.
- # See /usr/share/doc/bash-doc/examples in the bash-doc package.
- if [ -f ~/.bash_aliases ]; then
- . ~/.bash_aliases
- fi
- # enable programmable completion features (you don't need to enable
- # this, if it's already enabled in /etc/bash.bashrc and /etc/profile
- # sources /etc/bash.bashrc).
- if ! shopt -oq posix; then
- if [ -f /usr/share/bash-completion/bash_completion ]; then
- . /usr/share/bash-completion/bash_completion
- elif [ -f /etc/bash_completion ]; then
- . /etc/bash_completion
- fi
- fi
- # If this is an xterm set more declarative titles
- # "dir: last_cmd" and "actual_cmd" during execution
- # If you want to exclude a cmd from being printed see line 156
- case "$TERM" in
- xterm*|rxvt*)
- PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\$(print_title)\a\]$PS1"
- __el_LAST_EXECUTED_COMMAND=""
- print_title ()
- {
- __el_FIRSTPART=""
- __el_SECONDPART=""
- if [ "$PWD" == "$HOME" ]; then
- __el_FIRSTPART=$(gettext --domain="pantheon-files" "Home")
- else
- if [ "$PWD" == "/" ]; then
- __el_FIRSTPART="/"
- else
- __el_FIRSTPART="${PWD##*/}"
- fi
- fi
- if [[ "$__el_LAST_EXECUTED_COMMAND" == "" ]]; then
- echo "$__el_FIRSTPART"
- return
- fi
- #trim the command to the first segment and strip sudo
- if [[ "$__el_LAST_EXECUTED_COMMAND" == sudo* ]]; then
- __el_SECONDPART="${__el_LAST_EXECUTED_COMMAND:5}"
- __el_SECONDPART="${__el_SECONDPART%% *}"
- else
- __el_SECONDPART="${__el_LAST_EXECUTED_COMMAND%% *}"
- fi
- printf "%s: %s" "$__el_FIRSTPART" "$__el_SECONDPART"
- }
- put_title()
- {
- __el_LAST_EXECUTED_COMMAND="${BASH_COMMAND}"
- printf "\033]0;%s\007" "$1"
- }
- # Show the currently running command in the terminal title:
- # http://www.davidpashley.com/articles/xterm-titles-with-bash.html
- update_tab_command()
- {
- # catch blacklisted commands and nested escapes
- case "$BASH_COMMAND" in
- *\033]0*|update_*|echo*|printf*|clear*|cd*)
- __el_LAST_EXECUTED_COMMAND=""
- ;;
- *)
- put_title "${BASH_COMMAND}"
- ;;
- esac
- }
- preexec_functions+=(update_tab_command)
- ;;
- *)
- ;;
- esac
- ### Piperita Theme ###
- # Theme by Jacob Tomlinson
- # https://github.com/killfall/terminal-piperita
- # Environment variables to set prompt format and color
- export COLOR_BOLD="\[\e[1m\]"
- export COLOR_DEFAULT="\[\e[0m\]"
- export COLOR_WHITE="\[\033[m\]"
- export COLOR_GREEN="\[\033[32m\]"
- export COLOR_YELLOW="\[\033[33;1m\]"
- export COLOR_RED="\[\e[31m\]"
- export COLOR_BLUE="\[\033[36m\]"
- # Determine active Python virtualenv details.
- function set_virtualenv () {
- if test -z "$VIRTUAL_ENV" ; then
- PYTHON_VIRTUALENV=""
- else
- PYTHON_VIRTUALENV="${BLUE}[`basename \"$VIRTUAL_ENV\"`]${COLOR_NONE} "
- fi
- }
- # get current branch in git repo
- function parse_git_branch() {
- BRANCH=$(git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/')
- if [ ! "${BRANCH}" == "" ]
- then
- STAT=$(parse_git_dirty)
- echo -e " [${BRANCH}${STAT}]"
- else
- echo ""
- fi
- }
- # get current status of git repo
- function parse_git_dirty {
- status=$(git status 2>&1 | tee)
- dirty=$(echo -n "${status}" 2> /dev/null | grep "modified:" &> /dev/null; echo "$?")
- untracked=$(echo -n "${status}" 2> /dev/null | grep "Untracked files" &> /dev/null; echo "$?")
- ahead=$(echo -n "${status}" 2> /dev/null | grep "Your branch is ahead of" &> /dev/null; echo "$?")
- newfile=$(echo -n "${status}" 2> /dev/null | grep "new file:" &> /dev/null; echo "$?")
- renamed=$(echo -n "${status}" 2> /dev/null | grep "renamed:" &> /dev/null; echo "$?")
- deleted=$(echo -n "${status}" 2> /dev/null | grep "deleted:" &> /dev/null; echo "$?")
- bits=''
- if [ "${renamed}" == "0" ]; then
- bits=">${bits}"
- fi
- if [ "${ahead}" == "0" ]; then
- bits="*${bits}"
- fi
- if [ "${newfile}" == "0" ]; then
- bits="+${bits}"
- fi
- if [ "${untracked}" == "0" ]; then
- bits="?${bits}"
- fi
- if [ "${deleted}" == "0" ]; then
- bits="x${bits}"
- fi
- if [ "${dirty}" == "0" ]; then
- bits="!${bits}"
- fi
- if [ ! "${bits}" == "" ]; then
- echo " ${bits}"
- else
- echo ""
- fi
- }
- prompt_cmd () {
- # Set the PYTHON_VIRTUALENV variable.
- set_virtualenv
- LAST_STATUS=$?
- PS1="${PYTHON_VIRTUALENV}"
- # Test if user is root and set user color appropriately
- if [[ $(id -u) == 0 ]]
- then
- PS1+="$COLOR_RED"
- else
- PS1+="$COLOR_BLUE"
- fi
- PS1+="\u"
- PS1+="$COLOR_WHITE@"
- PS1+="$COLOR_GREEN\h"
- PS1+="$COLOR_WHITE:"
- PS1+="$COLOR_YELLOW\W"
- # Add git branch and status if applicable
- if type parse_git_branch > /dev/null 2>&1; then
- PS1+=$(parse_git_branch)
- fi
- # Test return code and colour the $ red if fail
- if [[ $LAST_STATUS = 0 ]]; then
- PS1+="$COLOR_WHITE"
- else
- PS1+="$COLOR_RED"
- fi
- PS1+='\$ '
- PS1+="$COLOR_WHITE"
- }
- PROMPT_COMMAND='prompt_cmd'
- export CLICOLOR=1
- export TERM=xterm-256color
- ### End Piperita Theme ###
- ### ssh agent setup
- # eval `ssh-agent -s`
- ### dtH Key
- # ssh-add ~/.ssh/id_rsa_moodhack
- ### Personal Key
- # ssh-add ~/.ssh/id_rsa_personal
- function destroy_ssh(){
- ### Agent destroy
- echo -e "SSH REMOVIDA(S)"
- eval `ssh-agent -s`
- }
- function all_ssh(){
- ls -al ~/.ssh
- }
- function current_ssh(){
- ssh-add -l
- }
- function load_ssh_personal(){
- ### --- Jorge Personal
- destroy_ssh
- echo -e "SSH PERSONAL CARGADA"
- ssh-add ~/.ssh/id_rsa_personal && git config --global user.email "glisterkaiser@gmail.com" && git config --global user.name "Jorge Fuentes"
- }
- function load_ssh_jorge_dth(){
- ### --- Jorge DevToHack
- destroy_ssh
- echo -e "SSH JORGE DTH CARGADA"
- ssh-add ~/.ssh/id_rsa_moodhack && git config --global user.email "jorgefuentes@devtohack.com" && git config --global user.name "Jorge Fuentes"
- }
- function load_ssh_nelson_dth(){
- ### --- Nelson DevToHack
- destroy_ssh
- echo -e "SSH NELSON DTH CARGADA"
- ssh-add ~/.ssh/id_rsa_nelson && git config --global user.email "nelsonmarcano@devtohack.com" && git config --global user.name "Nelson Marcano"
- }
- load_ssh_jorge_dth
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement