kovidgoyal / kitty

Cross-platform, fast, feature-rich, GPU based terminal
https://sw.kovidgoyal.net/kitty/
GNU General Public License v3.0
24.49k stars 979 forks source link

[Bug] Unable to enable features like "shopt expand_aliases" when 'bash -c cmd1; cmdN' as the given command #6673

Closed IceAsteroid closed 1 year ago

IceAsteroid commented 1 year ago

To Reproduce Steps to reproduce the behavior:

  1. Run kitty "bash -c 'sleep 0.05; shopt -s expand_aliases; source ${HOME}/.bashrc; wt-dnscrypt" from a terminal or in a script. Where "wt-dnscrypt" is an alias from .bashrc conf file.
  2. It will then immediately close the new opened terminal
  3. The error: "/home/apple/.bashrc: line 25: bind: warning: line editing not enabled", this error may also be related to the actual problem, I doubt the expand_aliases functionality is also not enabled, so, there's no wt-dnscrypt anyways, so the terminal is closed.
    
    historyEnhance_() {
    #stty -F /dev/tty -echo;
    #echo "type $(sed -E 's/^ ?*[0-9]?*\*?//' <<<"$(history | sed -E 's/^ ?*[0-9]+ //' | sed -E 's/ ?*$//' | fzf --tac )")" | dotool
    ;
    echo "type "$(sed -E 's/^ ?*[0-9]+ //;s/^ ?*[0-9]?*\*?//' <<<"$(history | sed -E 's/^ ?*//' | fzf --tac)")"" | dotool
    #stty -F /dev/tty echo
    }

bind new or change keybindings of bash

enhanced version of C-r for history searching

$() must be added, otherwise, sometimes shell won't show user typing anymore after ^C cancallin a command's running and then us

e C-r. bind -x '"\C-r":"$(historyEnhance_)"'


**Screenshots**
If applicable, add screenshots to help explain your problem.

**Environment details**

kitty 0.29.2 created by Kovid Goyal Linux unix 6.3.13_1 #1 SMP PREEMPT_DYNAMIC Tue Jul 25 00:19:40 UTC 2023 x86_64 Void 6.3.13_1 (unix) (/dev/tty)

Running under: Wayland Frozen: False Paths: kitty: /usr/bin/kitty base dir: /usr/lib/kitty extensions dir: /usr/lib/kitty/kitty system shell: /bin/bash Loaded config files: /home/apple/.config/kitty/kitty.conf

Config options different from defaults: font_family JetBrainsMono Nerd Font font_size 13.0 Colors: background #fbf1c7
color0 #ebdbb2
color1 #cc241d
color10 #79740e
color11 #b57614
color12 #076678
color13 #8f3f71
color14 #427b58
color15 #282828
color2 #98971a
color3 #d79921
color4 #458588
color5 #b16286
color6 #689d6a
color7 #7c6f64
color8 #928374
color9 #9d0006
cursor #665c54
cursor_text_color #bdae93
foreground #3c3836
selection_background #d65d0e
selection_foreground #3c3836
url_color #458588

Important environment variables seen by the kitty process: PATH /usr/lib/ruby/gems/3.2.0/bin:/home/apple/Bin:/home/apple/Bin/ScriptsLocal:/home/apple/Bin/Iptables:/home/apple/Bin/StartInTerminalFZF:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin:/home/apple/Bin/Games:/usr/sbin LANG en_US.UTF-8 EDITOR nvim SHELL /bin/bash GLFW_IM_MODULE ibus DISPLAY :0 WAYLAND_DISPLAY wayland-1 USER apple XCURSOR_SIZE 24 XDG_SEAT seat0 XDG_SESSION_TYPE wayland XDG_SESSION_CLASS user XDG_SESSION_ID 9 XDG_RUNTIME_DIR /tmp/1000-runtime-dir XDG_VTNR 1

** Additional information **
Also, in the original terminal where the new window is opened from, An error complaints:

[277 00:59:37.963738] [glfw error 65544]: process_desktop_settings: failed with error: [org.freedesktop.DBus.Error.UnknownMethod] No such interface “org.freedesktop.portal.Settings” on object at path /org/freedesktop/portal/desktop"


I was able to do such things without problems in alacritty so far. I wonder if this is considered a bug.

Any ideas?
kovidgoyal commented 1 year ago

This has nothing to do with kitty. Read man bash focusing on the section about when the various bash rc files are sourced. Depending on where your aliases are defined you will need to pass the appropriate options to bash.

IceAsteroid commented 1 year ago

@kovidgoyal, Hi, greetings!

But what, I do exactly what I should do for bash. It works on alacritty, but not on kitty. I wonder why such an issue would occur.

My goal is to call a script and for it to have more than one commands executed in a new opening terminal.

Why would this not work on kitty specifically?

Moreover, the reason why I switched to kitty, is alacritty cannot have different themes to switch, or it allegedly can do with a workaround that as someone mentioned in an issue page but not documented. And devs of it have been cocky so far.

Of course, alacritty is fast as rocket, but performance is not the first concern in my case.

kovidgoyal commented 1 year ago

On Wed, Oct 04, 2023 at 06:03:54AM -0700, IceAsteroid wrote:

@kovidgoyal, Hi.

But what, I do exactly what I should do for bash. It works on alacritty, but not on kitty. I wonder why such an issue would occur.

Read the manual, use the right options. Probably, bash -i -l

Presumably because alacritty is incorrectly running bash in login/interactive mode even though you have not asked it to. kitty will only do that when running it as an actual interactive shell.

My goal is to call a script and for it to have more than one commands executed in a new opening terminal.

Why would this not work on kitty specifically?

It works fine.

IceAsteroid commented 1 year ago

ok, thank you for the advice, have a good day, sir!

It worked!

I tried the following, and it ran like a rock.

kitty bash -i -c 'ls; sleep 2, shopt expand_aliases; wt-dnscrypt

No '-l' option here, since it launches shell as a login shell, that will bring code from ".bash_profile", which I have put stuff to run at login.

Indeed, without the '-i' option for bash, I cannot use shell options like expand_aliases, with just bash in a terminal.

My bad for not comprehensively searching for solutions. Sorry for the disturbance :(