diff --git a/.bashrc b/.bashrc index 9ae486e..eb9b447 100644 --- a/.bashrc +++ b/.bashrc @@ -24,6 +24,16 @@ case "$(uname -s)" in CYGWIN* ) DOTENV="cygwin" ;; + MINGW32_NT* ) + # we'll just pretend to use the cygwin functions + DOTENV="cygwin" + # we can only have monochrome prompts + _PS1_MONOCHROME=1 + # force the usage of /bin/bash instead of /bin/sh + if [ $BASH == '/bin/sh' ]; then + BASH='/bin/bash' + fi + ;; Darwin ) DOTENV="darwin" ;; diff --git a/.dotenv/.aliases b/.dotenv/.aliases index 6faa009..6d07660 100644 --- a/.dotenv/.aliases +++ b/.dotenv/.aliases @@ -22,9 +22,42 @@ alias cp="cp -i" alias mv="mv -i" # Colorize grep matches -alias grep="grep --color=auto" -alias fgrep="fgrep --color=auto" -alias egrep="egrep --color=auto" +# test if color is supported +echo | grep --color=auto > /dev/null 2>&1 +# if it is, always add color +if [[ $? == 0 ]]; then + alias grep="grep --color=auto" + alias fgrep="fgrep --color=auto" + alias egrep="egrep --color=auto" +fi + +# Detect which `ls` flavor is in use +if ls --color > /dev/null 2>&1; then + # GNU ls + LS_COLOR_FLAG="--color" +else + # darwin ls + LS_COLOR_FLAG="-G" +fi +# Specialized directory listings +alias la="ls -lA ${LS_COLOR_FLAG}" +alias ll="ls -l ${LS_COLOR_FLAG}" +alias l.="ls -d ${LS_COLOR_FLAG} .*" +alias ls="ls ${LS_COLOR_FLAG}" +alias lf="ls -l ${LS_COLOR_FLAG} | grep '^d'" + +# check if we can display in long format +if ls --format=long > /dev/null 2>&1; then + alias dir="ls ${LS_COLOR_FLAG} --format=vertical" + alias vdir="ls ${LS_COLOR_FLAG} --format=long" +fi + +unset LS_COLOR_FLAG + +# allow which command to expand +if which --tty-only which > /dev/null 2>&1; then + alias which="alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde" +fi # shortcuts to custom xargs pipes and process commands and other functions alias els="execlist" diff --git a/.dotenv/.prompt b/.dotenv/.prompt index 09a528d..b9b079c 100644 --- a/.dotenv/.prompt +++ b/.dotenv/.prompt @@ -36,17 +36,21 @@ PS1_COLOR_LOAD=' # If we want a monochrome bash prompt if [[ -n $_PS1_MONOCHROME ]]; then +# quick reference to colors + PS1_COLOR_GREY= + PS1_COLOR_DARK_GREY= + # colors for individual parts of the bash prompt - PS1_COLOR_EXIT_ERROR='' - PS1_COLOR_BG_JOBS='' - PS1_COLOR_USER='' - PS1_COLOR_HOST='' - PS1_COLOR_HOST_SCREEN=$PS1_COLOR_UNDERLINE'' - PS1_COLOR_WORK_DIR='' - PS1_COLOR_WORK_DIRINFO='' - PS1_COLOR_GIT='' - PS1_COLOR_TIME_AM='' - PS1_COLOR_TIME_PM='' + PS1_COLOR_EXIT_ERROR= + PS1_COLOR_BG_JOBS= + PS1_COLOR_USER= + PS1_COLOR_HOST= + PS1_COLOR_HOST_SCREEN=$PS1_COLOR_UNDERLINE + PS1_COLOR_WORK_DIR= + PS1_COLOR_WORK_DIRINFO= + PS1_COLOR_GIT= + PS1_COLOR_TIME_AM= + PS1_COLOR_TIME_PM= # load avg colorization PS1_COLOR_LOAD=' @@ -97,7 +101,7 @@ function __ps1_dir_wrapper() { if [[ $(( $__ps1_var_date - $__ps1_var_dirinforeloadtime )) -gt $__ps1_var_dirinfotime || "$PWD" != "$__ps1_var_dirinfoprev" ]]; then lsout=$(/bin/ls -lAh) lsnum=$(($(echo "${lsout}" | \wc -l | \sed "s/ //g") - 1)) - lssize="$(echo "${lsout}" | \grep -m 1 total | \sed "s/total //")b" + lssize="$(echo "${lsout}" | \grep '^total ' | \sed 's/^total //')b" __ps1_var_dirinfo="${lsnum}|${lssize}" __ps1_var_dirinfoprev="$PWD" diff --git a/.dotenv/cygwin/.aliases b/.dotenv/cygwin/.aliases index 1b1ce8d..f6663a0 100755 --- a/.dotenv/cygwin/.aliases +++ b/.dotenv/cygwin/.aliases @@ -11,19 +11,6 @@ alias p="cd ~/Documents/Projects" alias open="cygstart" alias md5="md5sum" -# Specialized directory listings -alias la="ls -lA --color=auto" 2> /dev/null -alias ll="ls -l --color=auto" 2> /dev/null -alias l.="ls -d .* --color=auto" 2> /dev/null -alias ls="ls --color=auto" 2> /dev/null -alias lf="ls -l --color=auto | grep '^d'" 2> /dev/null - -alias dir="ls --color=auto --format=vertical" -alias vdir="ls --color=auto --format=long" - -# allow which command to expand -alias which="alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde" - # Ability to kill windows applications alias kill="/bin/kill.exe -f" diff --git a/.dotenv/cygwin/.exports b/.dotenv/cygwin/.exports index 13f9121..d043b88 100755 --- a/.dotenv/cygwin/.exports +++ b/.dotenv/cygwin/.exports @@ -1,2 +1,8 @@ # Number of threads that is available -export PROC_CORES=$(grep "^processor" -c /proc/cpuinfo) +if [[ -r /proc/cpuinfo ]]; then + # for cygwin based environments + export PROC_CORES=$(grep "^processor" -c /proc/cpuinfo) +else + # for mingw based environments + export PROC_CORES=$(/c/Windows/syswow64/WindowsPowerShell/v1.0/powershell.exe get-wmiobject Win32_ComputerSystem\|format-list *proc* | grep 'Logical' | sed 's/^.\+ : //') +fi diff --git a/.dotenv/darwin/.aliases b/.dotenv/darwin/.aliases index bee0bd4..b2d5ee6 100755 --- a/.dotenv/darwin/.aliases +++ b/.dotenv/darwin/.aliases @@ -3,10 +3,3 @@ alias wcopy="xclip --in" alias wpaste="xclip --out" # Shortcuts - -# Specialized directory listings -alias la="ls -lAG" 2> /dev/null -alias ll="ls -lG" 2> /dev/null -alias l.="ls -d .* -G" 2> /dev/null -alias ls="ls -G" 2> /dev/null -alias lf="ls -lG | grep '^d'" 2> /dev/null diff --git a/.dotenv/linux/.aliases b/.dotenv/linux/.aliases index 224de83..912a681 100755 --- a/.dotenv/linux/.aliases +++ b/.dotenv/linux/.aliases @@ -9,16 +9,3 @@ alias open="nautilus" # useful shortcuts alias md5="md5sum" - -# Specialized directory listings -alias la="ls -lA --color=auto" 2> /dev/null -alias ll="ls -l --color=auto" 2> /dev/null -alias l.="ls -d .* --color=auto" 2> /dev/null -alias ls="ls --color=auto" 2> /dev/null -alias lf="ls -l --color=auto | grep '^d'" 2> /dev/null - -alias dir="ls --color=auto --format=vertical" -alias vdir="ls --color=auto --format=long" - -# allow which command to expand -alias which="alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde"