Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support shell-based subshells in Warp #64

Closed
thegedge opened this issue Jul 24, 2021 · 69 comments
Closed

Support shell-based subshells in Warp #64

thegedge opened this issue Jul 24, 2021 · 69 comments
Labels
Feature requests Feature Requests

Comments

@thegedge
Copy link

thegedge commented Jul 24, 2021

We're tracking non-shell based REPLs (likeirb, ipython, psql, etc. ) on another GitHub issue > #4082

** List of shell-based subshells Warp supports **

  • bash, zsh, fish, gcloud compute ssh, eb ssh, poetry shell, sudo su, etc.
@thegedge thegedge added the bug label Jul 24, 2021
@zachlloyd
Copy link
Contributor

Yeah i think the right UI for this is to continue doing blocks but with some indication that you are in a subshell, similar to how we handle ssh. This should be doable. Please upvote if you want it.

@elviskahoro elviskahoro changed the title Warp thinks exec ... is a long running command Core: Support subshells in Warp Nov 7, 2021
@elviskahoro elviskahoro changed the title Core: Support subshells in Warp Support subshells in Warp Dec 7, 2021
@elviskahoro elviskahoro added the DX label Dec 7, 2021
@elviskahoro
Copy link
Contributor

Differentiating User Shells And Subshells

From @shankarshastri via #220

Describe the solution you'd like?

It would be great based on the context, to show to users that currently in shell or subshell mode (For example docker shell container id for docker exec, and in case of ssh to ssh and hostname)

Is your feature request related to a problem? Please describe.

It's always a challenge to know whether we are in actual shell or any subshells.

Additional context

No response

@elviskahoro
Copy link
Contributor

Poetry (python) creates a subshell. Would be nice if this was supported as well.

@Liu-Da
Copy link

Liu-Da commented Apr 11, 2022

Are there any plans or roadmaps for supporting the sub-shell feature?

@sweetyclem
Copy link

Hi, in a ruby on rails console I have the same issue. Thanks for looking into it!

@elviskahoro
Copy link
Contributor

elviskahoro commented Apr 15, 2022

From #949

Describe the bug

On the MBP v12.2.1 native terminal, when I open up `psql`,I can navigate via Option + Left/Right arrow and modify my queries, but this behavior isn't compatible in Warp. Instead, I just get a space in the shell.

To Reproduce

Steps to reproduce:

  1. Open psql
  2. Type out a query like select * from users
  3. Try to navigate via Option + Left Arrow to replace * with specific columns.
  4. See that the cursor is moved to the right for some reason 🤷.

Expected behaviour

I would expect to be moved to the next "word" in the direction of the arrow key I choose while holding Option.

Screenshots

No response

Operating System

MacOS

OS Version

12.2.1

Additional context

No response

@jwickers
Copy link

Having Warp work with DB subshells would be huge. Those are the places where we often have to type and edit very long commands and basically where Warp would bring a lot of value.

@junyicc
Copy link

junyicc commented Jun 13, 2022

Encountered the same issue in subshells:

  • mongo shell
  • mycli command line
  • ...

Currently, we can do the same things by

  • Esc + B to move cursor to the beginning of the current word
  • Esc + F to move cursor to the end of the current word
  • Ctrl + W to delete whole word

But, it's not convenient and friendly. Looking forward to the shortcuts support in subshells by OPTION/CMD + ARROW LEFT/RIGHT or BACKSPACE

@joeyparis
Copy link

Just to add to the list of programs that would benefit from this, AWS's Elastic Beanstalk CLI. Specifically the eb ssh command

@evelant
Copy link

evelant commented May 8, 2023

Aw man, this is disappointing. I just discovered Warp, got excited, and now find out that it doesn't support nushell. The rusty terminal should work with the rusty shell! As cool as Warp is I can't give up nushell so it's back to iterm for now.

@miohtama
Copy link

Good work guys! Warp is the best thing happened to UNIX command line since zsh.

Another command not yet mentioned is sudo.

I am working on a server and often I need to use sudo -i -u to switch users. When sudo spawns a new shell, the Warp block mode is lost.

@llam15
Copy link

llam15 commented May 19, 2023

The new subshell capability is hands down the best feature! A few things I have noticed:

  • When I'm in a subshell of my subshell, such as running python manage.py inside of a docker exec, the ^D shortcut for exit does not seem to register. I can only exit the sub-sub-shell by typing exit() explicitly.
  • If I try to warpify the following command: docker compose exec my-container python manage.py shell_plus , I get IndentationError: unexpected indent
[ -z $WARP_BOOTSTRAPPED ] && echo $0 | grep -q zsh && unsetopt ZLE && eval 'unsetopt ZLE;WARP_SESSION_ID="$(date +%s)$RANDOM";_hostname=$(command -v hostname >/dev/null 2>&1 && command hostname 2>/dev/null
 || uname -n);_user=$(command -v whoami >/dev/null 2>&1 && command whoami 2>/dev/null || echo $USER);_msg=$(printf "{\"hook\": \"InitShell\", \"value\": {\"session_id\": $WARP_SESSION_ID, \"shell\": \"zsh\", \"
user\": \"$_user\", \"hostname\": \"$_hostname\", \"is_subshell\": true}}" | od -An -v -tx1 | command tr -d " \n");printf '"'"'\x1b\x50\x24\x64%s\x9c'"'"' $_msg;unset _hostname _user _msg;' || [ -z $WARP_BOOTST
RAPPED ] && echo $0 | grep -q bash && eval 'stty raw;unset PROMPT_COMMAND;HISTCONTROL=ignorespace;HISTIGNORE=" *";WARP_SESSION_ID="$(date +%s)$RANDOM";_hostname=$(command -v hostname >/dev/null 2>&1 && command
hostname 2>/dev/null || uname -n);_user=$(command -v whoami >/dev/null 2>&1 && command whoami 2>/dev/null || echo $USER);_msg=$(printf "{\"hook\": \"InitShell\", \"value\": {\"session_id\": $WARP_SESSION_ID, \"
shell\": \"bash\", \"user\": \"$_user\", \"hostname\": \"$_hostname\", \"is_subshell\": true}}" | od -An -v -tx1 | command tr -d " \n");printf '"'"'\x1b\x50\x24\x64%s\x9c'"'"' $_msg;unset _hostname _user _msg;'
 || [ -z $WARP_BOOTSTRAPPED ] && [ $FISH_VERSION ] && eval 'set -g WARP_SESSION_ID (random);set _hostname $(command -v hostname >/dev/null 2>&1 && command hostname 2>/dev/null || uname -n);set _user $(command -
v whoami >/dev/null 2>&1 && command whoami 2>/dev/null || echo $USER);set _msg $(echo -n "{\"hook\": \"InitShell\", \"value\": {\"session_id\": $WARP_SESSION_ID, \"user\": \"$_user\", \"hostname\": \"$_hostname
\", \"shell\": \"fish\", \"is_subshell\": true}}" | od -An -v -tx1 | command tr -d " \n");echo -n \u1b\u50\u24"d$_msg"\u9c;set -e _hostname _user _msg;'
  File "<bpython-input-3>", line 1
    [ -z $WARP_BOOTSTRAPPED ] && echo $0 | grep -q zsh && unsetopt ZLE && eval 'unsetopt ZLE;WARP_SESSION_ID="$(date +%s)$RANDOM";_hostname=$(command -v hostname >/dev/null 2>&1 && command hostname 2>/dev/null
|| uname -n);_user=$(command -v whoami >/dev/null 2>&1 && command whoami 2>/dev/null || echo $USER);_msg=$(printf "{\"hook\": \"InitShell\", \"value\": {\"session_id\": $WARP_SESSION_ID, \"shell\": \"zsh\", \"u
ser\": \"$_user\", \"hostname\": \"$_hostname\", \"is_subshell\": true}}" | od -An -v -tx1 | command tr -d " \n");printf '"'"'\x1b\x50\x24\x64%s\x9c'"'"' $_msg;unset _hostname _user _msg;' || [ -z $WARP_BOOTSTR
APPED ] && echo $0 | grep -q bash && eval 'stty raw;unset PROMPT_COMMAND;HISTCONTROL=ignorespace;HISTIGNORE=" *";WARP_SESSION_ID="$(date +%s)$RANDOM";_hostname=$(command -v hostname >/dev/null 2>&1 && command h
ostname 2>/dev/null || uname -n);_user=$(command -v whoami >/dev/null 2>&1 && command whoami 2>/dev/null || echo $USER);_msg=$(printf "{\"hook\": \"InitShell\", \"value\": {\"session_id\": $WARP_SESSION_ID, \"s
hell\": \"bash\", \"user\": \"$_user\", \"hostname\": \"$_hostname\", \"is_subshell\": true}}" | od -An -v -tx1 | command tr -d " \n");printf '"'"'\x1b\x50\x24\x64%s\x9c'"'"' $_msg;unset _hostname _user _msg;'
|| [ -z $WARP_BOOTSTRAPPED ] && [ $FISH_VERSION ] && eval 'set -g WARP_SESSION_ID (random);set _hostname $(command -v hostname >/dev/null 2>&1 && command hostname 2>/dev/null || uname -n);set _user $(command -v
 whoami >/dev/null 2>&1 && command whoami 2>/dev/null || echo $USER);set _msg $(echo -n "{\"hook\": \"InitShell\", \"value\": {\"session_id\": $WARP_SESSION_ID, \"user\": \"$_user\", \"hostname\": \"$_hostname\
", \"shell\": \"fish\", \"is_subshell\": true}}" | od -An -v -tx1 | command tr -d " \n");echo -n \u1b\u50\u24"d$_msg"\u9c;set -e _hostname _user _msg;'
    ^
IndentationError: unexpected indent
>>>

Happy to open separate issues if that's preferred! None of these are blocking, of course.

@zachbai
Copy link

zachbai commented May 19, 2023

Hi all, some exciting news:

Support for "Warpifying" bash, zsh, and fish subshells is launched in the latest release (v0.2023.05.18.01.08.stable_04)!

In Warpified subshell sessions, Warp's features like blocks, input editor, completions, etc work the same way they do in 'top-level' shell sessions.

By default, Warp recognizes the following commands and displays a banner prompting you for Warpification:

For the sake of clarity - Warpifying non-shell REPLs like python , irb, psql etc is not yet supported -- this is on the long term roadmap but includes a whole new set of challenges and likely won't be built for a while. That being said, I'm hearing from this thread that the big pain point is keyboard navigation, and I think we can improve this in the near term, short of full-on Warpification/block integration.

@zachbai
Copy link

zachbai commented May 19, 2023

@llam15 Thanks for the feedback!

When I'm in a subshell of my subshell, such as running python manage.py inside of a docker exec, the ^D shortcut for exit does not seem to register. I can only exit the sub-sub-shell by typing exit() explicitly.

Mind filing a separate GH issue for this? We should be able to prioritize a fix for this shortly.

Additionally, just to be clear, is python manage.py shell_plus dropping you into a Python REPL? If so -- I think your second bullet point is to be expected. At this point, only bash, fish, and zsh shells are eligible for Warpification.

@Slawikus
Copy link

Support for "Warpifying" bash, zsh, and fish subshells is launched in the latest release (v0.2023.05.18.01.08.stable_04)!

By default, Warp recognizes the following commands and displays a banner prompting you for Warpification:

  • poetry shell

Wow, that's great news!!! Will it work with pipenv shell similar to poetry?

@dannyneira
Copy link
Member

dannyneira commented May 19, 2023

@Slawikus Initiatingpipenv shell is supported from bash/fish, but not zsh at this time although we should have a fix for this in next week's release!

We'll update our docs and this thread if/when any others are added to the supported list. https://docs.warp.dev/features/subshells#how-to-warpify-the-subshell

@Evian-Zhang
Copy link

It seems like subshells spawned by sudo su does not be warpified in the latest v0.2023.05.18.01.08.stable_04 release. Switching to root user is frequently used for network engineers where most commands need administrator privilege, and currently using Warp with sudo su is just like a normal terminal which does not do anything magical.

@zachbai
Copy link

zachbai commented May 20, 2023

