annotate bashrc @ 152:510c38f1cfc2

Add helpful Git defaults for branch, pull/merge and publishing Also includes a broken command to try and alias adding to DVC since it always gives you a command to run
author IBBoard <dev@ibboard.co.uk>
date Tue, 11 Jan 2022 20:48:33 +0000
parents d0aef31d4122
children 99a7805cb924
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6
013543014cc9 Make sure we import a default bashrc file
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
1 if [ -f /etc/bashrc ]; then
013543014cc9 Make sure we import a default bashrc file
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
2 . /etc/bashrc
013543014cc9 Make sure we import a default bashrc file
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
3 fi
013543014cc9 Make sure we import a default bashrc file
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
4
8
e6a261f18fb1 Add Bash Completion sourcing
IBBoard <dev@ibboard.co.uk>
parents: 6
diff changeset
5 # Use bash-completion, if available
e6a261f18fb1 Add Bash Completion sourcing
IBBoard <dev@ibboard.co.uk>
parents: 6
diff changeset
6 if [ -f /etc/bash_completion ]; then
e6a261f18fb1 Add Bash Completion sourcing
IBBoard <dev@ibboard.co.uk>
parents: 6
diff changeset
7 . /etc/bash_completion
e6a261f18fb1 Add Bash Completion sourcing
IBBoard <dev@ibboard.co.uk>
parents: 6
diff changeset
8 fi
e6a261f18fb1 Add Bash Completion sourcing
IBBoard <dev@ibboard.co.uk>
parents: 6
diff changeset
9
20
ea572e660598 Fix Thunderbird dates and add more comments
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
10 # Use a sane editor
0
27e8e563b02b * First config files
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
11 export EDITOR=/usr/bin/nano
24
acbc487533ab Consistently fix Thunderbird time settings by moving some bits to profile, not bashrc
IBBoard <dev@ibboard.co.uk>
parents: 20
diff changeset
12
47
066d31abcee4 Set 256-colour terminal
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
13 # Set 256-colour terminal support
51
6b1492d34562 Switch from xterm to screen to fix Nano scrolling
IBBoard <dev@ibboard.co.uk>
parents: 47
diff changeset
14 export TERM="screen-256color"
47
066d31abcee4 Set 256-colour terminal
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
15
24
acbc487533ab Consistently fix Thunderbird time settings by moving some bits to profile, not bashrc
IBBoard <dev@ibboard.co.uk>
parents: 20
diff changeset
16 #Import aliases
0
27e8e563b02b * First config files
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
17 test -s ~/.alias && . ~/.alias || true
20
ea572e660598 Fix Thunderbird dates and add more comments
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
18
ea572e660598 Fix Thunderbird dates and add more comments
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
19 # Add sbins to path to make life easier (e.g. /sbin/ifconfig)
150
39abe6b6233f Add user's local bin dir to path
IBBoard <dev@ibboard.co.uk>
parents: 140
diff changeset
20 # Also add our hidden bin directory
39abe6b6233f Add user's local bin dir to path
IBBoard <dev@ibboard.co.uk>
parents: 140
diff changeset
21 export PATH=~/.local/bin:/sbin:/usr/sbin:/usr/local/sbin:$PATH
20
ea572e660598 Fix Thunderbird dates and add more comments
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
22
ea572e660598 Fix Thunderbird dates and add more comments
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
23 #Disable man page number prompts - where there's more than one, we normally want the default (user command) version
0
27e8e563b02b * First config files
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
24 export MAN_POSIXLY_CORRECT=1
27e8e563b02b * First config files
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
25
19
170de0d0d6dd Stop less creating a history file
IBBoard <dev@ibboard.co.uk>
parents: 8
diff changeset
26 #Disable less history, because do I really search the same things enough to use it across sessions?
170de0d0d6dd Stop less creating a history file
IBBoard <dev@ibboard.co.uk>
parents: 8
diff changeset
27 export LESSHISTFILE=-
170de0d0d6dd Stop less creating a history file
IBBoard <dev@ibboard.co.uk>
parents: 8
diff changeset
28
24
acbc487533ab Consistently fix Thunderbird time settings by moving some bits to profile, not bashrc
IBBoard <dev@ibboard.co.uk>
parents: 20
diff changeset
29 export XDG_CACHE_HOME="$HOME/.cache"
acbc487533ab Consistently fix Thunderbird time settings by moving some bits to profile, not bashrc
IBBoard <dev@ibboard.co.uk>
parents: 20
diff changeset
30
0
27e8e563b02b * First config files
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
31 if [ "$PS1" != "" -a "${STARTED_TMUX:-x}" = x -a "${SSH_TTY:-x}" != x ]
27e8e563b02b * First config files
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
32 then
27e8e563b02b * First config files
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
33 STARTED_TMUX=1; export STARTED_TMUX
27e8e563b02b * First config files
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
34 sleep 1
27e8e563b02b * First config files
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
35 ( (tmux has-session -t remote && tmux attach-session -t remote) || (tmux new-session -s remote) ) && exit 0
27e8e563b02b * First config files
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
36 echo "tmux failed to start"
6
013543014cc9 Make sure we import a default bashrc file
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
37 fi
27
c67aa2af6ff2 Switch to ibus, because it is simpler than uim but does XCompose
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
38
49
8f4076fd85a9 Export LS_OPTION from bashrc because profile doesn't seem to work on Tumbleweed
IBBoard <dev@ibboard.co.uk>
parents: 47
diff changeset
39 export GTK_IM_MODULE=ibus
56
3c48c5671f1a Make the prompt more visible and fix "less" highlighting
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
40 export LS_OPTIONS="$LS_OPTIONS -p"
3c48c5671f1a Make the prompt more visible and fix "less" highlighting
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
41
151
d0aef31d4122 Speed up compilation but stop Python making bytecode!
IBBoard <dev@ibboard.co.uk>
parents: 150
diff changeset
42 # Speed up compilation and take all the cores! (probably)
d0aef31d4122 Speed up compilation but stop Python making bytecode!
IBBoard <dev@ibboard.co.uk>
parents: 150
diff changeset
43 export MAKEFLAGS=-j$(lscpu|grep "^CPU(s):"|head -n1|awk '{print $2}')
d0aef31d4122 Speed up compilation but stop Python making bytecode!
IBBoard <dev@ibboard.co.uk>
parents: 150
diff changeset
44
d0aef31d4122 Speed up compilation but stop Python making bytecode!
IBBoard <dev@ibboard.co.uk>
parents: 150
diff changeset
45 export PYTHONDONTWRITEBYTECODE=true
d0aef31d4122 Speed up compilation but stop Python making bytecode!
IBBoard <dev@ibboard.co.uk>
parents: 150
diff changeset
46
64
39b07c5f8785 Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
47 function vcs_status {
39b07c5f8785 Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
48 GIT_PS1_SHOWDIRTYSTATE=1
39b07c5f8785 Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
49 GIT_PS1_SHOWUPSTREAM=verbose
39b07c5f8785 Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
50 . /etc/bash_completion.d/git-prompt.sh
39b07c5f8785 Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
51 VCS_EXTRA=$(__git_ps1 "%s")
39b07c5f8785 Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
52
39b07c5f8785 Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
53 if [[ "x$VCS_EXTRA" == "x" ]]; then
138
920255137b9d Include a "status" flag
IBBoard <dev@ibboard.co.uk>
parents: 131
diff changeset
54 VCS_EXTRA=$(hg prompt "{branch}{ {status|modified}}" 2>/dev/null)
69
78b4a74a5452 Fix mercurial status spacing, make it show like Git
IBBoard <dev@ibboard.co.uk>
parents: 67
diff changeset
55 HG_EXTRA=$(hg prompt "{-{incoming|count}}{+{outgoing|count}}" 2>/dev/null)
78b4a74a5452 Fix mercurial status spacing, make it show like Git
IBBoard <dev@ibboard.co.uk>
parents: 67
diff changeset
56 if [[ "x$HG_EXTRA" != "x" ]]; then
78b4a74a5452 Fix mercurial status spacing, make it show like Git
IBBoard <dev@ibboard.co.uk>
parents: 67
diff changeset
57 VCS_EXTRA="${VCS_EXTRA} u${HG_EXTRA}"
140
f5dd593cc018 Only show "u=" for hg when we're in a VCS'd directory
IBBoard <dev@ibboard.co.uk>
parents: 138
diff changeset
58 elif [[ "x$VCS_EXTRA" != "x" ]]; then
138
920255137b9d Include a "status" flag
IBBoard <dev@ibboard.co.uk>
parents: 131
diff changeset
59 VCS_EXTRA="${VCS_EXTRA} u="
69
78b4a74a5452 Fix mercurial status spacing, make it show like Git
IBBoard <dev@ibboard.co.uk>
parents: 67
diff changeset
60 fi
64
39b07c5f8785 Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
61 fi
39b07c5f8785 Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
62 if [[ "x$VCS_EXTRA" != "x" ]]; then
66
091d9fc4698b Limit path length and fix a colouring/wrapping bug that it highlighted
IBBoard <dev@ibboard.co.uk>
parents: 64
diff changeset
63 echo -n " ($VCS_EXTRA)"
64
39b07c5f8785 Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
64 fi
39b07c5f8785 Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
65 }
39b07c5f8785 Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
66
66
091d9fc4698b Limit path length and fix a colouring/wrapping bug that it highlighted
IBBoard <dev@ibboard.co.uk>
parents: 64
diff changeset
67 # Limit long paths
091d9fc4698b Limit path length and fix a colouring/wrapping bug that it highlighted
IBBoard <dev@ibboard.co.uk>
parents: 64
diff changeset
68 PROMPT_DIRTRIM=2
56
3c48c5671f1a Make the prompt more visible and fix "less" highlighting
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
69 # Bold the command prompt and standardise on SUSE format
57
28317d15a4cf Colourise prompt (PS1) based on Ubuntu default colours
IBBoard <dev@ibboard.co.uk>
parents: 56
diff changeset
70 # With colour!
70
3b6eae8d3801 Deal with spaces in current path when making $PS1
IBBoard <dev@ibboard.co.uk>
parents: 69
diff changeset
71 export PS1='\[\033[01;38;5;34m\]\u\[\033[01;38;5;28m\]@\[\033[01;38;5;34m\]\h\[\033[39m\]:\[\033[01;38;5;26m\]\w$(test "$PWD" != / && echo -n /)\[\033[39m\]\[\033[01;38;5;247m\]$(vcs_status)\[\033[39m\]>\[\033[00m\] '
56
3c48c5671f1a Make the prompt more visible and fix "less" highlighting
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
72
3c48c5671f1a Make the prompt more visible and fix "less" highlighting
IBBoard <dev@ibboard.co.uk>
parents: 54
diff changeset
73 # Fix "less" highlighting
59
2a3670fb2ef2 Improve highlighting background for "less"
IBBoard <dev@ibboard.co.uk>
parents: 57
diff changeset
74 export LESS_TERMCAP_so=$'\033[30;48;5;247m'
71
fed933b2b8f5 Fix Steam bug where overlay doesn't work
IBBoard <dev@ibboard.co.uk>
parents: 70
diff changeset
75 export LESS_TERMCAP_se=$'\033[0m'
fed933b2b8f5 Fix Steam bug where overlay doesn't work
IBBoard <dev@ibboard.co.uk>
parents: 70
diff changeset
76
72
21d5b52ae36f Configure default Go path to be sensible
IBBoard <dev@ibboard.co.uk>
parents: 71
diff changeset
77 export GOPATH="$HOME/.golang"
21d5b52ae36f Configure default Go path to be sensible
IBBoard <dev@ibboard.co.uk>
parents: 71
diff changeset
78
71
fed933b2b8f5 Fix Steam bug where overlay doesn't work
IBBoard <dev@ibboard.co.uk>
parents: 70
diff changeset
79 # Possible fix for Steam - https://github.com/ValveSoftware/steam-for-linux/issues/5000#issuecomment-305937612
125
1320f85d46d2 Steam runtime libs variable seems unnecessary, so remove it
IBBoard <dev@ibboard.co.uk>
parents: 114
diff changeset
80 #export STEAM_RUNTIME_PREFER_HOST_LIBRARIES=0
112
87de05d9f75f Add hidden default R package path
IBBoard <dev@ibboard.co.uk>
parents: 72
diff changeset
81
87de05d9f75f Add hidden default R package path
IBBoard <dev@ibboard.co.uk>
parents: 72
diff changeset
82 # Set a hidden R package directory
114
ef4c3848be18 Make sure that we actually EXPORT the R lib path!
IBBoard <dev@ibboard.co.uk>
parents: 113
diff changeset
83 export R_LIBS_USER=~/.R/
113
77768e1e9d49 Stop R prompting to save the workspace after each session
IBBoard <dev@ibboard.co.uk>
parents: 112
diff changeset
84 # And stop it asking us to save the workspace
127
724d0e149569 Add a function for base Conda activation
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
85 alias R='R --no-save'
724d0e149569 Add a function for base Conda activation
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
86
724d0e149569 Add a function for base Conda activation
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
87 conda_activate() {
724d0e149569 Add a function for base Conda activation
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
88 __conda_setup="$(~/.anaconda3/bin/conda 'shell.bash' 'hook' 2> /dev/null)"
724d0e149569 Add a function for base Conda activation
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
89 if [ $? -eq 0 ]; then
724d0e149569 Add a function for base Conda activation
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
90 eval "$__conda_setup"
724d0e149569 Add a function for base Conda activation
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
91 else
724d0e149569 Add a function for base Conda activation
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
92 if [ -f ~"/.anaconda3/etc/profile.d/conda.sh" ]; then
724d0e149569 Add a function for base Conda activation
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
93 . ~"/.anaconda3/etc/profile.d/conda.sh"
724d0e149569 Add a function for base Conda activation
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
94 else
724d0e149569 Add a function for base Conda activation
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
95 export PATH=~"/.anaconda3/bin:$PATH"
724d0e149569 Add a function for base Conda activation
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
96 fi
724d0e149569 Add a function for base Conda activation
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
97 fi
724d0e149569 Add a function for base Conda activation
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
98 unset __conda_setup
131
5f6e4aa53501 Let Conda activation use the local directory as a name
IBBoard <dev@ibboard.co.uk>
parents: 127
diff changeset
99
5f6e4aa53501 Let Conda activation use the local directory as a name
IBBoard <dev@ibboard.co.uk>
parents: 127
diff changeset
100 if [ $# -eq 1 ]; then
5f6e4aa53501 Let Conda activation use the local directory as a name
IBBoard <dev@ibboard.co.uk>
parents: 127
diff changeset
101 if [ "x$1" == "x." ]; then
5f6e4aa53501 Let Conda activation use the local directory as a name
IBBoard <dev@ibboard.co.uk>
parents: 127
diff changeset
102 _conda_env=$(basename $(readlink -f .))
5f6e4aa53501 Let Conda activation use the local directory as a name
IBBoard <dev@ibboard.co.uk>
parents: 127
diff changeset
103 else
5f6e4aa53501 Let Conda activation use the local directory as a name
IBBoard <dev@ibboard.co.uk>
parents: 127
diff changeset
104 _conda_env=$1
5f6e4aa53501 Let Conda activation use the local directory as a name
IBBoard <dev@ibboard.co.uk>
parents: 127
diff changeset
105 fi
5f6e4aa53501 Let Conda activation use the local directory as a name
IBBoard <dev@ibboard.co.uk>
parents: 127
diff changeset
106 conda activate $_conda_env
5f6e4aa53501 Let Conda activation use the local directory as a name
IBBoard <dev@ibboard.co.uk>
parents: 127
diff changeset
107 fi
5f6e4aa53501 Let Conda activation use the local directory as a name
IBBoard <dev@ibboard.co.uk>
parents: 127
diff changeset
108 unset _conda_env
127
724d0e149569 Add a function for base Conda activation
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
109 }