Created
June 23, 2012 22:10
-
-
Save monokrome/2980278 to your computer and use it in GitHub Desktop.
My.bash_profile for Arch Linux
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
source /etc/bash_completion.d/git | |
# Any directories that should additionally be treated as prefixes. | |
additional_prefixes=( | |
"/usr/local" | |
"${HOME}" | |
) | |
# Since some things install other things in silly places | |
extra_paths=( | |
"./bin" | |
"./node_modules/.bin" | |
) | |
# Specific additions to PATH | |
for next_path in ${extra_paths[@]}; do | |
if [[ -d "${next_path}" ]]; then | |
PATH="${next_path}:${PATH}" | |
fi | |
done | |
# Any additional full installation prefixes. | |
for next_prefix in ${additional_prefixes[@]}; do | |
if [[ -d "${next_prefix}/bin" ]]; then | |
PATH="${next_prefix}/bin:${PATH}" | |
fi | |
done | |
# Thanks to @kroogs for the idea of making the text red on errors :D | |
# This is a global reference to be used in order to know the last return | |
# code from within functions. | |
last_response_code=$? | |
# Formats the provided text into something a bit more striking. | |
error_text () { echo "\033[31m${@}\033[0m"; } | |
# Generates our PS1 when passed the last program's response code, and | |
# whatever text we want in the PS1. | |
make_PS1 () { | |
PS1_git=$(__git_ps1 "(%s) ") | |
if [ ${last_response_code} = 0 ]; then | |
echo "${PS1_git}${@} "; | |
else | |
echo -e "${PS1_git}`error_text ${@}` "; | |
fi | |
} | |
# A PS1. | |
export PS1='`last_response_code=$?;make_PS1 \W`' | |
ls () { | |
clear | |
command ls $@ | |
echo | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment