You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

18 lines
532 B

Adds compatibility with fish shell. Implementation notes: * `mcfly.fish` is based on the bash/zsh implementations, with the key bindings function inspired by fzf. * Key bindings are added by running `mcfly_key_bindings` after sourcing the file, rather than automatically, in case the user doesn't like the default ones. * The shebang is `/usr/bin/env fish` because I believe fish shell path is less likely to be consistent than bash/zsh. * To simplify, usage with fish doesn't need a `MCFLY_HISTORY` file, because we can get the last command easily during a fish postexec function. It's pointed at /dev/null, and temporary file cleanup is skipped. * A new `HistoryFormat` enum, defaulting to `Bash`, lets us specify history format so we can import/load. * A new `HistoryCommand` struct is used to represent each command in the history file, since it's no longer necessarily one line per entry. * The format of `search -o` files was extended to allow sending more commands back to the shell, in particular a 'delete' command for fish, which needs to handle history deletion itself rather than through file edits. Possible future improvements: * There's talk of changing fish's history format in fish 3.2. This could be handled with a new `FishJson` variant of `HistoryFormat` (named as appropriate, based on the format fish selects) and a `MCFLY_HISTORY_FORMAT` environment variable that the user can set to select it. * Use zsh extended timestamp as the `when` in `HistoryCommand`, if available. * Inspect zsh history file to see if extended timestamps are used, rather than requiring an argument, so that when the file is rewritten (when erasing lines) it doesn't lose extended timestamps. (Note: upon exit, zsh rewrites the file again, restoring extended timestamps, so it's not the end of the world.) * Handle bash's HISTTIMEFORMAT the way we handle zsh extended history. Testing done: * Tested add/search, importing history, and deleting history with bash 5.0.17, zsh 5.8, fish 2.7.1, and fish 3.1.2.
2 years ago
#!/bin/bash
# Build mcfly and run a dev environment fish for local mcfly testing
this_dir=$(cd `dirname "$0"`; pwd)
# Setup for local testing.
mkdir -p $this_dir/.fish
rm -f target/debug/mcfly
cargo build
# For some reason, to get line numbers in backtraces, we have to run the binary directly.
XDG_DATA_HOME=$this_dir/.fish \
MCFLY_PATH=target/debug/mcfly \
Adds compatibility with fish shell. Implementation notes: * `mcfly.fish` is based on the bash/zsh implementations, with the key bindings function inspired by fzf. * Key bindings are added by running `mcfly_key_bindings` after sourcing the file, rather than automatically, in case the user doesn't like the default ones. * The shebang is `/usr/bin/env fish` because I believe fish shell path is less likely to be consistent than bash/zsh. * To simplify, usage with fish doesn't need a `MCFLY_HISTORY` file, because we can get the last command easily during a fish postexec function. It's pointed at /dev/null, and temporary file cleanup is skipped. * A new `HistoryFormat` enum, defaulting to `Bash`, lets us specify history format so we can import/load. * A new `HistoryCommand` struct is used to represent each command in the history file, since it's no longer necessarily one line per entry. * The format of `search -o` files was extended to allow sending more commands back to the shell, in particular a 'delete' command for fish, which needs to handle history deletion itself rather than through file edits. Possible future improvements: * There's talk of changing fish's history format in fish 3.2. This could be handled with a new `FishJson` variant of `HistoryFormat` (named as appropriate, based on the format fish selects) and a `MCFLY_HISTORY_FORMAT` environment variable that the user can set to select it. * Use zsh extended timestamp as the `when` in `HistoryCommand`, if available. * Inspect zsh history file to see if extended timestamps are used, rather than requiring an argument, so that when the file is rewritten (when erasing lines) it doesn't lose extended timestamps. (Note: upon exit, zsh rewrites the file again, restoring extended timestamps, so it's not the end of the world.) * Handle bash's HISTTIMEFORMAT the way we handle zsh extended history. Testing done: * Tested add/search, importing history, and deleting history with bash 5.0.17, zsh 5.8, fish 2.7.1, and fish 3.1.2.
2 years ago
RUST_BACKTRACE=full \
MCFLY_DEBUG=1 \
PATH=target/debug/:$PATH \
Adds compatibility with fish shell. Implementation notes: * `mcfly.fish` is based on the bash/zsh implementations, with the key bindings function inspired by fzf. * Key bindings are added by running `mcfly_key_bindings` after sourcing the file, rather than automatically, in case the user doesn't like the default ones. * The shebang is `/usr/bin/env fish` because I believe fish shell path is less likely to be consistent than bash/zsh. * To simplify, usage with fish doesn't need a `MCFLY_HISTORY` file, because we can get the last command easily during a fish postexec function. It's pointed at /dev/null, and temporary file cleanup is skipped. * A new `HistoryFormat` enum, defaulting to `Bash`, lets us specify history format so we can import/load. * A new `HistoryCommand` struct is used to represent each command in the history file, since it's no longer necessarily one line per entry. * The format of `search -o` files was extended to allow sending more commands back to the shell, in particular a 'delete' command for fish, which needs to handle history deletion itself rather than through file edits. Possible future improvements: * There's talk of changing fish's history format in fish 3.2. This could be handled with a new `FishJson` variant of `HistoryFormat` (named as appropriate, based on the format fish selects) and a `MCFLY_HISTORY_FORMAT` environment variable that the user can set to select it. * Use zsh extended timestamp as the `when` in `HistoryCommand`, if available. * Inspect zsh history file to see if extended timestamps are used, rather than requiring an argument, so that when the file is rewritten (when erasing lines) it doesn't lose extended timestamps. (Note: upon exit, zsh rewrites the file again, restoring extended timestamps, so it's not the end of the world.) * Handle bash's HISTTIMEFORMAT the way we handle zsh extended history. Testing done: * Tested add/search, importing history, and deleting history with bash 5.0.17, zsh 5.8, fish 2.7.1, and fish 3.1.2.
2 years ago
exec /usr/bin/env fish -i --init-command "source $this_dir/mcfly.fish; and mcfly_key_bindings"