Browse Source

Merge branch 'master' of github.com:10sr/dotfiles

pull/1/head
10sr 11 years ago
parent
commit
3fbf3d1d2c
2 changed files with 46 additions and 42 deletions
  1. +0
    -6
      setup.sh
  2. +46
    -36
      shrc

+ 0
- 6
setup.sh View File

@@ -42,12 +42,6 @@ iswindows=$__iswindows
isdarwin=$__isdarwin isdarwin=$__isdarwin
islinux=$__islinux islinux=$__islinux


alias ismsys=$__ismsys
alias iscygwin=$__iscygwin
alias iswindows=$__iswindows
alias isdarwin=$__isdarwin
alias islinux=$__islinux

__homelocal="$__homelocal" __homelocal="$__homelocal"
__homevar="$__homevar" __homevar="$__homevar"
__EOC__ __EOC__


+ 46
- 36
shrc View File

@@ -38,7 +38,7 @@ __safe_add_path_r "/c/mingw/bin"
__safe_add_path_r "/c/mingw/msys/1.0/bin" __safe_add_path_r "/c/mingw/msys/1.0/bin"


# macports coreutils # macports coreutils
# isdarwin cannot be used it is not defined yet
# $isdarwin cannot be used it is not defined yet
__safe_add_path_l "/opt/local/bin" __safe_add_path_l "/opt/local/bin"
__safe_add_path_l "/opt/local/sbin" __safe_add_path_l "/opt/local/sbin"
__safe_add_path_l "/opt/local/libexec/gnubin" __safe_add_path_l "/opt/local/libexec/gnubin"
@@ -122,7 +122,7 @@ export LC_MESSAGES=C
export LC_TIME=C export LC_TIME=C


export TERMCAP="${TERMCAP}:vb=" export TERMCAP="${TERMCAP}:vb="
ismsys && export HOSTNAME
$ismsys && export HOSTNAME
# export ENV=~/.shrc # export ENV=~/.shrc


if ! with_coreutils if ! with_coreutils
@@ -133,7 +133,7 @@ else
null type dircolors && eval `dircolors` null type dircolors && eval `dircolors`
fi fi


if false iswindows
if false $iswindows
then then
export PAGER='tr -d \\r | less' export PAGER='tr -d \\r | less'
else else
@@ -185,12 +185,14 @@ __match "$TMP" "${USER}-tmp" >/dev/null || export TMP="${TMP}/${USER}-tmp"
export TEMP="$TMP" export TEMP="$TMP"
test -d "$TMP" || install -d "$TMP" test -d "$TMP" || install -d "$TMP"


! iswindows && null type stty && {
if ! $iswindows && null type stty
then
stty stop undef # unbind C-s to stop displaying output stty stop undef # unbind C-s to stop displaying output
# stty erase '^h' # stty erase '^h'
}
fi


if iswindows; then
if $iswindows
then
export USER=$USERNAME export USER=$USERNAME
fi fi


@@ -202,7 +204,7 @@ fi
###################### ######################
# Print welcome messages # Print welcome messages


