willpower232

willpower232 / bash.bashrc

Last active 1 month ago

Like 0

I am making my .bashrc portable as inspired by this https://www.cyberciti.biz/tips/bash-aliases-mac-centos-linux-unix.html

willpower232 revised this gist 1 month ago · 3a0ce0a

No changes

William Hall revised this gist 2 years ago · 60b0998

1 file changed, 24 insertions, 10 deletions

my.bashrc
@@ -30,16 +30,26 @@ fi
30 30
31 31 PS1='$(echo_last_status)\n'$ps1_shelllevel$ps1_user$ps1_folder$ps1_prompt
32 32
33 - #if [[ "$TERM" == "xterm-256color" && "$SHLVL" == "1" ]]; then
34 - # echo ""
35 - # curl --silent --max-time 2 https://wttr.in/lincoln,uk?0Q
36 - #fi
33 + # if [[ "$TERM" == "xterm-256color" && "$SHLVL" == "1" ]]; then
34 + # echo ""
35 + # curl --silent --max-time 2 https://wttr.in/lincoln,uk?0Q
36 +
37 + # if [[ $(which tailscale) != "" ]]; then
38 + # expiryEpoch=$(date -d $(tailscale status --json | jq -r '.Self.KeyExpiry') +%s)
39 + # nowEpoch=$(date +%s)
40 +
41 + # if [[ $(($expiryEpoch - $nowEpoch)) -lt $((86400 * 3)) ]]; then
42 + # echo -e "tailscale key expiring soon, time to \e[38;5;208mtailscale up --force-reauth\e[0m but not over ssh, obviously"
43 + # fi
44 + # fi
45 + # fi
37 46
38 47 # lol
39 48 alias nano='vim'
40 49
41 50 # alias bashphp='docker exec -it -w "$PWD" phpfpm bash'
42 51 # alias bashnode='bash ~/containers/nodejs/interactive.sh'
52 + # alias bashgolang='bash ~/containers/golang/interactive.sh'
43 53 # alias bashruby='bash ~/containers/ruby/interactive.sh'
44 54 # alias bashpython='bash ~/containers/python/interactive.sh'
45 55
@@ -137,15 +147,20 @@ complete -F _complete_alias d
137 147
138 148 export DOCKER_BUILDKIT=1
139 149 alias dc="docker-compose"
140 - alias dcb="docker-compose build --parallel"
150 + #alias dcb="docker-compose build --parallel"
151 + alias dcb="docker-compose build"
141 152 alias dcd="docker-compose down"
142 153 alias dcu="docker-compose up"
143 154 #alias dce="docker-compose exec --user $(id -u):$(id -g) --env HOME=/tmp"
144 155 alias dce="docker-compose exec"
145 156
157 + alias dceanrb="dce app npm run build"
158 + alias dceanrd="dce app npm run dev"
146 159 alias dceanrw="dce app npm run watch"
147 160 alias dceapat="dce app php artisan tinker"
148 161 alias dceapa="dce app php artisan"
162 + alias dceact="dce app composer test"
163 + alias dceaca="dce app composer analyse"
149 164 alias dcetct="dce testapp composer test"
150 165 alias dcetca="dce testapp composer analyse"
151 166 alias dcetact="dce test-app composer test"
@@ -173,9 +188,8 @@ function dcc {
173 188 eval $COMMAND
174 189 }
175 190
176 - #function k8sprod {
177 - # bash --rcfile ~/.bashrc.k8s
178 - #}
191 + # function k8sprod {
192 + # bash --rcfile ~/.bashrc.k8s
193 + # }
179 194
180 - alias assume="source assume"
181 - alias tf="terraform"
195 + alias tf="terraform"

Will Power revised this gist 3 years ago · 2591235

2 files changed, 10 insertions, 1 deletion

