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
20.86k stars 355 forks source link

Support the use of function + aliases #2010

Closed isanmu closed 1 year ago

isanmu commented 1 year ago

Discord username (optional)

No response

Describe the bug

  1. First, Warp support automatic completion/selection for command cd;

  2. Second, I alias cd to function:

    function cdd(){
    cd $1;ls
    }
    alias cd='cdd'

    But automatic completion/selection cannot work in Warp, that confused me.

  3. Third, While i test it in iTerm, Tabby or just local terminal, they all support automatic completion/selection.

e.g. In Warp, no hints for cd

image

In other terminals, exist hints for cd(with same alias)

image

To Reproduce

  1. go to ~/.zshrc
  2. add
    function cdd(){
    cd $1;ls
    }
    alias cd='cdd'
  3. save and source ~/.zshrc or open new tab
  4. text cd with Tab key

Expected behaviour

expect automatic completion and selection

Screenshots

No response

Operating System

MacOS

OS Version

12.6

Shell Version

zsh 5.8.1 (x86_64-apple-darwin21.0)

Warp Version

v0.2022.10.18.08.10.stable_03

Additional context

No response

Does this block you from using Warp daily?

Yes

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

No response

dannyneira commented 1 year ago

Hi @isanmu, I'm Danny, a Support Engineer at Warp. Thanks for letting us know! We're sorry about this, this is not an ideal experience.

For cd completion/suggestions, you can toggle "Open Completions as you type" in WarpsSettings > Features

Then disable your alias/function just for Warp by putting it in this conditional statement:


if [[ $TERM_PROGRAM != "WarpTerminal" ]]; then
##### WHAT YOU WANT TO DISABLE FOR WARP - BELOW

function cdd(){
    cd $1;ls
}
alias cd='cdd'

##### WHAT YOU WANT TO DISABLE FOR WARP - ABOVE
fi

Or you can try with just the alias( no function) like this instead: alias cd='cd $1 ; ls'

If you still see an issue, you may have an incompatible tool you need to add to the conditional statement: https://docs.warp.dev/help/known-issues#list-of-incompatible-tools Also, see more info on custom prompts here: https://docs.warp.dev/features/prompt

Please let me know if this helps with your issue.

isanmu commented 1 year ago

https://docs.warp.dev/features/prompt

@dannyneira Thanks for your reply and suggestions.

  1. I already toggle "Open Completions as you type". And it work fine in Warp

  2. I could get completions/suggestions if type cd in Warp before alias.

    image
  3. After add function and alias, I lost the completions in Warp, but normal in other Terminals

  4. I actually expect alias(plus functions) work well in Warp, not disable it in Warp.

  5. I have tried alias cd="cd $1 ; ls" before, but it seems only ls worked, while cd not(like picture bellow, i cd to folder Applications, but it work as command ls ./Applications, and still keep in ~ folder. ). That's why i turn to use function instead.

    image
  6. Anyway, It would be great to support auto completions/suggestions for alias(plus with functions) in Warp in the future.

dannyneira commented 1 year ago

Thanks for your feedback, i'll change this one to a Feature Request to support alias functions in Warp.

isanmu commented 1 year ago

After update, warp support alias cd="cd $1 ; ls" now, and work fine!

dannyneira commented 1 year ago

@isanmu Nice! what about the other functions you mentioned above? Are we Okay to close this request?

function cdd(){
    cd $1;ls
}
alias cd='cdd'
isanmu commented 1 year ago

@isanmu Nice! what about the other functions you mentioned above? Are we Okay to close this request?

function cdd(){
    cd $1;ls
}
alias cd='cdd'

Sorry, it's my mistake. 😵‍💫 alias cd="cd $1 ; ls" still worked as ls and lost function ofcd... And for function way, warp still lost auto completions. Sorry for mistakenly thinking it worked after update.

isanmu commented 1 year ago

@isanmu Nice! what about the other functions you mentioned above? Are we Okay to close this request?

function cdd(){
    cd $1;ls
}
alias cd='cdd'

This feature is supported now(test in latest version) and this request could be closed. Thanks for support of this feature! 😄 @dannyneira