Skip to content

Instantly share code, notes, and snippets.

@jarrodhroberson
Last active April 24, 2018 14:02
Show Gist options
  • Save jarrodhroberson/f24591b415fabc8f3c60c945a83f594c to your computer and use it in GitHub Desktop.
Save jarrodhroberson/f24591b415fabc8f3c60c945a83f594c to your computer and use it in GitHub Desktop.
bash scripts
alias ll='ls -lha --color=always'
alias subl='subl --touch --cygstart --'
#!/usr/bin/env bash
# look up color codes for our terminal rather than assuming ANSI
declare -r red=$(tput setaf 1)
declare -r green=$(tput setaf 2)
declare -r white=$(tput setaf 9)
declare -r aqua=$(tput setaf 6)
declare -r reset=$(tput sgr0)
colorize_msg() {
printf -v $1 "\[%s\]%s" ${2} ${3}
}
set_prompt() {
declare prompt_pwd=""
# only rerun this code when changing directories!
if [[ last_prompt_pwdL != $PWD ]]; then
declare -g last_prompt_pwdL=$PWD # logical path
declare -r last_prompt_pwdP=$(pwd -P) # physical path
if [[ $last_prompt_pwdL = $last_prompt_pwdP ]]; then
colorize_msg prompt_pwd $green $last_prompt_pwdL
else
colorize_msg prompt_pwd $red $last_prompt_pwdP
fi
# ...actually could have just "return"ed above, but this way we can change other
# aspects of the prompt even when we don't need to do a new directory lookup.
declare prompt=""
declare msg=""
colorize_msg msg $white "["
prompt+=$msg
colorize_msg msg $aqua "\u"
prompt+=$msg
colorize_msg msg $red "@"
prompt+=$msg
colorize_msg msg $aqua"\h"
prompt+=$msg
colorize_msg msg $white "] ["
prompt+=$msg
prompt+=${prompt_pwd}
colorize_msg msg $white "]"
prompt+=$msg
prompt+="${reset}\n"
PS1=$prompt
fi
}
# User dependent .bash_profile file
# source the users bashrc if it exists
if [ -f "${HOME}/.bashrc" ] ; then
source "${HOME}/.bashrc"
fi
# Set PATH so it includes user's private bin if it exists
if [ -d "${HOME}/bin" ] ; then
PATH="${HOME}/bin:${PATH}"
fi
if [ -f "${HOME}/.bash_aliases" ] ; then
source "${HOME}/.bash_aliases"
fi
if [ -f "${HOME}/.bash_functions" ] ; then
source "${HOME}/.bash_functions"
fi
# Set MANPATH so it includes users' private man if it exists
if [ -d "${HOME}/man" ]; then
MANPATH="${HOME}/man:${MANPATH}"
fi
# Set INFOPATH so it includes users' private info if it exists
if [ -d "${HOME}/info" ]; then
INFOPATH="${HOME}/info:${INFOPATH}"
fi
# # Set PATH so it includes Sublime Text 3 if it exists
if [ -f "${HOME}/bin/subl.sh" ] ; then
PATH="${HOME}/bin/subl.sh:${PATH}"
fi
export CDPATH=/d/svn/FIVESTAR_143455/branches/development/:.
# Add Sencha Cmd to the path
PATH="${HOME}/bin/Sencha/Cmd:${PATH}"
PROMPT_COMMAND=set_prompt
PS1=$prompt
if [ -f "/etc/.bashrc" ]; then
source /etc/.bashrc
fi
MAVEN_HOME="${HOME}/bin/apache-maven-3.5.3"
PATH="${MAVEN_HOME}bin:${PATH}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment