warpdotdev / Warp

Warp is a modern, Rust-based terminal with AI built in so you and your team can build great software, faster.
https://warp.dev
Other
21.37k stars 373 forks source link

Tab autocomplete does not work for aliased commands #2807

Closed lcrespom closed 1 year ago

lcrespom commented 1 year ago

Discord username (optional)

Luis#2191

Describe the bug

I have some aliases defined in my .zshrc file, such as cat="bat", `ll="ls -lh", etc.

When I type those aliased commands and I press the tab key, autocomplete does not work, i.e., it does not show a list of files and directory to choose from.

I am using the latest version of Warp in the latest version of MacOS and I have restarted Warp after adding the aliases in .zshrc, and the problem persists. I have also tried the same in the default Terminal App provided by Apple and autocomplete works as expected even for aliased commands - this is why I consider this a bug.

To Reproduce

  1. Define some alias in ~/.zshrc, e.g. alias cat="bat".
  2. Restart Warp, go to a directory where some files are present.
  3. Type cat and then hit the tab key. A list of files in the directory should be displayed by Warp for autocompletion.

Expected behaviour

The behaviour should be the same as when hitting the tab key when using an unaliased command.

Screenshots

No response

Operating System

None

OS Version

13.2.1

Shell Version

zsh 5.8.1 (x86_64-apple-darwin22.0)

Warp Version

v0.2023.03.14.08.03.stable_01

Additional context

No response

Does this block you from using Warp daily?

No

Warp Internal (ignore): linear-label:b8107fdf-ba31-488d-b103-d271c89cac3e

None

dannyneira commented 1 year ago

Thanks for submitting @lcrespom, If you disable the "Open completions menu as you type" in `Settings > Features > Editor" and press Tab after the alias do you see the same missing completion menu?

https://user-images.githubusercontent.com/16809145/227039457-aa1a13a5-3aee-428e-8463-504d4c1b948f.mp4

lcrespom commented 1 year ago

Hello Danny,

I checked and that setting was already disabled. Anyway I enabled it and tested again, then disabled it and tested again, the result is always the same, no file autocompletion when hitting tab. And when I type "ls" or "ll" (which is aliased to ls -lh), hitting tab after "ls " autocompletes the ls options, e.g. --color, -1, etc., but not files nor directories.

dannyneira commented 1 year ago

Thanks for the follow-up, so since I can't reproduce the issue on my end, my guess is that you normally have a custom prompt, theme, or plugin and Warp is unable to parse it.

You can check whether it’s something in your dotfiles by setting up clean configs: Run echo 'ZDOTDIR=/' > ~/.zshenv This forces Zsh to run with zero configs.

You can disable parts of your dotfiles just for Warp by using this conditional statement:

# Bash and Zsh
if [[ $TERM_PROGRAM != "WarpTerminal" ]]; then
# > What you want to disable here <
fi
# Fish
if test "$TERM_PROGRAM" != "WarpTerminal"
# > What you want to disable here <
end

We have a list of incompatible tools here: https://docs.warp.dev/help/known-issues#list-of-incompatible-tools And more info on custom prompts here: https://docs.warp.dev/features/prompt

lcrespom commented 1 year ago

Hello Danny,

Actually I am using all the defaults: zsh with the default prompt and without any customization, other than adding 3 aliases at the end of my ~/.zshrc file. I reviewed the link https://docs.warp.dev/help/known-issues#list-of-incompatible-tools and I am not using any of those tools.

jkodesigned commented 1 year ago

Hi, I have the same problem as Icrespom, but in my case, disabling the Open completions menu as you type option works. I use alias for pygmentize alias pcat='pygmentize -f terminal256 -O style=monokai -g'.

vlad-s commented 1 year ago

Can also confirm this issue. I have ls: aliased to ls -h --color=auto so tab autocompletion is broken for anything ls related. Using /bin/ls <tab> works as expected.

dannyneira commented 1 year ago

@vlad-s, as a workaround I recommend you use ls -hG instead or ls -h --color=auto, you'll get the same effect of adding color, but drop the -- since that appears to be causing some of the issues with the auto-completion.

In general, it appears this issue affects aliases with multiple -'s in combination with '='`s, but we're investigating and will provide updates on this thread.

lcrespom commented 1 year ago

I tested it and now it works, I confirm the problem is when aliases have -- in their expansion.

This works for ls --color but not for other aliases that don't have a shorthand for some parameters, e.g. for cat='bat --theme '\''Monokai Extended Bright'\', there is no shorthand for --theme.

longcw commented 1 year ago

Any updates here? It seems that -G is not the same with --color: -G, --no-group in a long listing, don't print group names

dannyneira commented 1 year ago

Hey Folks, This has been fixed in recent version of Warp. Closing, but if you have any issues, let us know.

BugWriter2 commented 1 year ago

@dannyneira tested on v0.2023.05.23.08.05.stable_00, still not working. I have ls aliased to alias ls='ls --color=auto' in my ~/.bashrc

danisvaliev001 commented 1 year ago