@Evian-Zhang thanks for the feedback --

For commands that are not automatically recognized for Warpification (including sudo su), you can follow the directions in our docs here to manually mark it as a 'Warpifiable' command.

image

On subsequent executions, the Warpify banner will be shown and you'll be able to Warpify the session.

Feel free to follow up on the thread if you encounter any issues!

@sebdanielsson
Copy link

I'm getting the following error when clicking on Warpify after adding sudo su to the commands:

sh-3.2#  [ -z $WARP_BOOTSTRAPPED ] && echo $0 | grep -q zsh && unsetopt ZLE && eval 'unsetopt ZLE;WARP_SESSION_ID="$(date +%s)$RANDOM";_hostname=$(command -v hostname >/dev/null 2>&1 && command hostname 2>/dev/null || uname -n);_user=$(command -v whoami >/dev/null 2>&1 && command whoami 2>/dev/null || echo $USER);_msg=$(printf "{\"hook\": \"InitShell\", \"value\": {\"session_id\": $WARP_SESSION_ID, \"shell\": \"zsh\", \"user\": \"$_user\", \"hostname\": \"$_hostname\", \"is_subshell\": true}}" | od -An -v -tx1 | command tr -d " \n");printf '"'"'\x1b\x50\x24\x64%s\x9c'"'"' $_msg;unset _hostname _user _msg;' || [ -z $WARP_BOOTSTRAPPED ] && echo $0 | grep -q bash && eval 'stty raw;unset PROMPT_COMMAND;HISTCONTROL=ignorespace;HISTIGNORE=" *";WARP_SESSION_ID="$(date +%s)$RANDOM";_hostname=$(command -v hostname >/dev/null 2>&1 && command hostname 2>/dev/null || uname -n);_user=$(command -v whoami >/dev/null 2>&1 && command whoami 2>/dev/null || echo $USER);_msg=$(printf "{\"hook\": \"InitShell\", \"value\": {\"session_id\": $WARP_SESSION_ID, \"shell\": \"bash\", \"user\": \"$_user\", \"hostname\": \"$_hostname\", \"is_subshell\": true}}" | od -An -v -tx1 | command tr -d " \n");printf '"'"'\x1b\x50\x24\x64%s\x9c'"'"' $_msg;unset _hostname _user _msg;' || [ -z $WARP_BOOTSTRAPPED ] && [ $FISH_VERSION ] && eval 'set -g WARP_SESSION_ID (random);set _hostname $(command -v hostname >/dev/null 2>&1 && command hostname 2>/dev/null || uname -n);set _user $(command -v whoami >/dev/null 2>&1 && command whoami 2>/dev/null || echo $USER);set _msg $(echo -n "{\"hook\": \"InitShell\", \"value\": {\"session_id\": $WARP_SESSION_ID, \"user\": \"$_user\", \"hostname\": \"$_hostname\", \"shell\": \"fish\", \"is_subshell\": true}}" | od -An -v -tx1 | command tr -d " \n");echo -n \u1b\u50\u24"d$_msg"\u9c;set -e _hostname _user _msg;'

@zachbai
Copy link

zachbai commented May 24, 2023

Hey @sebdanielsson,

It looks like this is because the login shell for the root user in your machine is /bin/sh, which isn't one of Warp's supported shells. Switching that login shell for root via sudo chsh -s $(which <fish|bash|zsh>) should change the root login shell to whichever shell you specify (fish/bash/zsh), all of which are supported by Warp. Let us know if this doesn't work for you.

That being said, we can probably do a better job of messaging that only bash/fish/zsh are supported. Or possibly look at ways to detect an unsupported shell while Warpifying and then notify you if so.

@shumkov
Copy link

shumkov commented May 27, 2023

Thank you for this fantastic feature! Looking forward to an option in settings to automatically warpify all supported (whitelisted) shells. Updating RC files is fine for local shells but when you work with docker or ssh subshells a lot it's not very feasible.

@zachbai
Copy link

zachbai commented May 30, 2023

Hey @shumkov,

Makes sense that the RC file update isn't always practical with docker containers/remote hosts.

