Closed baffalop closed 2 years ago
Hey @baffalop! Would you mind sharing your .bashrc
file? My intuition is that you might still be sourcing the old iTerm shell integration in addition to the new one?
Thanks for investigating @mschrage ! Below is my .bash_profile
with just aliases, functions and completions redacted.
#### FIG ENV VARIABLES ####
# Please make sure this block is at the start of this file.
[ -s ~/.fig/shell/pre.sh ] && source ~/.fig/shell/pre.sh
#### END FIG ENV VARIABLES ####
# highlights
export CLICOLOR=1
export LSCOLORS=ExFxCxDxBxegedabagacad
# prompt colours
export PS1="\[\033[33;1m\]\w\[\033[m\](\t)\[\033[1;97m\]$\[\033[0m\] "
# neovim as editor
export VISUAL=nvim
export EDITOR=$VISUAL
# bash-completion
[ -f /usr/local/etc/bash_completion ] && . /usr/local/etc/bash_completion
# shell integration
test -e "${HOME}/.iterm2_shell_integration.bash" && source "${HOME}/.iterm2_shell_integration.bash"
# readable blue
it2setcolor blue 57f
# vim in bash prompt
set -o vi
# paths
export PATH=~/.bin:~/Library/Python/2.7/bin:~/Library/Python/3.7/bin:~/.local/bin:$PATH
# Setting PATH for Python 3.9
# The original version is saved in .bash_profile.pysave
export PATH="/Library/Frameworks/Python.framework/Versions/3.9/bin:${PATH}"
# android development
export PATH=~/Library/Android/sdk/tools:~/Library/Android/sdk/tools/bin:~/Library/Android/sdk/platform-tools:$PATH
export JAVA_HOME=/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home # open JDK-8
export ANDROID_HOME=~/Library/Android/sdk
#### FIG ENV VARIABLES ####
# Please make sure this block is at the end of this file.
[ -s ~/.fig/fig.sh ] && source ~/.fig/fig.sh
#### END FIG ENV VARIABLES ####
To me it doesn't seem possible that I'm sourcing the old integration, but I don't know much about it.
I am also experiencing this issue. It arose after fixing the similar __bp_sanitize_string: command not found
problem (#612), just like @baffalop. Here's my .bash_profile
, also redacted, after uninstalling fig.
test -r /sw/bin/init.sh && . /sw/bin/init.sh
# Wed Jan 8 15:31:23 EST 2014 - MODIS Reprojection Tool modifications
MRT_HOME="/Applications/MRT"
PATH="$PATH:/Applications/MRT/bin"
MRT_DATA_DIR="/Applications/MRT/data"
export MRT_HOME PATH MRT_DATA_DIR
export PATH=/usr/local/bin:$PATH
# added by SSR 2015-02-27
HDF5_DIR="/usr/local/hdf"
export PATH=/usr/local/sbin:$PATH
export PATH=/usr/local/sbin:$PATH
# added by ssr 2015-12-07
source /usr/local/ferret_paths
# added by ssr 2016-06-17
export PATH="/Users/Shared/dir1/dir2/bin:$PATH"
# added by ssr 2016-06-27
alias my_utils="cat /Users/Shared/dir1/dir2/readme.txt"
test -e "${HOME}/.iterm2_shell_integration.bash" && source "${HOME}/.iterm2_shell_integration.bash"
# added by ssr 2016-08-25
export PS1='\[\033[1;34m\]\u:$PWD$\[\033[0m\] '
# added by ssr 2016-08-24
export PATH="/Users/Shared/misc_shell_scripts:$PATH"
# added by ssr 2016-10-21
alias ls='ls -G'
alias la='ls -A'
alias ll='ls -lh'
alias llt='ls -ltrh'
#added by ssr 2017-04-04
alias sq='ssh user@server.com /usr/bin/squeue -o \"%.7i %.4P %.14j %.8T %.10M %.9l %.6D %R\"'
alias sq2b='ssh user@server.com /home/user/scripts/sq2 -b'
# Setting PATH for Python 3.6
# The original version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.6/bin:${PATH}"
export PATH
# Some gdal utilities got screwed up by installation of Python3. This fixes it, at least for gdal_polygonize.py
export PATH=/Library/Frameworks/GDAL.framework/Programs:$PATH
##
# Your previous /Users/sam/.bash_profile file was backed up as /Users/sam/.bash_profile.macports-saved_2018-07-11_at_15:22:25
##
# MacPorts Installer addition on 2018-07-11_at_15:22:25: adding an appropriate PATH variable for use with MacPorts.
export PATH="/opt/local/bin:/opt/local/sbin:$PATH"
# Finished adapting your PATH environment variable for use with MacPorts.
# MacPorts Installer addition on 2018-07-11_at_15:22:25: adding an appropriate MANPATH variable for use with MacPorts.
export MANPATH="/opt/local/share/man:$MANPATH"
# Finished adapting your MANPATH environment variable for use with MacPorts.
# Added by ssr 2019-01-15
alias rsyncc='rsync -ah --progress --partial --append'
if command -v pyenv 1>/dev/null 2>&1; then
eval "$(pyenv init -)"
fi
# Added by ssr 2020-05-20
# https://sourceforge.net/p/nco/discussion/9829/thread/a470c9a3dd/
export HDF5_USE_FILE_LOCKING=FALSE
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/Users/sam/Applications/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "/Users/sam/Applications/anaconda3/etc/profile.d/conda.sh" ]; then
. "/Users/sam/Applications/anaconda3/etc/profile.d/conda.sh"
else
export PATH="/Users/sam/Applications/anaconda3/bin:$PATH"
fi
fi
unset __conda_setup
# <<< conda initialize <<<
# Added by SSR generally to avoid Anaconda versions of stuff I have installed from elsewhere
# Moved up here by SSR 2021-12-08 to ensure that ARM versions of Homebrew stuff are used, when available
export PATH="/usr/local/bin:$PATH"
# This wrapper added by SSR 2021-12-08 to provide flexibility
# https://blog.smittytone.net/2021/02/07/how-to-migrate-to-native-homebrew-on-an-m1-mac/
cpu=$(uname -p)
if [[ "$cpu" == "arm" ]]; then
# Told to do this during brew installation
eval "$(/opt/homebrew/bin/brew shellenv)"
# To retain access to emulator versions
alias brewold=/usr/local/bin/brew
# See notes in "else" block
export PATH="/opt/homebrew/bin:$PATH"
export PATH="/opt/homebrew/Cellar/nco/4.9.3/bin:$PATH"
else
# Added by SSR 2020-07-07 trying to give priority to nco commands from Homebrew instead of Anaconda
export PATH="/usr/local/Cellar/nco/4.9.3/bin:$PATH"
fi
# Added by SSR 2020-12-28
export PATH=$PATH:/usr/local/go/bin
# Setting PATH for Python 3.9
# The original version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.9/bin:${PATH}"
export PATH
export PATH=/Library/Frameworks/GDAL.framework/Programs:$PATH
export BASH_SILENCE_DEPRECATION_WARNING=1
Hey @baffalop @samsrabin! Would you mind running the following commands and sharing the output:
bash
which bash
bash --version
printf
Behaviorwhich printf
printf -v existing_prompt_command '%s' 'hello world'
echo $existing_prompt_command
Also @baffalop if you still have Fig installed could you try commenting out this line in ~/.fig/shell/post.bash
:
__bp_sanitize_string existing_prompt_command "$existing_prompt_command"
Let us know if this resolves the issue! (Don't forget that you'll need to open a new terminal session for the changes to be applied).
@mschrage Commenting out that line did indeed fix the issue!
As for the versions:
$ which bash
/usr/local/bin/bash
$ bash --version
GNU bash, version 5.1.4(1)-release (x86_64-apple-darwin19.6.0)
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
$ which printf
/usr/bin/printf
$ printf -v existing_prompt_command '%s' 'hello world'
$ echo $existing_prompt_command
hello world
Running the last two commands in a session without your suggested patch applied, just in case:
$ printf -v existing_prompt_command '%s' 'hello world'
existing_prompt_command
$ echo $existing_prompt_command
hello world
existing_prompt_command
(Essentially the same output, modulo the intrusive existing_prompt_command
message)
I get the same results as baffalop above (I reinstalled fig), so the commenting-out fixed it!
Have you installed bash
using brew
? It seems like the built-in printf
command may have changed behavior.
Could you run help printf
and share the output here if possible?
Nope, this is the macOS native bash
.
Output of help printf
:
printf: printf [-v var] format [arguments]
printf formats and prints ARGUMENTS under control of the FORMAT. FORMAT
is a character string which contains three types of objects: plain
characters, which are simply copied to standard output, character escape
sequences which are converted and copied to the standard output, and
format specifications, each of which causes printing of the next successive
argument. In addition to the standard printf(1) formats, %b means to
expand backslash escape sequences in the corresponding argument, and %q
means to quote the argument in a way that can be reused as shell input.
If the -v option is supplied, the output is placed into the value of the
shell variable VAR rather than being sent to the standard output.
Hmm super strange. Can you run type __bp_sanitize_string
for me?
And then can you run the following:
__bp_sanitize_string greeting "hello there"
echo $greeting
Btw thank you so much for all of the help debugging this! Really appreciate it!
Happy to help!
sam:/Users/sam$ type __bp_sanitize_string
__bp_sanitize_string is a function
__bp_sanitize_string ()
{
local sanitized_string;
sanitized_string=$(__bp_trim_whitespace "${1:-}");
sanitized_string=${sanitized_string%;};
sanitized_string=${sanitized_string#;};
sanitized_string=$(__bp_trim_whitespace "$sanitized_string");
echo -n "$sanitized_string"
}
sam:/Users/sam$ __bp_sanitize_string greeting "hello there"
greeting
sam:/Users/sam$ echo $greeting
(The last command just prints a blank line.)
Was able to reproduce this issue on my end and fix the issue. Seems like there are a few differences with the __bp_sanitize_string
function between versions 0.4.0 and 0.4.1 of https://github.com/rcaloras/bash-preexec.
Right now iTerm2's shell integrations use V0.4.0 and Fig requires V0.4.1 so if iTerm's shell integration is sourced first then your shell will end up with the old version and you'll end up with these messages.
We have a fix for this coming in our next build that avoids using internals of the pre-exec library on our end so there are no version compatibilities. For now, as a hotfix anyone running into this issue can put
if [[ -n "$BASH" ]]; then
source ~/.fig/shell/bash-preexec.sh
fi
at the top of ~/.fig/shell/pre.sh
to make sure V0.4.1 is sourced first and this should fix the issue. Please let us know if this fix is working!
Yup, can confirm that works!
For me this code block fixed the existing_prompt_command
print but then fig does not autocomplete at all anymore.
Hey @hoegertn! Which codeblock mine are you referring to here, mine or Sean's?
Sorry, I meant Sean's code
Can you upgrade to v1.0.54 and see if this resolves the issue. If not, would you mind sharing your bashrc file?
At first, it did not auto-complete at all, but I think I found the offending line in my profile by commenting it out line by line.
I had PROMPT_COMMAND='history -a'
set and that seems to break fig.
@hoegertn would you please be able to share your bashrc with us here or via email (hello@fig.io) and reference this issue. We will investigate and hopefully get this fixed!
@hoegertn this issue is likely related: #505
Can you share your bashrc file there?
Sanity checks
fig doctor
in the affected terminal sessionIssue Details
Description:
I've just getting set up with Fig and have just added the shell integration to my
.bash_profile
. I was initially getting the__bp_sanitize_string: command not found
error, but following the linked issue I updated my iTerm2 bash integration. However, now I instead get the stringexisting_prompt_command
printed after running any command. It's printed twice when starting a session or sourcing my.bash_profile
. Like so:Fig's autocompletion itself is working fine, but this is quite annoying. The same thing happens on iTerm2 and macOS Terminal. When I remove the line sourcing
~/.fig/fig.sh
the issue goes away.Here's the line in my
.bash_profile
for customising my prompt, in case that's relevant:System info
macOS 11.2.3 iTerm2 3.4.12 Fig 1.0.53 (B339)
Debugger screenshot
As required by the checklist:
Environment