bash.bashrc
@@ -168,6 +168,14 @@ fi
168 168 # you need this but it may already be set elsewhere
169 169 #HISTCONTROL=ignoreboth
170 170
171 + # just in case you're interested in history, this should include when the command was run
172 + HISTTIMEFORMAT="%F %T "
173 +
174 + # append history list to history file when shell exits, default?
175 + shopt -s histappend
176 + # append every command to the history list
177 + PROMPT_COMMAND="history -a;$PROMPT_COMMAND"
178 +
171 179 # Debian doesn't have bash-completion by default so you need to apt install bash-completion and add the below
172 180 # also don't forget about https://github.com/cykerway/complete-alias
173 181 #if [ -f /etc/bash_completion ]; then
my.bashrc
@@ -3,13 +3,14 @@
3 3
4 4 # simple function to output yay or nay based on last status code
5 5 # have to include it directly in PS1 so it reads the right status code
6 + # PROMPT_COMMAND can't see it
6 7 echo_last_status() {
7 8 if [ $? = 0 ]; then
8 9 echo "👌"
9 10 else
10 11 echo "👎"
11 12 fi
12 - # can't output a newline
13 + # newlines are not visible
13 14 }
14 15
15 16 # git clone git@github.com:jimeh/git-aware-prompt ~/.bash/git-aware-prompt

Will Power revised this gist 3 years ago · 5f25651

1 file changed, 1 insertion, 1 deletion