Automatic Warpification without an RC file is tough because, under the hood, Warpification is done by executing an initialization command that performs all the necessary setup for blocks, input editor, completions etc to work.

Basically, without the RC file update, Warp would have to know if and when it's ok to Warpify purely based on the executed subshell command. This is hard to do in a reliable way because the executed command doesn't always encode the shell (bash vs fish vs tcsh vs nushell) that is being spawned, and some of these shells are unsupported -- so it would put the subshell in a bad state if we just automatically tried to Warpify by executing the initialization command (which might contain invalid syntax or make assumptions that don't hold true in unsupported shells).

There might be some non-RC file-based workaround here, but it would still likely involve installation of some small binary or creation of some config file on the remote hosts where the subshells are being spawned, both of which I'm thinking are as intrusive (or more intrusive) than updating an RC file. I could be wrong here, though! Also open to other suggestions, since it's obvious that automatic Warpification for all subshells would be the most ideal UX.

@evelant
Copy link

evelant commented May 30, 2023

Now that feature has landed is it more feasible to add first class support for nushell? Is that on the roadmap? Warp looks awesome but I can't leave nushell for an old style shell, it's just too good. Nushell combined with Warp would be the most amazing experience!

@zachbai
Copy link

zachbai commented May 30, 2023

@evelant We're aware of the demand for nushell -- feel free to upvote #880! For the sake of transparency, it's not yet on the near-term roadmap (next 3 months or so), but agree it would be awesome to support and we're always re-evaluating what to build every quarter.

@shumkov
Copy link

shumkov commented May 30, 2023

@zachbai thank you for the comprehensive explanation. I understand the complications and I hope you guys will find a solution!

@dannyneira dannyneira changed the title Support subshells in Warp Support non-shell based subshells in Warp May 31, 2023
@Evian-Zhang
Copy link

It is interesting that, I can't directly ssh into a FreeBSD machine with warpified shell (I use /usr/bin/ssh to work around), however, after I get into the FreeBSD, I invoke such Warpification command, and I can use Warp features in FreeBSD!

I just feel confused that what is the different between a subshell and a shell spawned by ssh. Why don't use the same technologies to enable Warp features across ssh-target and subshells spawned by other common commands?

@llam15
Copy link

llam15 commented Jun 8, 2023

@zachbai

@llam15 Thanks for the feedback!

When I'm in a subshell of my subshell, such as running python manage.py inside of a docker exec, the ^D shortcut for exit does not seem to register. I can only exit the sub-sub-shell by typing exit() explicitly.

Mind filing a separate GH issue for this? We should be able to prioritize a fix for this shortly.

Sorry for the late reply, I did not get a notification for your reply 😓

Additionally, just to be clear, is python manage.py shell_plus dropping you into a Python REPL? If so -- I think your second bullet point is to be expected. At this point, only bash, fish, and zsh shells are eligible for Warpification.

Yes you're correct, python manage.py shell_plus is a Python REPL. Thanks for the explanation! Hope Python REPLs be supported soon :)

@dannyneira dannyneira unpinned this issue Jun 15, 2023
@dannyneira
Copy link
Member

Locking this issue to help with notifications. We are aware of the demand for non-shell based subshells (REPLs). Any further updates will be posted on this thread by the Warp team.

@warpdotdev warpdotdev locked and limited conversation to collaborators Jun 27, 2023
@elviskahoro elviskahoro changed the title Support non-shell based subshells in Warp Support non-shell (REPLs) based subshells in Warp Sep 1, 2023
@dannyneira
Copy link
Member

dannyneira commented Jan 17, 2024

Hey folks, since this issue was originally for sh based subshell, we're closing as resolved.

We'll be tracking the REPLs non-shell based subshell in a new meta issue which will also contain comments for tracking each REPL (irb, ipython, pipenv, psql, node, mongosh, rails, nix-shell, etc.) here #4082

Closing as completed since Subshell support has been
released.

@dannyneira dannyneira changed the title Support non-shell (REPLs) based subshells in Warp Support shell-based subshells in Warp Jan 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Feature requests Feature Requests
Projects
None yet
Development

No branches or pull requests