Skip to content

Commit

Permalink
Add curory support for mingw based bash... git...
Browse files Browse the repository at this point in the history
  • Loading branch information
weikinhuang committed Sep 19, 2012
1 parent b290e06 commit 358641b
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 48 deletions.
10 changes: 10 additions & 0 deletions .bashrc
Expand Up @@ -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"
;;
Expand Down
39 changes: 36 additions & 3 deletions .dotenv/.aliases
Expand Up @@ -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"
Expand Down
26 changes: 15 additions & 11 deletions .dotenv/.prompt
Expand Up @@ -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='
Expand Down Expand Up @@ -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"
Expand Down
13 changes: 0 additions & 13 deletions .dotenv/cygwin/.aliases
Expand Up @@ -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"

Expand Down
8 changes: 7 additions & 1 deletion .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
7 changes: 0 additions & 7 deletions .dotenv/darwin/.aliases
Expand Up @@ -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
13 changes: 0 additions & 13 deletions .dotenv/linux/.aliases
Expand Up @@ -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"

0 comments on commit 358641b

Please sign in to comment.