mirror of
https://github.com/89luca89/distrobox.git
synced 2026-08-19 01:14:49 -05:00
docs: add tutorial for fish in execute_commands_on_host.md (#257)
This commit is contained in:
@@ -65,6 +65,8 @@ user@fedora-distrobox:~$ host-exec bash -l
|
||||
Another cool trick we can pull, is to use the handy `command_not_found_handle` function
|
||||
to try and execute missing commands in the container on the host.
|
||||
|
||||
### bash / zsh
|
||||
|
||||
Place this in your `~/.profile`:
|
||||
|
||||
```shell
|
||||
@@ -91,6 +93,27 @@ if [ -n "${ZSH_VERSION-}" ]; then
|
||||
fi
|
||||
```
|
||||
|
||||
### fish
|
||||
|
||||
Place this snippet in a new fish function file (`~/.config/fish/functions/fish_command_not_found.fish`):
|
||||
|
||||
```fish
|
||||
function fish_command_not_found
|
||||
# "In a container" check
|
||||
if test -e /run/.containerenv -o -e /.dockerenv
|
||||
if command -q flatpak-spawn
|
||||
flatpak-spawn --host $argv
|
||||
else if command -q host-exec
|
||||
host-exec "$argv"
|
||||
else
|
||||
__fish_default_command_not_found_handler $argv
|
||||
end
|
||||
else
|
||||
__fish_default_command_not_found_handler $argv
|
||||
end
|
||||
end
|
||||
```
|
||||
|
||||
And restart your terminal. Now when a command does not exist on your container,
|
||||
it will be automatically executed back on the host:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user