cfea70f6373b7f4cd456a630d3448f60960a0bbb
David Blume Fixed when /etc bashrc gets...

David Blume authored 8 years ago

1) if [[ $(uname -s) != Darwin* ]] && [ -f /etc/bashrc ]; then
2)     # Fedora but not Macintosh requires explicit sourcing of /etc/bashrc
3)     # On Debian, it's /etc/bash.bashrc, but it doesn't have to be sourced here.
4)     . /etc/bashrc
5) fi
6) 
dblume Experiment: Add git branch...

dblume authored 2 years ago

7) parse_git_branch() {
8)     git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ ⌥\1/'
9)     #git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ \1/'
10) }
11) 
12) if true ; then
dblume Shorten directory in prompt...

dblume authored 2 years ago

13)     export PROMPT_DIRTRIM=1
dblume Experiment: Add git branch...

dblume authored 2 years ago

14)     # I like 023 or 030 for the git branch color. See https://i.stack.imgur.com/UQVe5.png
15)     if [[ -n $SSH_CLIENT ]]; then
16)         export PS1='$(if [ $? -eq 0 ]; then echo -e "\[\e[32m\]\xe2\x9c\x93";
dblume Match color for local and s...

dblume authored 2 years ago

17)                       else echo -e "\[\e[31m\]\xe2\x9c\x97"; fi) \[\e[38;5;242m\]\h:\w\[\e[38;5;030m\]$(parse_git_branch)\[\e[38;5;242m\]$\[\e[0m\] '
dblume Experiment: Add git branch...

dblume authored 2 years ago

18)     else
19)         export PS1='$(if [ $? -eq 0 ]; then echo -e "\[\e[32m\]\xe2\x9c\x93";
20)                       else echo -e "\[\e[31m\]\xe2\x9c\x97"; fi) \[\e[38;5;242m\]\w\[\e[38;5;030m\]$(parse_git_branch)\[\e[38;5;242m\]$\[\e[0m\] '
21)     fi
David Blume New PS1 with error detectio...

David Blume authored 6 years ago

22) else
dblume Shorten directory in prompt...

dblume authored 2 years ago

23)     export PROMPT_DIRTRIM=4
dblume Experiment: Add git branch...

dblume authored 2 years ago

24)     if [[ -n $SSH_CLIENT ]]; then
25)         export PS1='$(if [ $? -eq 0 ]; then echo -e "\[\e[32m\]\xe2\x9c\x93";
26)                       else echo -e "\[\e[31m\]\xe2\x9c\x97"; fi) \[\e[38;5;242m\]\h:\w$\[\e[0m\] '
27)     else
28)         export PS1='$(if [ $? -eq 0 ]; then echo -e "\[\e[32m\]\xe2\x9c\x93";
29)                       else echo -e "\[\e[31m\]\xe2\x9c\x97"; fi) \[\e[38;5;242m\]\w$\[\e[0m\] '
30)     fi
David Blume New PS1 with error detectio...

David Blume authored 6 years ago

31) fi
32) 
33) set -o vi
David Blume first commit

David Blume authored 8 years ago

34) 
35) add_to_path() {
36)     if [ -d "$1" ] && [[ ! $PATH =~ (^|:)$1(:|$) ]]; then
37)         PATH+=:$1
38)     fi
39) }
40) 
41) # if this is a CygWin .bashrc, then set CygWin's commands first in PATH
42) # because link.exe and find.exe exist in Windows's path.
43) # Add /usr/lib/lapack at the end so python's numpy can find lapack_lite
44) # (Note: BSD bash, used by OS X doesn't have the "substr" test for expr.)
45) if [[ $(uname -s) == CYGWIN* ]]; then
David Blume Use spaces instead of tabs.

David Blume authored 8 years ago

46)     PATH=/usr/local/bin:/usr/bin:$PATH
47)     PATH=${PATH//":/usr/local/bin:/usr/bin"/} # delete any instances in middle
48)     add_to_path /usr/lib/lapack
David Blume Add md() support for Cygwin...

David Blume authored 5 years ago

49)     export GIT_SSH=/cygdrive/c/cygwin64/bin/ssh
David Blume Use spaces instead of tabs.

