Closed msr8 closed 2 years ago
Thank you for the report and sorry for the late reply. This generally happens when .bash_profile
/ .bashrc
is sourced from another place in a context there are positional parameters (i.e., $1
, $2
, etc.). Kitty does something non-trivial in its startup to inject shell-integration codes (cf Shell integration - kitty). In fact, kitty disables .bash_profile
of Bash and instead sources .bash_profile
from its integration code.
However, as far as I see kitty's shell-integration code in the above link, I currently don't have an idea how the reported error arises. I tried to reproduce the problem in my environment, but it doesn't seem to reproduce. I tried kitty 0.25.2 (the latest release) in Fedora 35 with the following setting:
# ~/.bash_profile
source .bashrc
# ~/.bashrc
eval "$(zoxide init bash)"
source ~/.local/share/blesh/ble.sh
Hey there! Please don't be sorry. Blesh is now working after doing the 3rd (manually setting up kitty's shell integration) solution. The others didn't work for me. I am using the latest kitty version too, as shown below. And I used to use ble.sh on this device (macbook air 2017) (tho it was running macOS Catlina, while this machine is running Monterey) for a few months, but I factory resetted it a few days ago and was trying to install blesh on it. I am afraid I dont remember how I used to call my .bashrc
or initialise blesh in that. But if you will give me a few minutes, I will look into my backups and check
Edit: I am afraid I didn't backup the .bash_profile
or .bashrc
before resetting the device. I just uploaded a modified version (which didn't contain the lines to initialise blesh) to git as a "backup" before deleting everything
Edit 2: Perhaps it could just be an issue on MacOS Monterey version 12.5?
Thank you for the detailed information!
The others didn't work for me.
Do you remember if the error message was the same for the second one (with the setup described in README §1.3)? Considering the fact that it is actually solved by manually setting up kitty's shell integration, I think the second solution should also solve the problem, yet there might be another separate issue. More specifically, if you specify an option --noattach
(or --attach=none
, --attach=prompt
, etc.) to source /path/to/ble.sh --noattach
, the positional parameters would be supposed to be overridden so that the argument of the outer scope (i.e., /Users/mark/.bash_profile
in the present case) would not be passed to ble.sh.
I am using the latest kitty version too, as shown below. And I used to use ble.sh on this device (macbook air 2017) (tho it was running macOS Catlina, while this machine is running Monterey) for a few months, but I factory resetted it a few days ago and was trying to install blesh on it.
A possible reason of the behavior change might be because you had been using an older version of kitty before you factory-reset it. Actually, the current form of kitty's shell integration is introduced only recently in kitty v0.24.0 (2022-01-04).
Edit 2: Perhaps it could just be an issue on MacOS Monterey version 12.5?
Hmm, currently I don't have an idea, but this type of issue wouldn't typically be operating-system-specific in my naive thinking. I'd appreciate it if you could see what messages would be shown on the kitty startup with the automatic shell integration (without the manual setup of the shell integration) with the following additional settings in ~/.bash_profile
. You can remove these settings after you checked the message.
# test code in ~/.bash_profile
{
declare -p BASH_SOURCE FUNCNAME
printf '<%s>\n' "$@"
type source
} >&2
Do you remember if the error message was the same for the second one (with the setup described in README §1.3)?
It works AS LONG AS the line shell_integration disabled
is added in kitty.conf
. Wait lemme show you in more detail
where the issue doesn't arrise
╭─[mark]-[Marks-MacBook-Air (192.168.1.12)]-[~]
╰─[$] cat .bash_profile
source ~/.bashrc
export BASH_SILENCE_DEPRECATION_WARNING=1
#if test -n "$KITTY_INSTALLATION_DIR"; then
# export KITTY_SHELL_INTEGRATION="enabled"
# source "$KITTY_INSTALLATION_DIR/shell-integration/bash/kitty.bash"
#fi
╭─[mark]-[Marks-MacBook-Air (192.168.1.12)]-[~]
╰─[$] cat .bashrc
[[ $- == *i* ]] && source ~/.local/share/blesh/ble.sh --noattach
# ---------- ALIASES ----------
alias grep='grep --color=auto'
alias py='python3'
alias ls='lsd'
alias cd='z'
alias vim='nvim'
alias cls='clear'
alias bro='sudo'
alias daddy='sudo'
alias bitch='sudo'
alias please='sudo'
alias locip="ifconfig | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1'"
alias hideicons='defaults write com.apple.finder CreateDesktop false; killall Finder'
alias showicons='defaults write com.apple.finder CreateDesktop true; killall Finder'
# ---------- PS1 ----------
# User
PS1='\[\033[1;97m\] ╭─[\[\033[1;92m\]\u\[\033[1;97m\]]-'
# Hostname
PS1+='[\[\033[1;95m\]\h ($(locip))\[\033[1;97m\]]-'
# Pwd
PS1+='[\[\033[1;94m\]\w\[\033[1;97m\]]\n'
# Final
PS1+=' ╰─[\[\033[1;92m\]\$\[\033[1;97m\]] \[\033[0m\]'
export PS1
# ---------- ZOXIDE ----------
eval "$(zoxide init bash)"
# ---------- BLESH ----------
source ~/.local/share/blesh/ble.sh
# ---------- FUCK ----------
eval "$(thefuck --alias)"
# ---------- SPICETIFY ----------
export SPICETIFY_INSTALL="/Users/mark/.spicetify"
export PATH="$PATH:/Users/mark/.spicetify"
[[ ${BLE_VERSION-} ]] && ble-attach
╭─[mark]-[Marks-MacBook-Air (192.168.1.12)]-[~]
╰─[$] cat .config/kitty/kitty.conf
confirm_os_window_close 0
remember_window_size no
# initial_window_width 610
initial_window_width 920
initial_window_height 390
# background_opacity 0.69
background_opacity 0.9
background #020B0E
foreground #FFFFFF
# selection_background #525252
# font_family Lucida Console Regular
font_family Ubuntu Mono
font_size 16.0
cursor_shape beam
tab_bar_edge top
tab_bar_style powerline
close_on_child_death yes
macos_quit_when_last_window_closed yes
hide_window_decorations titlebar-only
window_padding_width 6
adjust_line_height 130%
adjust_column_width 110%
# map shift+ctrl+d close_tab
map alt+t new_tab
map alt+= new_tab
map alt+q close_tab
map alt+- close_tab
map alt+1 goto_tab 1
map alt+2 goto_tab 2
map alt+3 goto_tab 3
map alt+4 goto_tab 4
map alt+5 goto_tab 5
map alt+6 goto_tab 6
map alt+7 goto_tab 7
map alt+8 goto_tab 8
map alt+9 goto_tab 9
map alt+right next_tab
map alt+left previous_tab
map shift+super+= change_font_size all +1.0
map shift+super+- change_font_size all -1.0
map alt+r set_tab_title
map cmd+f toggle_fullscreen
shell_integration disabled
where the issue does arrise
ble.sh: unrecognized argument '/Users/mark/.bash_profile'
ble.sh: cancel initialization.
╭─[mark]-[Marks-MacBook-Air (192.168.1.12)]-[~]
╰─[$] cat .bash_profile
source ~/.bashrc
export BASH_SILENCE_DEPRECATION_WARNING=1
#if test -n "$KITTY_INSTALLATION_DIR"; then
# export KITTY_SHELL_INTEGRATION="enabled"
# source "$KITTY_INSTALLATION_DIR/shell-integration/bash/kitty.bash"
#fi
╭─[mark]-[Marks-MacBook-Air (192.168.1.12)]-[~]
╰─[$] cat .bashrc
[[ $- == *i* ]] && source ~/.local/share/blesh/ble.sh --noattach
# ---------- ALIASES ----------
alias grep='grep --color=auto'
alias py='python3'
alias ls='lsd'
alias cd='z'
alias vim='nvim'
alias cls='clear'
alias bro='sudo'
alias daddy='sudo'
alias bitch='sudo'
alias please='sudo'
alias locip="ifconfig | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1'"
alias hideicons='defaults write com.apple.finder CreateDesktop false; killall Finder'
alias showicons='defaults write com.apple.finder CreateDesktop true; killall Finder'
# ---------- PS1 ----------
# User
PS1='\[\033[1;97m\] ╭─[\[\033[1;92m\]\u\[\033[1;97m\]]-'
# Hostname
PS1+='[\[\033[1;95m\]\h ($(locip))\[\033[1;97m\]]-'
# Pwd
PS1+='[\[\033[1;94m\]\w\[\033[1;97m\]]\n'
# Final
PS1+=' ╰─[\[\033[1;92m\]\$\[\033[1;97m\]] \[\033[0m\]'
export PS1
# ---------- ZOXIDE ----------
eval "$(zoxide init bash)"
# ---------- BLESH ----------
source ~/.local/share/blesh/ble.sh
# ---------- FUCK ----------
eval "$(thefuck --alias)"
# ---------- SPICETIFY ----------
export SPICETIFY_INSTALL="/Users/mark/.spicetify"
export PATH="$PATH:/Users/mark/.spicetify"
[[ ${BLE_VERSION-} ]] && ble-attach
╭─[mark]-[Marks-MacBook-Air (192.168.1.12)]-[~]
╰─[$] cat .config/kitty/kitty.conf
confirm_os_window_close 0
remember_window_size no
# initial_window_width 610
initial_window_width 920
initial_window_height 390
# background_opacity 0.69
background_opacity 0.9
background #020B0E
foreground #FFFFFF
# selection_background #525252
# font_family Lucida Console Regular
font_family Ubuntu Mono
font_size 16.0
cursor_shape beam
tab_bar_edge top
tab_bar_style powerline
close_on_child_death yes
macos_quit_when_last_window_closed yes
hide_window_decorations titlebar-only
window_padding_width 6
adjust_line_height 130%
adjust_column_width 110%
# map shift+ctrl+d close_tab
map alt+t new_tab
map alt+= new_tab
map alt+q close_tab
map alt+- close_tab
map alt+1 goto_tab 1
map alt+2 goto_tab 2
map alt+3 goto_tab 3
map alt+4 goto_tab 4
map alt+5 goto_tab 5
map alt+6 goto_tab 6
map alt+7 goto_tab 7
map alt+8 goto_tab 8
map alt+9 goto_tab 9
map alt+right next_tab
map alt+left previous_tab
map shift+super+= change_font_size all +1.0
map shift+super+- change_font_size all -1.0
map alt+r set_tab_title
map cmd+f toggle_fullscreen
# shell_integration disabled
Here as you can see, the error only arrises when the line shell_integration disabled
is commented out in kitty.conf
, and its the same error. If the output is too messy, I can edit my comment to make it more readable, just lmk :)
I'd appreciate it if you could see what messages would be shown on the kitty startup
So adding those in with the config files the same as shown under where the issue does arrise
, but .bash_profile
changed to
{
declare -p BASH_SOURCE FUNCNAME
printf '<%s>\n' "$@"
type source
} >&2
source ~/.bashrc
export BASH_SILENCE_DEPRECATION_WARNING=1
#if test -n "$KITTY_INSTALLATION_DIR"; then
# export KITTY_SHELL_INTEGRATION="enabled"
# source "$KITTY_INSTALLATION_DIR/shell-integration/bash/kitty.bash"
#fi
This is the output:
declare -a BASH_SOURCE=([0]="/Users/mark/.bash_profile" [1]="/Applications/kitty.app/Contents/Resources/kitty/shell-integration/bash/kitty.bash" [2]="/Applications/kitty.app/Contents/Resources/kitty/shell-integration/bash/kitty.bash" [3]="/Applications/kitty.app/Contents/Resources/kitty/shell-integration/bash/kitty.bash")
declare -a FUNCNAME=([0]="source" [1]="_ksi_safe_source" [2]="_ksi_inject" [3]="source")
</Users/mark/.bash_profile>
source is a shell builtin
ble.sh: unrecognized argument '/Users/mark/.bash_profile'
ble.sh: cancel initialization.
╭─[mark]-[Marks-MacBook-Air (192.168.1.12)]-[~]
╰─[$]
It works AS LONG AS the line
shell_integration disabled
is added inkitty.conf
.
I meant by automatic shell integration the case without the line shell_integration disable
in kitty.conf
.
Wait lemme show you in more detail
Ah, OK. You are sourcing ble.sh twice (with and without --noattach
). The error message is shown for the second source of ble.sh without --noattach
in your ~/.bashrc
. The setup in README §1.3 is meant to replace the simple source ble.sh
. When you have the setup as README §1.3, the original simple source /path/to/ble.sh
should be removed.
This is the output:
declare -a BASH_SOURCE=([0]="/Users/mark/.bash_profile" [1]="/Applications/kitty.app/Contents/Resources/kitty/shell-integration/bash/kitty.bash" [2]="/Applications/kitty.app/Contents/Resources/kitty/shell-integration/bash/kitty.bash" [3]="/Applications/kitty.app/Contents/Resources/kitty/shell-integration/bash/kitty.bash") declare -a FUNCNAME=([0]="source" [1]="_ksi_safe_source" [2]="_ksi_inject" [3]="source") </Users/mark/.bash_profile> source is a shell builtin ble.sh: unrecognized argument '/Users/mark/.bash_profile' ble.sh: cancel initialization. ╭─[mark]-[Marks-MacBook-Air (192.168.1.12)]-[~]
Thank you! OK, so .bash_profile
seems to be called through helper functions _ksi_inject
and _ksi_safe_source
, which I don't find in the latest version of kitty.bash
. It seems to have been removed in commit https://github.com/kovidgoyal/kitty/commit/d6492264c7541d41afcf2958142475ca1c7f7d3d after the report https://github.com/kovidgoyal/kitty/issues/5254 on 8th Jul. This means that the problem will be anyway fixed in the next release of kitty, though I'm still not sure why the problem doesn't arise in my environment with kitty 0.25.2. FWIW, the problematic code seems to have been introduced in commit https://github.com/kovidgoyal/kitty/commit/88091b4ab3cb8016dc80dda4c0327e857a9fdcdc and included in kitty 0.24.3+.
Ah, OK. You are sourcing ble.sh twice
Oh yeah, I didn't notice, sorry about that
This means that the problem will be anyway fixed in the next release of kitty
Nice, what workaround do you recommend I use in the meantime though?
I recommend the setup in README §1.3, which is more robust against other types of conflicts with other Bash configurations.
kitty v0.26.0 seems to have been released.
Yupp, it works flawlessly with that, thank you!
Thank you!
ble version: 0.4.0-devel3+a22e145 Bash version: 5.1.16(1)-release (x86_64-apple-darwin21.1.0)
So whenever I start a new shell, it shows me this:
These are the contents of
/Users/mark/.bash_profile
:These are the contents of my .bashrc:
Edit: Just noticed that this happens only when I open a new shell using Kitty, and not via any other terminal
Edit 2: If I do
source .bashrc
after starting the shell, it works