dot rc

Sign in or create your account | Project List | Help

dot rc Commit Details

Date:2010-05-17 11:01:47 (1 year 8 months ago)
Author:Luciano Rocha
Commit:b9861e0f76d6be15da1e8ac114c545c20c389d7b
Message:OS X fixes

Files: rc/bash_functions (2 diffs)
rc/bash_functions_noti (1 diff)
rc/bash_prompt (1 diff)
rc/bashrci (1 diff)

Change Details

rc/bash_functions
134134            abs="$PWD/$arg"
135135        fi
136136
137        t=$(file -i "$abs")
137        if [ "$(uname -s)" = Darwin ]; then
138            t=$(file -I "$abs")
139        else
140            t=$(file -i "$abs")
141        fi
142
138143        # remove ; charset=..
139144        t="${t%%;*}"
140145
...... 
177182            ;;
178183            *gzip)
179184            if [ -z "${arg##*.tgz}" ] || [ -z "${arg##*tar*}" ]; then
180                tar -xzpsSf "$abs" -C "$dir"
185                tar -xzpf "$abs" -C "$dir"
181186            else
182187                zcat < "$abs" > "$dir/$dest"
183188            fi
184189            ;;
185190            *bzip2)
186191            if [ -z "${arg##*.tbz*}" ] || [ -z "${arg##*tar*}" ]; then
187                tar -xjpsSf "$abs" -C "$dir"
192                tar -xjpf "$abs" -C "$dir"
188193            else
189194                bzcat < "$abs" > "$dir/$dest"
190195            fi
rc/bash_functions_noti
99    [ -n "$1" ] && type -P "$1" &> /dev/null
1010}
1111
12## doc: check if $DISPLAY isn't pointing to a remote server
13_check_if_remote_display()
14{
15    local d="${DISPLAY%.[0-9]*}"
16    local hn="${HOSTNAME%%.*}"
17
18    if [ -n "${d##:*}" ]; then
19        ## hostname set
20
21        if [ -z "${d##/*}" ]; then
22            ## unix socket
23            return 0
24        fi
25
26        if [ -n "${d##localhost*}" ] &&
27            [ -n "${d##$hn*}" ]; then
28            ## not set to localhost or $hostname
29            return 1
30        fi
31    fi
32
33    ## localhost, but probably tunneled
34    if [ "${d##*:}" -ge 10 ]; then
35        return 1
36    fi
37
38    ## ok
39    return 0
40}
41
1242## doc: convert text (xh ym zs) to seconds
1343_str2time()
1444{
rc/bash_prompt
55_wdlen=36
66
77## colors
8_RESET=`echo -ne '\e[0m'`
9_RED=`echo -ne '\e[0;31m'`
10_GREEN=`echo -ne '\e[0;32m'`
11_YELLOW=`echo -ne '\e[0;33m'`
12_BLUE=`echo -ne '\e[0;34m'`
13_MAGENTA=`echo -ne '\e[0;35m'`
14_CYAN=`echo -ne '\e[0;36m'`
15_GRAY=`echo -ne '\e[0;37m'`
8_RESET=`echo -ne '\033[0m'`
9_RED=`echo -ne '\033[0;31m'`
10_GREEN=`echo -ne '\033[0;32m'`
11_YELLOW=`echo -ne '\033[0;33m'`
12_BLUE=`echo -ne '\033[0;34m'`
13_MAGENTA=`echo -ne '\033[0;35m'`
14_CYAN=`echo -ne '\033[0;36m'`
15_GRAY=`echo -ne '\033[0;37m'`
1616
1717## username and hostname colors depend on their values
1818_HCDEF="$_BLUE"
rc/bashrci
4444## gvim if DISPLAY set and to localhost
4545_check_gvim()
4646{
47    local d="${DISPLAY%.[0-9]*}"
48
49    ## hostname set != than localhost
50    if [ -n "${d##:*}" ]; then
51        if [ -n "${d##localhost*}" ] &&
52            [ -n "${d##$(hostname -s)*}" ]; then
53            return 1
54        fi
47    # if DISPLAY set, check if it isn't a remote DISPLAY
48    if [ -n "$DISPLAY" ]; then
49        _check_if_remote_display
50        return $?
5551    fi
5652
57    ## localhost, but probably tunneled
58    if [ "${d##*:}" -ge 10 ]; then
59        return 1
60    fi
53    # OS X: gvim uses cocoa
54    [ $(uname -s) = Darwin ]
6155
62    ## ok
63    return 0
56    # failed otherwise
6457}
6558
66if _exists gvim && [ -n "$DISPLAY" ] && _check_gvim; then
59if _exists gvim && _check_gvim; then
6760    alias vi=mvim
6861    alias vim=mvim
6962elif _exists vim; then

Archive Download the corresponding diff file

Branches:
master