David Blume authored 8 years ago

50)     ulimit -n 1024 # for "duplicity"
David Blume Add support for 'md' on WSL.

David Blume authored 4 years ago

51) elif [[ -n "${WSL_DISTRO_NAME}" ]]; then
52)     export BROWSER=/mnt/c/Program\ Files\ \(x86\)/Google/Chrome/Application/chrome.exe
David Blume first commit

David Blume authored 8 years ago

53) fi
54) 
David Blume whitespace

David Blume authored 6 years ago

55) # change the color of directories in the ls command
David Blume Refactor .bashrc to keep di...

David Blume authored 8 years ago

56) if [[ $(uname -s) == Darwin* ]]; then
57)     export LSCOLORS=gxfxcxdxbxegedabagacad
58)     export CLICOLOR=1
59) else
60)     # After executing: dircolors -p > .dircolors
61)     # Lighten the color of directories from blue to light blue
62)     # sed -i '/# directory/c\DIR 00;36 # directory' .dircolors
63)     if [ -x /usr/bin/dircolors ]; then
64)         test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
65)         alias ls='ls --color=auto'
66)     fi
David Blume first commit

David Blume authored 8 years ago

67) fi
68) 
David Blume Add .vimrc tab values for ....

David Blume authored 8 years ago

69) export P4DIFF='vim -d'  # Override from the command line: "P4DIFF=; p4 diff main.py"
David Blume Set vim as editor for cscope

David Blume authored 6 years ago

70) export CSCOPE_EDITOR=vim
David Blume Add .vimrc tab values for ....

David Blume authored 8 years ago

71) 
David Blume Add alias for colors in ls...

David Blume authored 8 years ago

72) alias grep='grep --color=auto'
73) alias fgrep='fgrep --color=auto'
74) alias egrep='egrep --color=auto'
David Blume I almost always want to do...

David Blume authored 4 years ago

75) alias vim-='vim +"setl buftype=nofile" -'
David Blume Add support for tmux; use p...

David Blume authored 4 years ago

76) alias tmux='tmux -2'
David Blume Add alias for colors in ls...

David Blume authored 8 years ago

77) 
78) # colored GCC warnings and errors
79) export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
80) 
David Blume first commit

David Blume authored 8 years ago

81) # Add to PATH only if not already in PATH.
82) add_to_path $HOME/bin
83) 
David Blume disable ctrl+s as stty flow...

David Blume authored 3 years ago

84) # For interactive shells ('i' in $-), disable stty flow control (ctrl+s,ctrl+q)
85) case "$-" in
86) *i*)
87)   stty start ''
88)   stty stop  ''
89)   stty -ixon # disable XON/XOFF flow control
90)   stty ixoff # enable sending (to app) of start/stop characters
91)   stty ixany # let any character restart output, not only start character
92)   ;;
93) *) ;;
94) esac
95) 
David Blume first commit

David Blume authored 8 years ago

96) alias findinpyfiles="find . -name \*.py -print0 | xargs -0 grep -nI"
David Blume Add a few c++ aliases, and...

David Blume authored 8 years ago

97) alias findinchppfiles="find . -type f \( -name \*.[ch]pp -or -name \*.[ch] \) -print0 | xargs -0 grep -nI"
98) alias findincppfiles="find . -type f \( -name \*.cpp -or -name \*.c \) -print0 | xargs -0 grep -nI"
99) alias findinhppfiles="find . -type f \( -name \*.hpp -or -name \*.h \) -print0 | xargs -0 grep -nI"
100) 
101) alias clip="expand | cut -b1-\$COLUMNS"
David Blume Optionally source a .localr...

David Blume authored 8 years ago

102) 
David Blume Add alias for httpie https

David Blume authored 6 years ago

103) # For httpie: https://github.com/jakubroztocil/httpie#installation
104) alias https='http --default-scheme=https'
105) 
David Blume Add a command for viewing M...

David Blume authored 5 years ago

106) md() {
David Blume Make the local variables co...

David Blume authored 5 years ago

107)     declare -r sys_name=$(uname -s)
David Blume Add md() support for Cygwin...

David Blume authored 5 years ago

