4797cd0abdda9854a2140ecf12f2819133eff20c
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 Use __git_ps1 when possible.

dblume authored 2 years ago

7) # Some devices may not have __git_ps1, so fake it
8) if ! $(declare -F __git_ps1 > /dev/null); then
9)     __git_ps1() {
dblume Make fake __git_ps1 use its...

dblume authored 2 years ago

10)         printf "$1" $(git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/')
dblume Use __git_ps1 when possible.

dblume authored 2 years ago

11)     }
12) fi
dblume Experiment: Add git branch...

dblume authored 2 years ago

13) 
14) if true ; then
dblume Shorten directory in prompt...

dblume authored 2 years ago

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

dblume authored 2 years ago

16)     # I like 023 or 030 for the git branch color. See https://i.stack.imgur.com/UQVe5.png
17)     if [[ -n $SSH_CLIENT ]]; then
18)         export PS1='$(if [ $? -eq 0 ]; then echo -e "\[\e[32m\]\xe2\x9c\x93";
dblume Make fake __git_ps1 use its...

dblume authored 2 years ago

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

dblume authored 2 years ago

20)     else
21)         export PS1='$(if [ $? -eq 0 ]; then echo -e "\[\e[32m\]\xe2\x9c\x93";
dblume Make fake __git_ps1 use its...

dblume authored 2 years ago

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

dblume authored 2 years ago

23)     fi
David Blume New PS1 with error detectio...

David Blume authored 6 years ago

24) else
dblume Shorten directory in prompt...

dblume authored 2 years ago

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

dblume authored 2 years ago

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

David Blume authored 6 years ago

33) fi
34) 
35) set -o vi
David Blume first commit

David Blume authored 8 years ago

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

David Blume authored 8 years ago

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

David Blume authored 5 years ago

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

David Blume authored 8 years ago

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

David Blume authored 4 years ago

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

David Blume authored 8 years ago

55) fi
56) 
David Blume whitespace

David Blume authored 6 years ago

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

David Blume authored 8 years ago

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

David Blume authored 8 years ago

69) fi
70) 
David Blume Add .vimrc tab values for ....

David Blume authored 8 years ago

71) 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

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

David Blume authored 8 years ago

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

David Blume authored 8 years ago

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

David Blume authored 4 years ago

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

David Blume authored 4 years ago

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

David Blume authored 8 years ago

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

David Blume authored 8 years ago

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

David Blume authored 3 years ago

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

David Blume authored 8 years ago

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

David Blume authored 8 years ago

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

David Blume authored 8 years ago

104) 
David Blume Add alias for httpie https

David Blume authored 6 years ago

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

David Blume authored 5 years ago

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

David Blume authored 5 years ago

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

David Blume authored 5 years ago

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

David Blume authored 5 years ago

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

David Blume authored 5 years ago

112)         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

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

David Blume authored 5 years ago

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

David Blume authored 5 years ago

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

David Blume authored 5 years ago

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

David Blume authored 5 years ago

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

David Blume authored 5 years ago

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

David Blume authored 5 years ago

120)         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

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

David Blume authored 5 years ago

128)     fi
129) }
130) 
David Blume I almost always want to do...

David Blume authored 4 years ago

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

David Blume authored 4 years ago

132)     # apropos -s 7 . | awk '!/iso|latin/ {print $1}' | shuf -n 1 | xargs man 7
133)     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

134) }
135) 
David Blume Added venv command

David Blume authored 3 years ago

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

David Blume authored 3 years ago

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

David Blume authored 3 years ago

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

David Blume authored 3 years ago

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

David Blume authored 3 years ago

147)     fi
148) }
149) 
David Blume Moving ignoredups:erasedups...

David Blume authored 5 years ago

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

David Blume authored 5 years ago

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

David Blume authored 4 years ago

153) #HISTFILESIZE=2000
154) #HISTSIZE=2000
155) # [ $(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

156) shopt -s histappend
157) 
David Blume Forgot a corresponding chan...

David Blume authored 8 years ago

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

David Blume authored 8 years ago

159)     source $HOME/.localrc