the bug is there on v0.2023.05.30.08.03.stable_02

alias ll='ls -l --color=always' does not work alias ll='ls -lG' works

macOS Ventura 13.4, zsh 5.9, default Warp prompt.

simonjwicks commented 1 year ago

I'm also still seeing this in v0.2023.05.30.08.03.stable_03

grep aliased to alias grep="grep --color=always" in .zshrc

Ventura 13.4, default warp prompt, no incompatible tools and just 3 aliases in my .zshrc

limingchina commented 1 year ago

for this issue https://github.com/warpdotdev/Warp/issues/2969(the git log autocompletion with file/path problem), which is marked as a duplicate. It's also still not working. I have version v0.2023.06.06.08.02.stable_00.

danisvaliev001 commented 1 year ago

thanks for fix, alias ll='ls -l --color=always' works correct in today's upgrade v0.2023.06.13.08.03.stable_02

BugWriter2 commented 1 year ago

@dannyneira , The fix for alias ls='ls --color=auto' is still pending

tested on v0.2023.06.13.08.03.stable_02

gandazgul commented 1 year ago

This is still an issue for me with alias alias ls='ls --color=auto'. Warp: v0.2023.06.13.08.03.stable_03 MacOS: 12.6.5

dannyneira commented 1 year ago

hey Folks, Sorry about this issue, we're looking into it, but you can try using the -G flag instead of --color=auto/always for either ls or grep.

alias ls='ls -G'
alias grep='grep -G'

That should help until we resolve this issue.

danisvaliev001 commented 1 year ago

checked again, this works fine for me now: alias ll='ls -l --color=always'

all is fresh: macOS Ventura 13.4.1 zsh 5.9 (x86_64-apple-darwin22.0) Warp v0.2023.06.20.08.04.stable_03

dannyneira commented 1 year ago

@simonjwicks @gandazgul @lcrespom @BugWriter2 @limingchina Could you please confirm if the same issue is happening when you upgrade MacOS, zsh, and Warp to the latest version?

VeryLazyBoy commented 1 year ago

@dannyneira I believe --color=always works as expected in the latest Warp but not --color=auto

limingchina commented 1 year ago

@dannyneira , I have latest macos, zsh and warp installed.

zsh 5.9 (x86_64-apple-darwin22.0) ProductName: macOS ProductVersion: 13.4.1 BuildVersion: 22F82 v0.2023.06.20.08.04.stable_03

The autocompletion for directory/filename still doesn't work with "git log"

gandazgul commented 1 year ago

zsh 5.9 Warp v0.2023.06.20.08.04.stable_03 MacOS 12.6.5 I can't upgrade :(

Alias ll='ls -lha --color=always'

Tab does nothing, if I remove --color=always, then it works normally.

-G instead of --color=always doesnt show any colors for me.

danisvaliev001 commented 1 year ago

@limingchina @gandazgul @BugWriter2 @VeryLazyBoy do you use apple silicon or other?

i tested on m1. Maybe this is matters.

--color=always --color=auto – all works fine.

gandazgul commented 1 year ago

@danisvaliev001 mine is a MacBook Pro (16-inch, 2019) Intel i7. I dont have an M1 to test on.

BugWriter2 commented 1 year ago

@danisvaliev001 @dannyneira I apologize for not mentioning earlier that I am using the SSH wrapper functionality on my remote Linux server. I've observed that the behavior of the --color flag differs between my local Mac machine and the remote Linux server. On my Mac, both --color=always and --color=auto options seem to work, while on the Linux server only --color=always option works.

tested on warp: v0.2023.06.20.08.04.stable_03 macos: v13.1 (22C65) with intel chip remote ssh server: Ubuntu 20.04.6 LTS

gandazgul commented 1 year ago

I just rebooted Warp just in case, the ll alias or ls with the params make tab stop working. Specifically the = sign, ls -lah --color /[tab] works fine as soon as =auto or =always is added then it stops working. Just setting --color adds color btw so I have that as a workaround for now. But I'm guessing this bug affects any other params with =

simonjwicks commented 1 year ago

Still not working for me unfortunately

alias grep="grep --color=always" in ~/.zshrc With grep no tab autocomplete With egrep which is not aliased, it works

Warp: v0.2023.06.20.08.04.stable_03 macOS 13.4.1 (22F82) on M1 Max zsh 5.9 (x86_64-apple-darwin22.0)

gandazgul commented 1 year ago

@simonjwicks try removing the =always and leaving just --color, it makes the tab work and still colorizes the output.

image

simonjwicks commented 1 year ago

@gandazgul Thanks for the tip - works perfectly!

danielpeng2 commented 1 year ago

Hey all -- a fix is out in today's release (v0.2023.07.25.08.03.stable_00) that should fix filepath completions not appearing in the ls --color={value} case. Let me know if any further issues are encountered!

limingchina commented 1 year ago

The issue of auto completion of files is still fixed for "git log" command. But it's tracked with a separate ticket: https://github.com/warpdotdev/Warp/issues/2969