Skip to content

Add fish shell hooks#7

Open
micromaomao wants to merge 6 commits intolandlock-lsm:mainfrom
micromaomao:fish-hook
Open

Add fish shell hooks#7
micromaomao wants to merge 6 commits intolandlock-lsm:mainfrom
micromaomao:fish-hook

Conversation

@micromaomao
Copy link
Copy Markdown

With this I think the experience is fairly similar to the zsh case, with similar limitations, e.g. no command substitution, but also no automatic alias expansion yet due to alias actually being functions, rather than something we can just query.

There is also a caveat regarding pipelines (see third commit), and I'm not sure how best to handle it.

Demo:

(0.001s) linux-devbox-2 (mao) ~ at 23:58:24
> exa / # outside sandbox
bin   boot.2  etc   lib    mnt  proc  run   snapshots  sys  usr
boot  dev     home  lib64  opt  root  sbin  srv        tmp  var
(0.003s) linux-devbox-2 (mao) ~ at 23:58:26
> cd island/
(0.002s) linux-devbox-2 (mao; fish-hook) ~/island I[island] at 23:58:27
> exa / # inside sandbox
Permission denied: / - code: 13

Skipped 1 directories due to permission denied: 
  /
(0.003s) linux-devbox-2 (mao; fish-hook) ~/island I[island] at 23:58:31
> ls / # ls is a built-in function wrapping ls in fish, so not sandboxed
bin@  boot/  boot.2/  dev/  etc/  home/  lib@  lib64@  mnt/  opt/  proc/  root/  run/  sbin@  snapshots/  srv/  sys/  tmp/  usr/  var/
(0.001s) linux-devbox-2 (mao; fish-hook) ~/island I[island] at 23:59:34
> grep -R 'BEGIN OPENSSH PRIVATE KEY' ~/.ssh # similarly, grep is a built in alias, so not sandboxed
/home/mao/.ssh/id_ed25519:-----BEGIN OPENSSH PRIVATE KEY-----

Automatic insertion of island run for absolute path:

# I typed "/bin/grep -R ...", then enter
> island run -- /bin/grep -R 'BEGIN OPENSSH PRIVATE KEY' ~/.ssh
/bin/grep: /home/mao/.ssh: Permission denied

abbr expansion (I typed gp, then pressed enter twice (required to press enter twice due to limitation))

> git push -v
Pushing to https://github.com/micromaomao/island.git
fatal: cannot exec '/home/mao/.vscode-server/cli/servers/Stable-618725e67565b290ba4da6fe2d29f8fa1d4e3622/server/extensions/git/dist/askpass.sh': Permission denied
fatal: could not read Username for 'https://github.com': Permission denied

Closes: #6

Signed-off-by: Tingmao Wang <m@maowtm.org>
Signed-off-by: Tingmao Wang <m@maowtm.org>
Signed-off-by: Tingmao Wang <m@maowtm.org>
- Move TAP functions to a separate `tap.fish` file
- Add `test_operators` to test `&&` and `||` parsing
- Update name of mock profiles to be more conventional
- Change some test messages
- Handle multiline buffers correctly in commandline mock

Signed-off-by: Tingmao Wang <m@maowtm.org>
Signed-off-by: Tingmao Wang <m@maowtm.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fish shell hooks support

1 participant