Bash-it / bash-it

A community Bash framework.
MIT License
14.22k stars 2.29k forks source link

[Bug]: After upgrading I started getting __git_ps1 error on each PS1 #2113

Closed georgettica closed 2 years ago

georgettica commented 2 years ago

Expected behavior

that __git_ps1 will work OOTB after an upgrade

Current behavior

on every PS1 the error

-bash: __git_ps1: command not found

occurs

Possible solution

add a source command in here https://github.com/Bash-it/bash-it/blob/master/completion/available/brew.completion.bash

source /usr/local/etc/bash_completion.d/git-prompt.sh

Context

asked in the brew repo and they said it's expected behaviour https://github.com/Homebrew/homebrew-core/issues/96384#issuecomment-1060233448

additonally, a oneliner for plugins themes and aliases:

$ for  i in  plugins aliases  completions ; do echo showing $i; shit show $i | grep '\[x\]'; echo; done
showing plugins
base                 [x]        miscellaneous tools
git                  [x]        git helper functions
man                  [x]        colorize man pages for better readability
osx                  [x]        osx-specific functions
ssh                  [x]        ssh helper functions
sshagent             [x]        sshagent helper functions
xterm                [x]        automatically set your xterm title with host and location info

showing aliases
docker               [x]        docker abbreviations
general              [x]        general aliases
git                  [x]        common git abbreviations
homebrew-cask        [x]        Some aliases for Homebrew Cask
homebrew             [x]        Some aliases for Homebrew
osx                  [x]        osx-specific aliases
tmux                 [x]        Tmux terminal multiplexer

showing completions
aliases              [x]
awscli               [x]
bash-it              [x]
brew                 [x]        brew completion
docker               [x]        docker completion
export               [x]
git_flow             [x]
github-cli           [x]        GitHub CLI completion
go                   [x]        completion for go command using gocomplete
makefile             [x]
ssh                  [x]
system               [x]
tmux                 [x]

Steps to reproduce

_

Bash-it version

v3.0.0

List of enabled plugins, themes and aliases

in the context section

Bash version

GNU bash, version 5.1.16(1)-release (x86_64-apple-darwin20.6.0)

Operating system and version

macOS 11.6.3 20G415 (pulled by sw_vers)

bash-it doctor output

$ bash-it doctor
DEBUG: core: main: Loading libraries(except appearance)...
DEBUG: lib: colors: Loading library file...
DEBUG: lib: helpers: Loading library file...
DEBUG: lib: history: Loading library file...
DEBUG: lib: log: Loading library file...
DEBUG: lib: preexec: Loading library file...
DEBUG: lib: preview: Loading library file...
DEBUG: lib: search: Loading library file...
DEBUG: lib: utilities: Loading library file...
DEBUG: core: reloader: Loading all enabled components...
DEBUG: aliases: docker: Loading component...
DEBUG: aliases: docker: Loaded.
DEBUG: aliases: general: Loading component...
DEBUG: aliases: general: Loaded.
DEBUG: aliases: git: Loading component...
DEBUG: aliases: git: Loaded.
DEBUG: aliases: homebrew-cask: Loading component...
DEBUG: aliases: homebrew-cask: Loaded.
DEBUG: aliases: homebrew: Loading component...
DEBUG: aliases: homebrew: Loaded.
DEBUG: aliases: osx: Loading component...
DEBUG: aliases: osx: Loaded.
DEBUG: aliases: tmux: Loading component...
DEBUG: aliases: tmux: Loaded.
DEBUG: plugin: base: Loading component...
DEBUG: plugin: base: Command 'markdown' does not exist
DEBUG: plugin: base: Command 'mkisofs' does not exist
DEBUG: plugin: base: Loaded.
DEBUG: plugin: git: Loading component...
DEBUG: plugin: git: Loaded.
DEBUG: plugin: man: Loading component...
DEBUG: plugin: man: Loaded.
DEBUG: plugin: osx: Loading component...
DEBUG: plugin: osx: Function 'update_terminal_cwd' does not exist
DEBUG: plugin: osx: Loaded.
DEBUG: plugin: ssh: Loading component...
DEBUG: plugin: ssh: Loaded.
DEBUG: plugin: sshagent: Loading component...
DEBUG: plugin: sshagent: Loaded.
DEBUG: plugin: xterm: Loading component...
DEBUG: plugin: xterm: Loaded.
DEBUG: completion: awscli: Loading component...
DEBUG: completion: awscli: Command 'aws_completer' does not exist
DEBUG: completion: awscli: Loaded.
DEBUG: completion: bash-it: Loading component...
DEBUG: completion: bash-it: Loaded.
DEBUG: completion: docker: Loading component...
DEBUG: completion: docker: Completion for 'docker' already exists
DEBUG: completion: docker: Loaded.
DEBUG: completion: export: Loading component...
DEBUG: completion: export: Loaded.
DEBUG: completion: git_flow: Loading component...
DEBUG: completion: git_flow: Loaded.
DEBUG: completion: github-cli: Loading component...
DEBUG: completion: github-cli: Completion for 'gh' already exists
DEBUG: completion: github-cli: Loaded.
DEBUG: completion: go: Loading component...
DEBUG: completion: go: Command 'gocomplete' does not exist
DEBUG: completion: go: Loaded.
DEBUG: completion: makefile: Loading component...
DEBUG: completion: makefile: Loaded.
DEBUG: completion: ssh: Loading component...
DEBUG: completion: ssh: Loaded.
DEBUG: completion: system: Loading component...
DEBUG: completion: system: Loaded.
DEBUG: completion: tmux: Loading component...
DEBUG: completion: tmux: Loaded.
DEBUG: completion: brew: Loading component...
DEBUG: completion: brew: Loaded.
DEBUG: completion: aliases: Loading component...
DEBUG: completion: aliases: Loaded.
DEBUG: core: main: Loading theme 'roderik'.
DEBUG: themes: base: Command 'battery_percentage' does not exist
DEBUG: core: main: Loading custom aliases, completion, plugins...
DEBUG: core: main: Loading general custom files...
DEBUG: custom: example: Loading custom file...
DEBUG: core: main: Command 'gloobus-preview' does not exist```

### Your ~/.bashrc

```bash
$ cat ~/.bashrc