108)     if [[ $sys_name == Darwin* ]]; then
David Blume Make the local variables co...

David Blume authored 5 years ago

109)         declare -r T=$(mktemp $TMPDIR$(uuidgen).html)
David Blume Add md() support for Cygwin...

David Blume authored 5 years ago

110)         curl -s -X POST --data-binary @"$1" https://md.dlma.com/ > $T
David Blume No need to specify Safari t...

David Blume authored 5 years ago

111)         open $T
David Blume Add md() support for Cygwin...

David Blume authored 5 years ago

112)     elif [[ $sys_name == CYGWIN* ]]; then
David Blume Make the local variables co...

David Blume authored 5 years ago

113)         declare -r T=$(mktemp --suffix=.html)
David Blume Add md() support for Cygwin...

David Blume authored 5 years ago

114)         curl -s -X POST --data-binary @"$1" https://md.dlma.com/ > $T
115)         cygstart $T
David Blume Add a command for viewing M...

David Blume authored 5 years ago

116)     else
David Blume Make the local variables co...

David Blume authored 5 years ago

117)         declare -r T=$(mktemp --suffix=.html)
David Blume Add md() support for Cygwin...

David Blume authored 5 years ago

118)         curl -s -X POST --data-binary @"$1" https://md.dlma.com/ > $T
David Blume Add support for 'md' on WSL.

David Blume authored 4 years ago

119)         if [[ -z "${WSL_DISTRO_NAME}" ]]; then
120)             xdg-open $T
121)             echo "rm \"$T\" >/dev/null 2>&1" | at now + 2 minutes
122)         else
123)             # Set BROWSER to your web browser's path
124)             "$BROWSER" $(realpath --relative-to=$PWD $T)
125)         fi
David Blume Add a command for viewing M...

David Blume authored 5 years ago

126)     fi
127) }
128) 
David Blume I almost always want to do...

David Blume authored 4 years ago

129) concept() {
David Blume Add support for tmux; use p...

David Blume authored 4 years ago

130)     # apropos -s 7 . | awk '!/iso|latin/ {print $1}' | shuf -n 1 | xargs man 7
131)     apropos -s 7 . | awk '!/iso|latin/ {print $1}' | shuf -n 1 | pee "xargs echo man 7" "xargs man 7"
David Blume I almost always want to do...

David Blume authored 4 years ago

132) }
133) 
David Blume Added venv command

David Blume authored 3 years ago

134) venv() {
David Blume venv() supports filename co...

David Blume authored 3 years ago

135)     # Inspired by https://twitter.com/gvanrossum/status/1319328122618048514
136)     if hash deactivate 2>/dev/null; then
137)         deactivate
138)     fi
139)     if [[ $1 ]]; then
140)         if [ ! -f $1/bin/activate ]; then
141)             echo "Creating with: python3 -m venv $1"
142)             python3 -m venv $1
David Blume Added venv command

David Blume authored 3 years ago

143)         fi
David Blume venv() supports filename co...

David Blume authored 3 years ago

144)         source $1/bin/activate
David Blume Added venv command

David Blume authored 3 years ago

145)     fi
146) }
147) 
David Blume Moving ignoredups:erasedups...

David Blume authored 5 years ago

148) # https://unix.stackexchange.com/questions/1288/preserve-bash-history-in-multiple-terminal-windows
149) HISTCONTROL=ignoredups:erasedups
David Blume Add some commands to exclud...

David Blume authored 5 years ago

150) HISTIGNORE="&:ls:[bf]g:exit:pwd:clear"
David Blume I almost always want to do...

David Blume authored 4 years ago

151) #HISTFILESIZE=2000
152) #HISTSIZE=2000
153) # [ $(wc -l < $HOME/.bash_history) -gt 950 ] && echo "David, your .bash_history is over 950 lines. Consider updating your .bashrc."
David Blume Moving ignoredups:erasedups...

David Blume authored 5 years ago

154) shopt -s histappend
155) 
David Blume Forgot a corresponding chan...

David Blume authored 8 years ago

156) if [ -f $HOME/.localrc ]; then
David Blume Specify path for .localrc

David Blume authored 8 years ago

157)     source $HOME/.localrc