iswindows && alias tty="echo cmd.exe"
$iswindows && alias tty="echo cmd.exe"
type fortune >/dev/null 2>&1 && { type fortune >/dev/null 2>&1 && {
fortune fortune
echo echo
@@ -233,11 +235,11 @@ __safe_alias(){
alias "$1" alias "$1"
} }


( ! with_coreutils && isdarwin ) || test "$TERM" = dumb || \
( ! with_coreutils && $isdarwin ) || test "$TERM" = dumb || \
_coloroption=" --color=auto" _coloroption=" --color=auto"
( ! with_coreutils && isdarwin ) || iswindows || \
( ! with_coreutils && $isdarwin ) || $iswindows || \
_timeoption=" --time-style=long-iso" _timeoption=" --time-style=long-iso"
( ! with_coreutils && isdarwin ) || _hideoption=" --hide=[A-Z]*" # do not use
( ! with_coreutils && $isdarwin ) || _hideoption=" --hide=[A-Z]*" # do not use


_timeformat_iso="%Y-%m-%dT%H:%M:%S%z" _timeformat_iso="%Y-%m-%dT%H:%M:%S%z"
_timeformat_rfc2822="%a, %d %b %Y %T %z" _timeformat_rfc2822="%a, %d %b %Y %T %z"
@@ -247,7 +249,7 @@ alias datenum="date +$_timeformat_num"
alias ls="ls -hCF${_coloroption}${_timeoption}" alias ls="ls -hCF${_coloroption}${_timeoption}"
# export GREP_OPTIONS="" # export GREP_OPTIONS=""
alias gr="grep -n --color=always" alias gr="grep -n --color=always"
iswindows && alias grep="grep -n"
$iswindows && alias grep="grep -n"
# alias ll="ls -l" # alias ll="ls -l"
# alias la="ls -A" # alias la="ls -A"
# alias lla="ls -Al" # alias lla="ls -Al"
@@ -296,14 +298,18 @@ __safe_alias htags="htags --xhtml --symbol --line-number \
__safe_alias au=aunpack __safe_alias au=aunpack
__safe_alias lv="lv|less" __safe_alias lv="lv|less"
__safe_alias rs="rsync --progress --itemize-changes --compress" __safe_alias rs="rsync --progress --itemize-changes --compress"
iscygwin && {
if $iscygwin
then
__my_wget_options=" --no-check-certificate" __my_wget_options=" --no-check-certificate"
__safe_alias wget="wget $__my_wget_options" __safe_alias wget="wget $__my_wget_options"
}
fi


isdarwin && alias updatedb="LC_ALL=C updatedb"
# do not use locate installed by macports
isdarwin && test -x /usr/bin/locate && alias locate="/usr/bin/locate"
if $isdarwin
then
alias updatedb="LC_ALL=C updatedb"
# do not use locate installed by macports
test -x /usr/bin/locate && alias locate="/usr/bin/locate"
fi


cd(){ cd(){
command cd "$@" command cd "$@"
@@ -314,7 +320,7 @@ cd(){
alias pad=notepad alias pad=notepad
__safe_alias pad=gedit __safe_alias pad=gedit
__safe_alias pad=leafpad __safe_alias pad=leafpad
isdarwin && alias pad="open -e"
$isdarwin && alias pad="open -e"


__safe_alias wic=wicd-curses __safe_alias wic=wicd-curses
__safe_alias wil="wicd-cli -y -l | head" __safe_alias wil="wicd-cli -y -l | head"
@@ -385,11 +391,11 @@ null type port && {
{ sudo port -v upgrade outdated; }" { sudo port -v upgrade outdated; }"
} }


if iscygwin; then
if $iscygwin
then
null type windate || \ null type windate || \
alias windate="cmd.exe //c 'echo %DATE%-%TIME%'" alias windate="cmd.exe //c 'echo %DATE%-%TIME%'"
# alias cygsu="cygstart /cygwinsetup.exe" # alias cygsu="cygstart /cygwinsetup.exe"
# alias ls="ls -CFG $(iswindows || test "$TERM" = dumb || echo --color=auto)"
fi fi


g(){ g(){
@@ -737,11 +743,11 @@ showinfo(){


__safe_run diskinfo __safe_run diskinfo


! isdarwin && test -n "${DISPLAY}" && {
! $isdarwin && test -n "${DISPLAY}" && {
__safe_run xrandr | \grep --color=never ^Screen __safe_run xrandr | \grep --color=never ^Screen
} }


iswindows || __safe_run finger $USER
$iswindows || __safe_run finger $USER
LANG=C __safe_runc id LANG=C __safe_runc id
__safe_run xset q __safe_run xset q
} }
@@ -812,10 +818,10 @@ then
fi fi


catclip(){ catclip(){
if iswindows
if $iswindows
then then
cat /dev/clipboard | tr -d \\r cat /dev/clipboard | tr -d \\r
elif isdarwin
elif $isdarwin
then then
pbpaste pbpaste
else else
@@ -832,10 +838,10 @@ setclip(){
`cat "$@"` `cat "$@"`
__EOF__ __EOF__
fi fi
if iswindows
if $iswindows
then then
0<&3 sed -e 's/$/\r/' | tee /dev/clipboard 0<&3 sed -e 's/$/\r/' | tee /dev/clipboard
elif isdarwin
elif $isdarwin
then then
pbcopy 0<&3 pbcopy 0<&3
else else
@@ -846,17 +852,17 @@ __EOF__
} }


open_file(){ open_file(){
if iscygwin
if $iscygwin
then then
cygstart "$@" cygstart "$@"
elif ismsys
elif $ismsys
then then
cmd.exe //c start "" "$@" cmd.exe //c start "" "$@"
elif isdarwin
elif $isdarwin
then then
touch "$@" touch "$@"
open "$@" open "$@"
elif islinux
elif $islinux
then then
touch "$@" touch "$@"
if null type pcmanfm; then if null type pcmanfm; then
@@ -977,6 +983,7 @@ __my_battery_status(){
alias bat='__my_battery_status %s\\n' alias bat='__my_battery_status %s\\n'


ipaddress(){ ipaddress(){
# ipaddress <fmt>
type ip >/dev/null 2>&1 || return 1 type ip >/dev/null 2>&1 || return 1
local ip=$(LANG=C ip addr show scope global | \ local ip=$(LANG=C ip addr show scope global | \
\grep --color=never --only-matching 'inet [^ ]*' | cut -d " " -f 2) \grep --color=never --only-matching 'inet [^ ]*' | cut -d " " -f 2)
@@ -992,7 +999,7 @@ test -n "$SSH_CONNECTION" && __my_ps1_str="${__my_ps1_str}${__my_c5}SSH${__my_cd
test -n "$__MY_DTACH" && __my_ps1_str="${__my_ps1_str}${__my_c5}DTACH${__my_cdef} " test -n "$__MY_DTACH" && __my_ps1_str="${__my_ps1_str}${__my_c5}DTACH${__my_cdef} "


__my_ps1_scale(){ __my_ps1_scale(){
if null type stty && ! ismsys
if null type stty && ! $ismsys
then then
echo "[LxC:`stty size | tr -d $'\n' | tr " " x`]" echo "[LxC:`stty size | tr -d $'\n' | tr " " x`]"
fi fi
@@ -1023,12 +1030,12 @@ __my_ps1_git(){
} }


__my_ps1_ipaddr(){ __my_ps1_ipaddr(){
! iswindows && ipaddress [Addr:%s]
! $iswindows && ipaddress [Addr:%s]
} }


__my_ps1_bttry(){ __my_ps1_bttry(){
local bst="${TMP}/batterystatus" local bst="${TMP}/batterystatus"
if test -z "$DISPLAY" && ! iswindows
if test -z "$DISPLAY" && ! $iswindows
then then
test -f $bst && local bstr="$(cat $bst)" test -f $bst && local bstr="$(cat $bst)"
test -n "$bstr" && ! echo $bstr | grep 100 >/dev/null 2>&1 && \ test -n "$bstr" && ! echo $bstr | grep 100 >/dev/null 2>&1 && \
@@ -1045,13 +1052,13 @@ __my_ps1_jobs(){
# __my_ps1_jobs <num> # __my_ps1_jobs <num>
if test "$1" -ne 0 if test "$1" -ne 0
then then
echo "<JOBS:$1> "
echo "[JOBS:$1] "
fi fi
} }


__my_alert_fail(){ __my_alert_fail(){
test $laststatus -eq 0 || \ test $laststatus -eq 0 || \
echo "<STATUS:${laststatus}> "
echo "[STATUS:${laststatus}] "
} }


# About ansi escape sequences # About ansi escape sequences
@@ -1121,11 +1128,14 @@ then
__my_cdef="$__color_default" __my_cdef="$__color_default"
fi fi


__my_ps1_info(){
echo "$(__my_ps1_scale)$(__my_ps1_git)$(__my_ps1_bttry)$(__my_ps1_ipaddr)$(__my_ps1_moc)"
}

_ps1_bash="\ _ps1_bash="\
${__my_c4}:: ${__my_cdef}[${__my_c2}\u@\H${__my_cdef}:${__my_c1}\w/${__my_cdef}]\$(__my_ps1_scale)\$(__my_ps1_git)\$(__my_ps1_bttry)\$(__my_ps1_ipaddr)\$(__my_ps1_moc)\n\
${__my_c4}:: ${__my_cdef}[${__my_c2}\u@\H${__my_cdef}:${__my_c1}\w/${__my_cdef}]\$(__my_ps1_info)\n\
${__my_c4}:: ${__my_cdef}\$(__my_ps1_jobs \j)${__my_ps1_str}\$(__my_alert_fail)\$ " ${__my_c4}:: ${__my_cdef}\$(__my_ps1_jobs \j)${__my_ps1_str}\$(__my_alert_fail)\$ "
inbash && PS1=$_ps1_bash inbash && PS1=$_ps1_bash
_ps1_zsh="$_ps1_bash"
#inzsh && PS1="$_ps1_zsh" #inzsh && PS1="$_ps1_zsh"


__my_set_header_line(){ __my_set_header_line(){


Loading…
Cancel
Save