dot rc

Sign in or create your account | Project List | Help

dot rc Git Source Tree

Root/rc/bashrci

Source at commit b9861e0f76d6be15da1e8ac114c545c20c389d7b created 2 years 3 days ago.
By Luciano Rocha, OS X fixes
1# vim:filetype=sh
2# .bashrc for interactive shells
3
4# enable some shell options
5while read opt comment; do
6    [ -n "$opt" -a "$opt" != . ] && shopt -s $opt
7done <<\EOF
8cdspell correct minor errors in the spelling of a directory
9. component in a 'cd' command
10checkhash check if hashed command path exists before executing
11. the command, refresh if needed
12checkwinsize check window size after each command, update LINES and COLUMNS
13cmdhist save all lines of a multiple-line command in the same history
14. entry
15extglob use extended pattern matching rules ?,*,+,@,!()
16histreedit allow re-edition of failed history substitution
17huponexit send SIGHUP to all jobs when login shell exits
18no_empty_cmd_completion don't try to autocomplete on an empty line
19promptvars prompt strings undergo normal expansion
20EOF
21
22# disable some shell options
23while read opt comment; do
24    [ -n "$opt" -a "$opt" != . ] && shopt -u $opt
25done <<\EOF
26hostcomplete don't try to complete hostnames for words containing a @
27sourcepath don't use PATH for "source" (".")
28nullglob don't expand to nothing if pattern fails to match any filename
29failglob don't error if pattern fails to match any filename
30EOF
31
32set -P # use physical directory instead of symlink, in cd/pushd/...
33
34## history
35shopt -s histappend
36HISTFILE=~/.bash_history
37HISTFILESIZE=8000
38HISTSIZE=2000
39# add :ignorespace to ignore lines beginning with whitespace
40HISTCONTROL=erasedups
41HISTTIMEFORMAT="%F %T -- "
42
43## vim alias
44## gvim if DISPLAY set and to localhost
45_check_gvim()
46{
47    # if DISPLAY set, check if it isn't a remote DISPLAY
48    if [ -n "$DISPLAY" ]; then
49        _check_if_remote_display
50        return $?
51    fi
52
53    # OS X: gvim uses cocoa
54    [ $(uname -s) = Darwin ]
55
56    # failed otherwise
57}
58
59if _exists gvim && _check_gvim; then
60    alias vi=mvim
61    alias vim=mvim
62elif _exists vim; then
63    alias vi=svim
64    alias vim=svim
65    [ -n "$DISPLAY" ] && _exists gvim || alias gvim=svim
66else
67    alias vim=vi
68    alias gvim=vi
69fi
70
71## remove temporary function
72unset _check_gvim
73
74## less alias
75if _exists less; then
76    alias more=less
77else
78    alias less=more
79fi
80

Archive Download this file

Branches:
master