#!/usr/local/bin/bash
# If not running interactively, don't do anything
case $- in
  *i*) ;;
    *) return;;
esac

# Path to the bash it configuration
export BASH_IT="/Users/rong/.bash_it"

# Lock and Load a custom theme file.
# Leave empty to disable theming.
# location / .bash_it/themes/
export BASH_IT_THEME='roderik'

# (Advanced): Change this to the name of your remote repo if you
# cloned bash-it with a remote other than origin such as `bash-it`.
# export BASH_IT_REMOTE='bash-it'

# Your place for hosting Git repos. I use this for private repos.
export GIT_HOSTING='git@git.domain.com'

# Don't check mail when opening terminal.
unset MAILCHECK

# Change this to your console based IRC client of choice.
#export IRC_CLIENT=''

# Set this to the command you use for todo.txt-cli
export TODO="t"

# Set this to false to turn off version control status checking within the prompt for all themes
export SCM_CHECK=true

# Set Xterm/screen/Tmux title with only a short hostname.
# Uncomment this (or set SHORT_HOSTNAME to something else),
# Will otherwise fall back on $HOSTNAME.
#export SHORT_HOSTNAME=$(hostname -s)

# Set Xterm/screen/Tmux title with only a short username.
# Uncomment this (or set SHORT_USER to something else),
# Will otherwise fall back on $USER.
#export SHORT_USER=${USER:0:8}

# Set Xterm/screen/Tmux title with shortened command and directory.
# Uncomment this to set.
export SHORT_TERM_LINE=true

# Set vcprompt executable path for scm advance info in prompt (demula theme)
# https://github.com/djl/vcprompt
#export VCPROMPT_EXECUTABLE=~/.vcprompt/bin/vcprompt

# (Advanced): Uncomment this to make Bash-it reload itself automatically
# after enabling or disabling aliases, plugins, and completions.
#export BASH_IT_AUTOMATIC_RELOAD_AFTER_CONFIG_CHANGE=1

# Uncomment this to make Bash-it create alias reload.
# export BASH_IT_RELOAD_LEGACY=1

# Load Bash It
source "$BASH_IT"/bash_it.sh

# for readline
LDFLAGS="-L/usr/local/opt/readline/lib"
CPPFLAGS="-I/usr/local/opt/readline/include"
PKG_CONFIG_PATH="/usr/local/opt/readline/lib/pkgconfig"

source "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/path.bash.inc"
source "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/completion.bash.inc"

source "$HOME/.config/ocm-container/env.source"

CMD=$(cat <<END
paths = [ 

    "${HOME}/.cargo/bin",
    "${HOME}/.krew/bin",
    "${HOME}/Repositories/jira",
    "${HOME}/Repositories/ops-sop/v4/utils",
        "${HOME}/Repositories/ugbt-update-all-gobin/",
    "${HOME}/bin/",
    "${HOME}/go/bin/",
    "/usr/local/bin",
    "/usr/local/opt/coreutils/libexec/gnubin",
    "/usr/local/opt/findutils/libexec/gnubin",
    "/usr/local/opt/gnu-sed/libexec/gnubin",
    "/usr/local/opt/gnu-tar/libexec/gnubin",
    "/usr/local/opt/icu4c/bin",
    "/usr/local/opt/icu4c/sbin",
    "/usr/local/opt/openjdk@11/bin",
    "/usr/local/opt/python@3.9/bin",
    "/usr/local/sbin",

    "" # useful for sorting the paths and not caring for last ','

]
stringed_path = ":".join(paths[:-1])

print(stringed_path)
END
)

PATH_ARGS=$(python3 -c "$CMD")
export PATH=":$PATH"
export PATH=${PATH_ARGS}:${PATH}

#export BASH_SILENCE_DEPRECATION_WARNING=1

if [ -f ~/.bash_aliases ] ; then
    . ~/.bash_aliases
fi
if [ -f ~/.bash_functions ] ; then
    . ~/.bash_functions
fi
bind -f ~/.bash_key_bindings

export LC_CTYPE=en_US.UTF-8

#source /usr/local/etc/bash_completion.d/git-prompt.sh

Notes

No response

NoahGorny commented 2 years ago

Hi @georgettic, can you tell us what was the commit/PR that broke this for you? you can use git bisect in order to find out. It's weird to me that it only happens now after updating, as we did not source the file beforehand

gaelicWizard commented 2 years ago

@georgettica, which bash-completion do you have installed? Is it from Homebrew? Is it linked or unlinked?

(I recently made changes to completion/system that meant to improve handling loading different installations of bash-completion, and the git-prompt.sh file should be loaded via that.)

georgettica commented 2 years ago

I'll check it tomorrow :)

georgettica commented 2 years ago

I have bash completion from brew, after running the:

==> Caveats
Add the following line to your ~/.bash_profile:

this was solved.

thanks so much and sorry for wasting your time :(