diff options
| author | jason | 2022-07-23 15:31:12 -0600 |
|---|---|---|
| committer | jason | 2022-07-23 15:31:12 -0600 |
| commit | bac761ceb8c4e432b9c938ef294d2ae70157fed1 (patch) | |
| tree | c66d3163a4edcb3902655c0c676b29cd9d55b9c4 /bash | |
| parent | 9daa2b5aa785237d2265219c462e79d22c1c0e63 (diff) | |
| download | dotfiles-bac761ceb8c4e432b9c938ef294d2ae70157fed1.tar.gz dotfiles-bac761ceb8c4e432b9c938ef294d2ae70157fed1.zip | |
fix docker completion & prompt
Diffstat (limited to 'bash')
| -rw-r--r-- | bash/.bashrc | 68 |
1 files changed, 37 insertions, 31 deletions
diff --git a/bash/.bashrc b/bash/.bashrc index 01e5e04..ffef555 100644 --- a/bash/.bashrc +++ b/bash/.bashrc | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | LC_ALL="en_US.UTF-8" | 1 | LC_ALL="en_US.UTF-8" |
| 2 | # This PS1 is completed at the end, allowing statuses to be included between the directory and closing $ | 2 | # This PS1 is completed at the end, allowing statuses to be included between the directory and closing $ |
| 3 | PS1="[\u@\[\e[38;5;148m\]\h\[\e[m\]:\[\e[36m\]\W\[\e[m\]\[\e[m\]]\[\e[m\]" | 3 | PS1="[\u@\[\e[38;5;148m\]\h\[\e[m\]:\[\e[36m\]\W\[\e[m\]\[\e[m\]]\[\e[m\]" |
| 4 | local END_PS1="\$\[\e[m\] " | 4 | END_PS1="\$\[\e[m\] " |
| 5 | # This is the original PS1 | 5 | # This is the original PS1 |
| 6 | #PS1="[\u@\[\e[38;5;148m\]\h\[\e[m\]:\[\e[36m\]\W\[\e[m\]\[\e[m\]]\[\e[m\]\$\[\e[m\] " | 6 | #PS1="[\u@\[\e[38;5;148m\]\h\[\e[m\]:\[\e[36m\]\W\[\e[m\]\[\e[m\]]\[\e[m\]\$\[\e[m\] " |
| 7 | PATH="${HOME}/bin:${HOME}/.local/bin:${PATH}" | 7 | PATH="${HOME}/bin:${HOME}/.local/bin:${PATH}" |
| @@ -54,8 +54,13 @@ fi | |||
| 54 | 54 | ||
| 55 | # Enable docker completions | 55 | # Enable docker completions |
| 56 | if [ -d /Applications/Docker.app/Contents/Resources/etc/ ]; then | 56 | if [ -d /Applications/Docker.app/Contents/Resources/etc/ ]; then |
| 57 | # Docker for Mac seems to switch the filenames sometimes. | ||
| 58 | if [ -f /Applications/Docker.app/Contents/Resources/etc/docker ]; then | ||
| 59 | . /Applications/Docker.app/Contents/Resources/etc/docker | ||
| 60 | elif [ -f /Applications/Docker.app/Contents/Resources/etc/docker-compose.bash-completion ]; then | ||
| 61 | . /Applications/Docker.app/Contents/Resources/etc/docker-compose.bash-completion | ||
| 62 | fi | ||
| 57 | . /Applications/Docker.app/Contents/Resources/etc/docker-compose.bash-completion | 63 | . /Applications/Docker.app/Contents/Resources/etc/docker-compose.bash-completion |
| 58 | . /Applications/Docker.app/Contents/Resources/etc/docker | ||
| 59 | fi | 64 | fi |
| 60 | 65 | ||
| 61 | # Enable nix | 66 | # Enable nix |
| @@ -159,6 +164,19 @@ alias define='sdcv' | |||
| 159 | #alias cleanstale="git clean -fd -e'!__pycache__' -e'!*.py[cod]'" | 164 | #alias cleanstale="git clean -fd -e'!__pycache__' -e'!*.py[cod]'" |
| 160 | #alias dry-cleanstale="git clean -fdn -e'!__pycache__' -e'!*.py[cod]'" | 165 | #alias dry-cleanstale="git clean -fdn -e'!__pycache__' -e'!*.py[cod]'" |
| 161 | 166 | ||
| 167 | # Enable direnv (https://github.com/direnv/direnv/) | ||
| 168 | DIRENV=`which direnv` | ||
| 169 | if [[ -x $DIRENV ]]; then | ||
| 170 | eval "$(direnv hook bash)" | ||
| 171 | fi | ||
| 172 | show_virtual_env() { | ||
| 173 | if [[ -n "$VIRTUAL_ENV" && -n "$DIRENV_DIR" ]]; then | ||
| 174 | echo "($(basename $VIRTUAL_ENV))" | ||
| 175 | fi | ||
| 176 | } | ||
| 177 | export -f show_virtual_env | ||
| 178 | PS1='$(show_virtual_env)'$PS1 | ||
| 179 | |||
| 162 | # Git Related | 180 | # Git Related |
| 163 | function delete-branches() { | 181 | function delete-branches() { |
| 164 | # Interactive branch deleter | 182 | # Interactive branch deleter |
| @@ -169,31 +187,18 @@ function delete-branches() { | |||
| 169 | xargs --no-run-if-empty git branch --delete --force | 187 | xargs --no-run-if-empty git branch --delete --force |
| 170 | } | 188 | } |
| 171 | 189 | ||
| 172 | local XCODE_SELECT=`which xcode-select` | 190 | XCODE_SELECT=`which xcode-select` |
| 173 | if [[ -x $XCODE_SELECT ]]; then | 191 | if [[ -x $XCODE_SELECT ]]; then |
| 174 | local OSX_GIT_COMPLETION=`xcode-select -p`/usr/share/git-core/git-completion.bash | 192 | OSX_GIT_COMPLETION=`xcode-select -p`/usr/share/git-core/git-completion.bash |
| 175 | if [[ -f $OSX_GIT_COMPLETION ]]; then | 193 | if [[ -f $OSX_GIT_COMPLETION ]]; then |
| 176 | source $OSX_GIT_COMPLETION | 194 | source $OSX_GIT_COMPLETION |
| 177 | fi | 195 | fi |
| 178 | local OSX_GIT_PROMPT=`xcode-select -p`/usr/share/git-core/git-prompt.sh | 196 | OSX_GIT_PROMPT=`xcode-select -p`/usr/share/git-core/git-prompt.sh |
| 179 | if [[ -f $OSX_GIT_PROMPT ]]; then | 197 | if [[ -f $OSX_GIT_PROMPT ]]; then |
| 180 | source $OSX_GIT_PROMPT | 198 | source $OSX_GIT_PROMPT |
| 181 | fi | 199 | fi |
| 182 | fi | 200 | fi |
| 183 | 201 | ||
| 184 | if [[ $(type -t __git_ps1) == function ]]; then | ||
| 185 | GIT_PS1_SHOWDIRTYSTATE=1 # Show unstaged and staged indicators | ||
| 186 | GIT_PS1_SHOWUNTRACKEDFILES=1 # show % for untracked files | ||
| 187 | # GIT_PS1_SHOWUPSTREAM=auto # show +/- changes with upstream | ||
| 188 | #PS1=$PS1'$(__git_ps1 " (%s)")' | ||
| 189 | |||
| 190 | # Alternatively, for a slightly faster prompt, __git_ps1 can be | ||
| 191 | # used for PROMPT_COMMAND in Bash with two parameters, <pre> and | ||
| 192 | # <post>, which are strings you would put in $PS1 before and after | ||
| 193 | # the status string generated by the git-prompt machinery. | ||
| 194 | export PROMPT_COMMAND="__git_ps1 '${PS1}' '${END_PS1}'; ${PROMPT_COMMAND}" | ||
| 195 | fi | ||
| 196 | |||
| 197 | # The Gemini earbuds don't sync the volume. This turns up the hardware volume control | 202 | # The Gemini earbuds don't sync the volume. This turns up the hardware volume control |
| 198 | alias geminiup="dbus-send --print-reply --system --dest=org.bluez /org/bluez/hci0/dev_7C_C4_EF_CC_45_43 org.bluez.MediaControl1.VolumeUp" | 203 | alias geminiup="dbus-send --print-reply --system --dest=org.bluez /org/bluez/hci0/dev_7C_C4_EF_CC_45_43 org.bluez.MediaControl1.VolumeUp" |
| 199 | alias geminidown="dbus-send --print-reply --system --dest=org.bluez /org/bluez/hci0/dev_7C_C4_EF_CC_45_43 org.bluez.MediaControl1.VolumeDown" | 204 | alias geminidown="dbus-send --print-reply --system --dest=org.bluez /org/bluez/hci0/dev_7C_C4_EF_CC_45_43 org.bluez.MediaControl1.VolumeDown" |
| @@ -205,19 +210,6 @@ export MOZ_USE_XINPUT2=1 | |||
| 205 | #export GPG_TTY=$(tty) | 210 | #export GPG_TTY=$(tty) |
| 206 | export SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket)" | 211 | export SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket)" |
| 207 | 212 | ||
| 208 | # Enable direnv (https://github.com/direnv/direnv/) | ||
| 209 | DIRENV=`which direnv` | ||
| 210 | if [[ -x $DIRENV ]]; then | ||
| 211 | eval "$(direnv hook bash)" | ||
| 212 | fi | ||
| 213 | show_virtual_env() { | ||
| 214 | if [[ -n "$VIRTUAL_ENV" && -n "$DIRENV_DIR" ]]; then | ||
| 215 | echo "($(basename $VIRTUAL_ENV))" | ||
| 216 | fi | ||
| 217 | } | ||
| 218 | export -f show_virtual_env | ||
| 219 | PS1='$(show_virtual_env)'$PS1 | ||
| 220 | |||
| 221 | # Enable warpdir (https://rc4.net/wd-rs/) | 213 | # Enable warpdir (https://rc4.net/wd-rs/) |
| 222 | WARPDIR=`which warpdir` | 214 | WARPDIR=`which warpdir` |
| 223 | if [[ -x $WARPDIR ]]; then | 215 | if [[ -x $WARPDIR ]]; then |
| @@ -230,5 +222,19 @@ if [[ -x $TERRAFORM ]]; then | |||
| 230 | complete -C $TERRAFORM terraform | 222 | complete -C $TERRAFORM terraform |
| 231 | fi | 223 | fi |
| 232 | 224 | ||
| 225 | # If __git_ps1 is enabled, set that up. | ||
| 226 | if [[ $(type -t __git_ps1) == function ]]; then | ||
| 227 | GIT_PS1_SHOWDIRTYSTATE=1 # Show unstaged and staged indicators | ||
| 228 | GIT_PS1_SHOWUNTRACKEDFILES=1 # show % for untracked files | ||
| 229 | # GIT_PS1_SHOWUPSTREAM=auto # show +/- changes with upstream | ||
| 230 | PS1=$PS1'$(__git_ps1 " (%s)")' | ||
| 231 | |||
| 232 | # Alternatively, for a slightly faster prompt, __git_ps1 can be | ||
| 233 | # used for PROMPT_COMMAND in Bash with two parameters, <pre> and | ||
| 234 | # <post>, which are strings you would put in $PS1 before and after | ||
| 235 | # the status string generated by the git-prompt machinery. | ||
| 236 | # DISABLED because this doesn't work with $(show_virtualenv) | ||
| 237 | #export PROMPT_COMMAND="__git_ps1 '${PS1}' '${END_PS1}'; ${PROMPT_COMMAND}" | ||
| 238 | fi | ||
| 233 | # Close off the PS1 with the $ | 239 | # Close off the PS1 with the $ |
| 234 | PS1=${PS1}${END_PS1} | 240 | PS1=${PS1}${END_PS1} |