holzschu / a-shell

A terminal for iOS, with multiple windows
BSD 3-Clause "New" or "Revised" License
2.71k stars 117 forks source link

Running dash as main shell #548

Open rcarmo opened 1 year ago

rcarmo commented 1 year ago

I’ve been trying to get some shell scripts (like https://github.com/agkozak/zsh-z and variants) working, but that would mean running dash as the primary shell. This would be a catch-22 situation because by doing that I lose access to the built-ins like showmarks, etc., so I’m curious as to whether this actually makes sense to try…

holzschu commented 1 year ago

That is a good question. Users have also suggested using zsh-autosuggestions: https://github.com/zsh-users/zsh-autosuggestions (the two are similar). It looks like these things should be easy(-ish) to plug into the current autocomplete behaviour: the JavaScript component sends the autocomplete prefix to the Swift component, which computes the possible expansions and sends them back. So the work to do is:

holzschu commented 1 year ago

Hum. There was another thing I should have noticed: you said that you don't have access to showmarks from inside dash. That shouldn't happen (but it did). That will be fixed in the next version.

rcarmo commented 1 year ago

I looked for the showmarks command (and others) but couldn't find them... thanks!

holzschu commented 1 year ago

Some commands look for an executable before they run a command, to be sure that the command exists (dash is one of them, Python and Vim too). For these, I created fake commands for all internal commands in $APPDIR/bin. These fake commands are just empty files, but that is enough for the part that looks for an executable. Somehow, I had forgotten to do that for showmarks and a few others.

holzschu commented 1 year ago

The latest TestFlight version implements a partial version of zsh-z: autocomplete after the "cd" command will show the most frequently used directories first (and the most frequently used bookmarks first if you start with "~").

rcarmo commented 1 year ago

Awesome, going to check it out.

rcarmo commented 1 year ago

Works great. But the real power of "z" is jumping to a partial match anywhere on the path, like "z drafts" going to /foo/var/drafts.

holzschu commented 1 year ago

That should be feasible, now that I have the list of directories and their frequency. Looking at the video, they use some weird matching. I don't understand how gk is matching to aghozak.github.io (or I don't understand how to do it).

holzschu commented 1 year ago

Hi, the TestFlight version of a-Shell mini has both a z command (which works by fuzzy matching and frequency, so z D/ss changes into ~/Documents/.ssh in my case), and a z + autocomplete behaviour, where z + arguments + tab shows the directories that match the argument.

It's not the same as zsh-z, but it works nicely.