| Commit message (Collapse) | Author |
|
|
|
That helps remove duplicated code and rustc/cargo will now also show
dead code correctly.
|
|
|
|
This PR fixes a shell hang when daemon autostart happens from the
interactive search widget.
The bash/zsh/fish integrations run `atuin search -i` under command
substitution and swap stdout/stderr so the TUI can draw to the terminal
while the selected command is captured:
```sh
3>&1 1>&2 2>&3
```
This leaves fd 3 open in the atuin search process. If search autostarts
the daemon, the spawned long-running `atuin daemon start --daemonize`
inherits fd 3, the command-substitution pipe, so the shell keeps waiting
for EOF until the daemon is killed.
The fix: close fd 3 after the swap in the non-tmux bash/zsh/fish paths:
```sh
3>&1 1>&2 2>&3 3>&-
```
Tested on zsh; I still need to confirm for bash and fish. Near as I can
tell, the other shell integrations don't need this change.
Fixes #3499
|
|
The functionality to run a tmux popup has the problem that the command
runs as a child of the `tmux` *server* process, rather than the current
shell. One potential issue is that the `$PATH` is not forwarded to this
command, so the `atuin` command may not be found.
Fixes: https://github.com/atuinsh/atuin/issues/3182 (#3182)
<!-- Thank you for making a PR! Bug fixes are always welcome, but if
you're adding a new feature or changing an existing one, we'd really
appreciate if you open an issue, post on the forum, or drop in on
Discord -->
## Checks
- [x] I am happy for maintainers to push small adjustments to this PR,
to speed up the review cycle
- [x] I have checked that there are no existing pull requests for the
same thing
|
|
<!-- Thank you for making a PR! Bug fixes are always welcome, but if
you're adding a new feature or changing an existing one, we'd really
appreciate if you open an issue, post on the forum, or drop in on
Discord -->
## Checks
- [x] I am happy for maintainers to push small adjustments to this PR,
to speed up the review cycle
- [x] I have checked that there are no existing pull requests for the
same thing
Silent DB failures breaking shell when disk is full
When storage runs out (i.e. disk full), atuin breaks the shell by
continuously printing database errors for every character typed. This is
a fix to silence the DB errors
|
|
This PR fixes:
+ #3154
+ #3164
+ #3166
It changes the following:
+ Pass ATUIN_SESSION to tmux popup
+ Use `command rm` to bypass user-defined configs
+ Disable tmux popup by default
## Checks
- [x] I am happy for maintainers to push small adjustments to this PR,
to speed up the review cycle
- [x] I have checked that there are no existing pull requests for the
same thing
---------
Co-authored-by: Ellie Huxtable <ellie@elliehuxtable.com>
|
|
This is a "continuation" of #1177 - which was a draft that used FIFOs
(named pipes) to get output from the popup, however this causes popup
not being closed properly, so in this PR I use tmpfile to store the
result and read after popup closes. @ellie could you review this PR
please?
P.S. Thank you @immae for sharing your idea!
## Feature
+ Option to use tmux popup window in `config.toml`
+ Customize window width/height in `config.toml`
+ Tmux display-popup for `zsh, bash, fish`
## Checks
- [x] I am happy for maintainers to push small adjustments to this PR,
to speed up the review cycle
- [x] I have checked that there are no existing pull requests for the
same thing
---------
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
|
|
eg, the user uses tmux, runs zsh again as a nested session, etc
## Checks
- [ ] I am happy for maintainers to push small adjustments to this PR,
to speed up the review cycle
- [ ] I have checked that there are no existing pull requests for the
same thing
|
|
<!-- Thank you for making a PR! Bug fixes are always welcome, but if
you're adding a new feature or changing an existing one, we'd really
appreciate if you open an issue, post on the forum, or drop in on
Discord -->
## Checks
- [ ] I am happy for maintainers to push small adjustments to this PR,
to speed up the review cycle
- [ ] I have checked that there are no existing pull requests for the
same thing
|
|
This adds a workaround for an issue with a Bash-5.1 bug reported by
@MaxenceG2M at
https://github.com/atuinsh/atuin/issues/962#issuecomment-3451132291. See
the added code comments for details.
## Checks
- [x] I am happy for maintainers to push small adjustments to this PR,
to speed up the review cycle
- [x] I have checked that there are no existing pull requests for the
same thing
|
|
This patch tries to port a change for zsh-autosuggestion in #2780 to
suppress the error messages in typing the command. The same issue
happens with ble.sh, so we want to suppress the error message in the
same way as with zsh-autosuggestion.
## Checks
- [x] I am happy for maintainers to push small adjustments to this PR,
to speed up the review cycle
- [x] I have checked that there are no existing pull requests for the
same thing
|
|
(#2977)
In #2953, I chose `\e[0;<n>A` as special key sequences for
`enter_accept` in Bash, but I realized that the sequence `\e[0;<n>A`
doesn't actually work in the `vi-insert` keymap. I instead suggest using
the key sequences of the form `\C-x\C-_A0\a` (99ddcbf7), which is
unlikely to conflict with the users' keybindings. In addition, for Bash
<= 3.2, I also noticed that we cannot insert `$READLINE_LINE` in the
command line when we are in the `vi-command` keymap. I suggest switching
from `vi-command` to `vi-insert` temporarily (e6c4e9fd).
## Checks
- [x] I am happy for maintainers to push small adjustments to this PR,
to speed up the review cycle
- [x] I have checked that there are no existing pull requests for the
same thing
|
|
<!-- Thank you for making a PR! Bug fixes are always welcome, but if
you're adding a new feature or changing an existing one, we'd really
appreciate if you open an issue, post on the forum, or drop in on
Discord -->
This PR introduces a mechanism to use Readline's `accept-line` to run
the user command properly. The idea is described in [the code
comment](https://github.com/atuinsh/atuin/pull/2953/files#diff-57afeb258339de1b14a8dd3fdc88d1a0e192fd186706e570c44c3ef41f7a8c6dR362-R382)
in the added code. This naturally fixes #2935 because Readline's
`accept-line` also performs the necessary keymap transition.
This PR also fixes the behavior of <kbd>tab</kbd> and <kbd>enter</kbd>
with `enter_accept = false` `in Bash <= 3.2. In the previous
implementation, the selected command was lost in Bash 3.2, but this PR
correctly inserts the selected command into the command line buffer.
This PR adds a utility `atuin-bind` to make it easier to define custom
keybindings. The default bindings are also set up by the new function
`atuin-bind` now. This new function `atuin-bind` arranges all
non-trivial setups to make it possible to call Readline's `accept-line`.
The old mechanism using `__atuin_accept_line` is kept for existing users
who set up custom keybindings (without using the new function
`atuin-bind`).
## Checks
- [x] I am happy for maintainers to push small adjustments to this PR,
to speed up the review cycle
- [x] I have checked that there are no existing pull requests for the
same thing
|
|
|
|
The command chaining feature can be implemented without the prefix.
|
|
* feat: command chaining
Allow for smart completion of commands ending in && or ||
* fmt
|
|
|
|
|
|
|
|
I'd like to tidy up the root a little, and it's nice to have all the
rust crates in one place
|
|
* feat(doctor): check active preexec framework
To check if "blesh" or "bash-preexec" is loaded and active in the
current Bash session where `atuin doctor` is called, we make the Atuin
integration script for Bash to set the environment variable
`ATUIN_PREEXEC_BACKEND` and store a string when it detects "blesh" or
"bash-preexec".
To check whether the obtained ATUIN_PREEXEC_BACKEND is set by the
current session, we record SHLVL in ATUIN_PREEXEC_BACKEND and check if
it matches SHLVL of the current process.
* feat(doctor): detect the case where Atuin is initialized before blesh
|
|
Bash < 5.0 doesn't support the high-resolution clock EPOCHREALTIME, so
ble.sh uses the builtin command `time` to measure the execution times
in Bash < 5.0. This has a lower resolution of milliseconds but still
more accurate than Atuin's measurent because Atuin's measurement
includes the spawn cost of Atuin, which is typically larger than a
millisecond.
Reported-by: Georgios Vlassis <https://github.com/gvlassis>
Reference: https://github.com/atuinsh/atuin/pull/1484#issuecomment-2047068582
|
|
We have introduced initialization guards in #1533 [1], where `return
0` was used to cancel the initialization. However, this cancels the
processing of the caller (which is typically `~/.bashrc`) instead of
just canceling Atuin's initialization. In this patch, we avoid using
`return 0`. Instead, we enclose the main part of the initialization
in a big if-statement.
[1] https://github.com/atuinsh/atuin/pull/1533
|
|
* refactor(doctor): update func names and desc to match current impl
* fix(doctor): use environment variable to detect plugin if possible
In this patch, if the plugin provides an environment variable, we use
the environment variable to test the existence of the plugin. When an
environment variable is not available, we continue to use the mock
interactive session by "shell -ic command". We also test
shell-specific plugins only in the corresponding shells. An
additional test can be performed by a custom function for each plugin.
|
|
* fix: pass search query in via env
* fix
|
|
In GitHub #1509, we blocked the unintended preexec event caused by the
keybinding of Atuin. However, with that fix, the preexec event for
the intended user command is still missing. In this patch, we try to
manually run the preexec hook when we detected the unintended preexec
(which means the missing intended preexec).
References:
https://github.com/atuinsh/atuin/pull/1509
https://forum.atuin.sh/t/atuin-bash-and-ble-sh/175
https://github.com/atuinsh/atuin/issues/1003#issuecomment-1947905213
https://github.com/atuinsh/atuin/pull/1727
https://github.com/atuinsh/atuin/pull/1728
|
|
keybind…" (#1728)
This reverts commit 032ca19c73be45c39a2d7a9972cb7d47d34d31ce.
|
|
(#1…" (#1727)
This reverts commit 86f2c8e58806020bc04999a5039e18ff10409e59.
|
|
* fix(bash/preexec): support termcap-based tput
The current uses of tput specify the terminfo entry names. However,
there are different implementations of the tput command. There are
two ways to specify the terminal capability: terminfo and termcap
names. Although recent implementations of tput (such as ncurses in
Linux) accepts the terminfo name, some accept both the terminfo and
termcap names, and some old implementations (such as in FreeBSD) only
accept the termcap names.
In this patch, we first attempt the terminfo name and then the termcap
name if the terminfo name fails.
Note: When both fail due to e.g. non-existent tput, we end up with
outputting nothing. This does not cause a serious problem because it
just does not clear the previous prompts.
* perf(bash/preexec): cache the results of tput
With the current implementation, we spwan 10 processes of the tput
command at most every time we perform `enter_accept`. In this patch,
to reduce the delay, we separate the related code into a function and
cache the results of the tput commands.
|
|
When the previous prompt is longer than the prompt calculated by the
current PS1, some extra characters from the previous prompt remains in
the terminal display. In this patch, we erase the content of the
previous prompt before outputting our new prompt.
|
|
Fixes https://github.com/atuinsh/atuin/issues/1668
When the prompt becomes longer after "enter_accept", Bash still uses
the previous shorter prompt, so the extra characters in the new prompt
drawn by Atuin is left in the terminal display. In this patch, we
remove the last line of the prompt drawn by Atuin so that it doesn't
interfere with the last line of the prompt drawn by Bash.
|
|
A search feature in the vi-normal mode of shells can be called by "/".
To make the shell-integration keybindings consistent with the existing
shell keybindings, we add the keybinding to "/" in this patch.
This patch removes the Ctrl-r binding in the "vicmd" keymap in Zsh.
The key Ctrl-r is used for the `redo` operation in the vi-normal mode
by default. We would like to avoid overwriting an existing keybinding
with a totally different feature.
|
|
(#1620)
* fix(bash): strip control chars generated by \[\] in PS1 with bash-preexec
Fixes https://github.com/atuinsh/atuin/issues/1617
* perf(bash): count newlines using Bash built-in features
|
|
* feat(search): introduce keymap-dependent vim-mode
* fix(zsh): provide widgets with specific keymaps
* fix(settings): unify "vim" and "keymap_mode"
|
|
* fix(bash): add a guard for interactive shells
* fix(bash): add a guard for the Bash version
* fix(bash): localize READLINE_LINE in bash < 4
In bash < 4, the variables READLINE_LINE and READLINE_POINT are not
supported for the shell commands called by `bind -x`. Even if it is
not supported, atuin works in not a bad way. However, this sometimes
causes a strange behavior by the remaining values of READLINE_LINE set
in the previous calls of __atuin_history. In bash < 4, we can
consistently use an empty string instead of $READLINE_LINE, and the
changes to READLINE_LINE and READLINE_POINT should be localized within
the function.
* fix(bash): add guard for double initialization
In bash, it is customary to reload the settings by sourcing `.bashrc`
again after modifying it. In such a case, `eval "$(atuin init bash)"`
is executed again. This registers duplicate hooks to
`preexec_functions` and `precmd_functions`. To prevent this in this
patch, we introduce an include guard, so that the initialization is
not performed more than once.
|
|
* feat(bash): support high-resolution timing without blesh
For the integration using bash-preexec, this measures the execution
time of the command using EPOCHREALTIME without the support by ble.sh.
This is not as accurate as the measurement by ble.sh as it contains
also the processing time of the preexec and precmd hooks, but it is
still free from the fork cost.
* fix(shell): work around custom IFS for duration
When a custom IFS is set by the user, the word splitting of
${duration:+--duration "$duration"} does not work as expected. We
instead use the form "--duration=$duration" with the word splitting
being disabled.
|
|
|
|
* style(bash): make indentation consistent
Initially, in this file, the first level is indented by four spaces,
and additional levels are indented by adding two spaces. However,
this does not seem intentional because the other files, such as
atuin.zsh, are consistently indented by four spaces for any levels.
The indentation was gradually fixed to use four spaces when the
relevant code is updated, but there are still remaining parts using
two spaces. In this patch, the remaining parts are updated to use the
consistent indentation of four spaces.
* style(bash): remove extra quotations on rhs of assignments
On the right-hand sides of assignments, the quoting of the variable
expansions are not needed because they are not subject to the word
splitting and the pathname expansions.
* style(bash): strip `{` and `}` from `${var}` when not needeed
* style(bash): do not use unnecessary quoting in the conditional commands
In the conditional commands [[ ... ]], the words are not subject to
the word splitting and the pathname expansions, so we do not need to
quote the expansions except for the right-hand sides of ==, !=, and
=~, where the quoting has a special meaning. In the first place, the
syntax [[ .. ]] is introduced to resolve the issue of the quoting, so
it is natural to use the unquoted form inside [[ ... ]] by default.
In this patch, we use the unquoted form of expansions.
* style(bash): prefer [[ $a && ! $b ]] to [[ -n $a && -z $b ]]
* style(bash): put "then" in the same line as "if"
This is also the format that Bash outputs with `bash --pretty-print
FILE` or `declare -f FUNC`.
|
|
When a child shell session is started from another shell session
(parent session), the environment variable ATUIN_HISTORY_ID set by the
parent session causes Atuin's precmd hook of the child session to be
unexpectedly performed before the first call of Atuin's preexec hook.
In this patch, we clear ATUIN_HISTORY_ID (possibly set by the parent
session) on the startup of the session.
|
|
* fix(bash): improve up key in multiline mode of ble.sh
ble.sh has a multiline mode where pressing [up] can be used to move to
the previous line. The command history is loaded only when the [up]
key is pressed when the cursor is in the first line. However, with
Atuin's integration, the [up] key always causes Atuin's history search
and cannot be used to move to the previous line when the cursor is not
in the first line. There is also another situation that the [up] key
does not load the command history.
In this patch, with ble.sh, we perform Atuin's history search only in
the situation where the command history is loaded in the original
binding of ble.sh.
* fix(init): perform bind on explicitly specified keymaps
With the current implementation, the keybindings to [C-r] and [up] are
only set up in the currently activated keymaps in Bash. As a result,
if the user changes the keymap after `eval "$(atuin init bash)"`,
Atuin's keybindings do not take effect. In this patch, we bind
Atuin's keybindings in all the keymaps (emacs, vi-insert, and
vi-command) by explicitly specifying them (as done for the Zsh
integration). The keybinding to "k" in the vi-command keymap is also
added to make it consistent with the Zsh integration.
* fix(init): work around limitation of "bind -x" in bash <= 4.2
In bash <= 4.2, "bind -x" with a key sequence with more than two bytes
does not work properly. Inputting the key sequence will produce an
error message saying "bash: bash_execute_unix_command: cannot find
keymap for command", and the shell command is not executed.
To work around this, we can first translate the key sequences to
another key sequence with two bytes and run the shell command through
the two-byte key sequence. In this patch, we use \C-x\C-p as the
two-byte key sequence.
* refactor(bash): move the inlined binding scripts to atuin.bash
* refactor(init): use `is_ok()` instead of negating `is_err()`
Co-authored-by: Ellie Huxtable <ellie@elliehuxtable.com>
---------
Co-authored-by: Ellie Huxtable <ellie@elliehuxtable.com>
|
|
When the user sets a custom value of IFS, the up keybinding may fail
because the option `--shell-up-key-binding` passed to
`__atuin_history` is broken by the word splitting of the shell. For
example, when the user sets IFS=-, `atuin` called from __atuin_history
receives `shell up key binding <content>` as the search string.
$ IFS=-
$ echo [up] # <-- this does not work as expected
Note that the problem only happens with the plain Bash without ble.sh.
The problem does not arise within ble.sh because ble.sh separates the
user environment and the line-editor environment by saving/restoring
the shell settings. The keybindings are processed in the line-editor
environment, so the custom IFS set by the user does not affect it.
In this patch, we properly quote the arguments to the atuin command.
|
|
auto-complete (#1511)
Apply the change for zsh-autosuggestions in
https://github.com/atuinsh/atuin/pull/1506 to the code for blesh
auto-complete.
|
|
This fixes the second issue of "0s or wrong command duration" reported
at https://github.com/atuinsh/atuin/issues/1003.
The problem is that, with bash-preexec, the preexec hook may be called
even for the commands executed by the keybindings.
* In particular, the preexec is called before the command
`__atuin_history` is executed on pressing [C-r] and [up]. In this
case, $1 passed to `__atuin_preexec` contains the last entry in the
command history, so `atuin history start` is called for the last
command. As a result, pressing [C-r] and [up] clears the duration
of the last command. This causes the reported 0s duration.
* Furthermore, the precmd hook corresponding to the keybinding command
will not be called, so the duration is only filled when the next
user command starts. This replaces the duration of the last command
with the time interval between the last press of [C-r] or [up] and
the start time of the next command. This causes the reported wrong
duration.
There is no general and robust way to distinguish the preexec
invocation for keybindings from that for the user commands, but in
this patch we exclude the preexec invocation for Atuin's keybindings
[C-r] and [up] at least.
|
|
* feat(bash): provide auto-complete source for ble.sh
* docs(integration): mention the auto-complete source for ble.sh
|
|
The parameter expansions for the prompt strings, `${PS1@P}`, is only
available in bash >= 4.4. In Bash 4.3 or below w/ bash-preexec, the
current implementation produces error messages. There is no way to
evaluate PS1 with bash < 4.4, so we give up the adjustments for
multiline prompts in bash < 4.4 in this patch.
|
|
* feat(bash): measure duration in microsecond resolution with ble.sh
* feat(zsh): measure duration in nanosecond resolution with zsh/datetime
* refactor(history): use Option<i64> for command-line arg duration
Co-authored-by: Ellie Huxtable <ellie@elliehuxtable.com>
* style(history): apply suggestion by `cargo fmt`
* fix(history): use Option<u64> for arg duration
---------
Co-authored-by: Ellie Huxtable <ellie@elliehuxtable.com>
|
|
* fix(bash): preserve the line content on search cancel
In the current implementation for Bash, the line content is lost when
the user cancels the atuin search by pressing ESC, C-g, or Down at the
bottom line. This is because the line content is set to the empty
string returned by atuin on the cancellation of the search.
In the integrations for other shells, zsh and fish, the empty output
is properly handled so that the line content is preserved. This patch
makes the behavior in Bash consistent with that in zsh and fish, i.e.,
we do nothing when the atuin search returns an empty output.
* fix(zsh): ignore confusing line `__atuin_accept__:*` on search cancel
|
|
* fix(bash): prefix "__atuin_" to avoid variable conflicts
Because the function "__atuin_history" executes an arbitary user
command for "enter_accept", the local variable names should be
carefully chosen. A local variable can shadow a global variable that
the user wants to use when there is a name conflict. To avoid such a
situation we try to namespace the variables used by atuin by prefixing
"__atuin_".
* fix(bash): work around "shopt -s xpg_echo"
* refactor(bash): simplify the rendering of the prompt
* perf(bash): avoid extra evaluation of PS1
* refactor(bash): count \n by wc
We can simply use "wc -l" to count the number of newline characters.
In the POSIX standard, a line in a text stream is defined as
characters terminated by a newline character, so the unterminated line
is not counted by "wc -l". As a result, "wc -l" actually counts the
number of newline characters.
* refactor(bash): rename localvar `HISTORY => __atuin_command`
This patch renames the local variable `HISTORY` in __atuin_accept_line
to `__atuin_command`. The name of the global variable `HISTORY` set
by `__atuin_history` is kept.
|
|
|