my.bashrc
@@ -93,7 +93,7 @@ function git {
93 93 command git config --unset core.filemode && echo "removed core.filemode setting boss"
94 94 cd $curdir
95 95
96 - elif [[ "$1" == "branch" && "$@" != *"--help"* && -z "$3" ]]; then
96 + elif [[ "$1" == "branch" && "$@" != *"--help"* && "$@" != *" -r"* && -s "$2" && -z "$3" ]]; then
97 97 if [[ "$2" == "--random" ]]; then
98 98 command git fetch --all;
99 99 while true; do name=$RANDOM; if [ -z "$(command git show-ref refs/heads/$name)" ]; then command git checkout -b $name; break; fi; done;

Will Power revised this gist 3 years ago · c145693

1 file changed, 26 insertions, 3 deletions

my.bashrc
@@ -29,6 +29,11 @@ fi
29 29
30 30 PS1='$(echo_last_status)\n'$ps1_shelllevel$ps1_user$ps1_folder$ps1_prompt
31 31
32 + #if [[ "$TERM" == "xterm-256color" && "$SHLVL" == "1" ]]; then
33 + # echo ""
34 + # curl --silent --max-time 2 https://wttr.in/lincoln,uk?0Q
35 + #fi
36 +
32 37 # lol
33 38 alias nano='vim'
34 39
@@ -89,9 +94,15 @@ function git {
89 94 cd $curdir
90 95
91 96 elif [[ "$1" == "branch" && "$@" != *"--help"* && -z "$3" ]]; then
92 - shift 1
93 - echo "switching to checkout..."
94 - command git checkout -b "$@" || command git checkout "$@"
97 + if [[ "$2" == "--random" ]]; then
98 + command git fetch --all;
99 + while true; do name=$RANDOM; if [ -z "$(command git show-ref refs/heads/$name)" ]; then command git checkout -b $name; break; fi; done;
100 + else
101 + shift 1
102 + echo "switching to checkout..."
103 + command git checkout -b "$@" || command git checkout "$@"
104 + fi
105 +
95 106 else
96 107 command git "$@"
97 108 fi
@@ -106,6 +117,8 @@ function docker {
106 117 shift 1
107 118 command docker stop "$@"
108 119 command docker rm "$@"
120 + elif [[ "$1" == "login-to-github" ]]; then
121 + echo 'ghp_abcd' | docker login ghcr.io -u youruser --password-stdin
109 122 else
110 123 command docker "$@"
111 124 fi
@@ -129,6 +142,13 @@ alias dcu="docker-compose up"
129 142 #alias dce="docker-compose exec --user $(id -u):$(id -g) --env HOME=/tmp"
130 143 alias dce="docker-compose exec"
131 144
145 + alias dceanrw="dce app npm run watch"
146 + alias dceapat="dce app php artisan tinker"
147 + alias dceapa="dce app php artisan"
148 + alias dcetct="dce testapp composer test"
149 + alias dcetca="dce testapp composer analyse"
150 + alias dcetact="dce test-app composer test"
151 +
132 152 # persisting the changes you've made to your container
133 153 # is a terrible idea and yet here it is
134 154 function dcc {
@@ -155,3 +175,6 @@ function dcc {
155 175 #function k8sprod {
156 176 # bash --rcfile ~/.bashrc.k8s
157 177 #}
178 +
179 + alias assume="source assume"
180 + alias tf="terraform"

Will Power revised this gist 4 years ago · 9437784

1 file changed, 4 insertions, 2 deletions

my.bashrc
@@ -116,12 +116,14 @@ complete -F _complete_alias d
116 116
117 117 # aliases let you put things after the command if you want
118 118 # i.e. get familiar with the flags but type way fewer characters
119 - # e.g. dc build --no-cache -> rebuild the images without cache
119 + # e.g. dcb --no-cache -> rebuild the images without cache
120 120 # e.g. dcu -d -> dc up and detach/background it
121 121 # e.g. dce app bash -> dc exec bash in the service
122 122 # e.g. dcd -v -> dc down and clear volumes too
123 123
124 - alias dc=docker-compose
124 + export DOCKER_BUILDKIT=1
125 + alias dc="docker-compose"
126 + alias dcb="docker-compose build --parallel"
125 127 alias dcd="docker-compose down"
126 128 alias dcu="docker-compose up"
127 129 #alias dce="docker-compose exec --user $(id -u):$(id -g) --env HOME=/tmp"

Will Power revised this gist 5 years ago · c11dff9

1 file changed, 1 insertion, 1 deletion

my.bashrc
@@ -76,7 +76,7 @@ function git {
76 76 # command git config user.email me@work.com && echo "set user for work boss"
77 77 # ;;
78 78
79 - # *"personalgithubname"*)
79 + # *"personalgithubname"* | *"gist.github.com"*)
80 80 # command git config user.email me@home.com && echo "set user for personal boss"
81 81 # ;;
82 82

Will Power revised this gist 5 years ago · ffb31b1

1 file changed, 2 insertions

my.bashrc.k8s
@@ -68,3 +68,5 @@ function qk {
68 68 command kubectl "$@"
69 69 fi
70 70 }
71 +
72 + alias kbuild='kustomize build --enable-alpha-plugins .'

Will Power revised this gist 5 years ago · a6e23c4

1 file changed, 1 insertion, 1 deletion

my.bashrc
@@ -72,7 +72,7 @@ function git {
72 72 cd $newdir
73 73
74 74 #case $@ in
75 - # *"workgithubname"*)
75 + # *"workgithubname"* | *"WorkGithubName"* | *"othercompanyname"*)
76 76 # command git config user.email me@work.com && echo "set user for work boss"
77 77 # ;;
78 78

Will Power revised this gist 5 years ago · af6ec7e

1 file changed, 3 insertions, 6 deletions

my.bashrc
@@ -73,13 +73,11 @@ function git {
73 73
74 74 #case $@ in
75 75 # *"workgithubname"*)
76 - # command git config user.email me@work.com
77 - # echo "set user for work boss"
76 + # command git config user.email me@work.com && echo "set user for work boss"
78 77 # ;;
79 78
80 79 # *"personalgithubname"*)
81 - # command git config user.email me@home.com
82 - # echo "set user for personal boss"
80 + # command git config user.email me@home.com && echo "set user for personal boss"
83 81 # ;;
84 82
85 83 # *)
@@ -87,8 +85,7 @@ function git {
87 85 # ;;
88 86 #esac
89 87
90 - command git config --unset core.filemode
91 - echo "removed core.filemode setting boss"
88 + command git config --unset core.filemode && echo "removed core.filemode setting boss"
92 89 cd $curdir
93 90
94 91 elif [[ "$1" == "branch" && "$@" != *"--help"* && -z "$3" ]]; then