Comments (23)
if you only use zsh-autosuggestions this works:
# zsh autosuggestions
source ~/.zsh/zsh-autosuggestions/zsh-autosuggestions.zsh
bindkey '^ ' autosuggest-accept
_zsh_autosuggest_strategy_atuin_top() {
suggestion=$(atuin search --cmd-only --limit 1 --search-mode prefix $1)
}
ZSH_AUTOSUGGEST_STRATEGY=atuin_top
from atuin.
I found https://news.ycombinator.com/item?id=35256206
reposting here for brevity:
atuin-setup() {
if ! which atuin &> /dev/null; then return 1; fi
bindkey '^E' _atuin_search_widget
export ATUIN_NOBIND="true"
eval "$(atuin init "$CUR_SHELL")"
fzf-atuin-history-widget() {
local selected num
setopt localoptions noglobsubst noposixbuiltins pipefail no_aliases 2>/dev/null
# local atuin_opts="--cmd-only --limit ${ATUIN_LIMIT:-5000}"
local atuin_opts="--cmd-only"
local fzf_opts=(
--height=${FZF_TMUX_HEIGHT:-80%}
--tac
"-n2..,.."
--tiebreak=index
"--query=${LBUFFER}"
"+m"
"--bind=ctrl-d:reload(atuin search $atuin_opts -c $PWD),ctrl-r:reload(atuin search $atuin_opts)"
)
selected=$(
eval "atuin search ${atuin_opts}" |
fzf "${fzf_opts[@]}"
)
local ret=$?
if [ -n "$selected" ]; then
# the += lets it insert at current pos instead of replacing
LBUFFER+="${selected}"
fi
zle reset-prompt
return $ret
}
zle -N fzf-atuin-history-widget
bindkey '^R' fzf-atuin-history-widget
}
atuin-setup
This works really well so far!
from atuin.
@Dentrax I believe what you want is possible, although I don't know the details of how to configure the hook correctly.
This command does what you want,
atuin history list --cmd-only | fzf
Now, if you set export ATUIN_NOBIND=1
in your .rc file before the atuin init step, then the TUI based hook won't be installed, and you could install your own to trigger the command I suggested above.
There's a secondary issue that atuin streaming to fzf is slow but I'm gonna close this issue as solved and open a new one for that
from atuin.
I have atuin
working with fzf
and zsh-autosuggestions
I don't have the time to review it now, or to publish my entire dotfiles but I can dump the important bits. Some of it is a little messy but it's decently documented.
Pastebin
@hd-deman You can write stuff into the shell input by setting it in the buffer like this: BUFFER="some stuff"
from atuin.
#1274 which should be out next week should help with that
from atuin.
cargo install --path . --root $(brew --prefix)
cargo install atuin --root $(brew --prefix)
should do the trick
from atuin.
It was mentioned here already: #286
from atuin.
I found https://news.ycombinator.com/item?id=35256206
reposting here for brevity:
atuin-setup() { if ! which atuin &> /dev/null; then return 1; fi bindkey '^E' _atuin_search_widget export ATUIN_NOBIND="true" eval "$(atuin init "$CUR_SHELL")" fzf-atuin-history-widget() { local selected num setopt localoptions noglobsubst noposixbuiltins pipefail no_aliases 2>/dev/null # local atuin_opts="--cmd-only --limit ${ATUIN_LIMIT:-5000}" local atuin_opts="--cmd-only" local fzf_opts=( --height=${FZF_TMUX_HEIGHT:-80%} --tac "-n2..,.." --tiebreak=index "--query=${LBUFFER}" "+m" "--bind=ctrl-d:reload(atuin search $atuin_opts -c $PWD),ctrl-r:reload(atuin search $atuin_opts)" ) selected=$( eval "atuin search ${atuin_opts}" | fzf "${fzf_opts[@]}" ) local ret=$? if [ -n "$selected" ]; then # the += lets it insert at current pos instead of replacing LBUFFER+="${selected}" fi zle reset-prompt return $ret } zle -N fzf-atuin-history-widget bindkey '^R' fzf-atuin-history-widget } atuin-setup
This works really well so far!
Works really well - but how do I get the preview window? I tried adding "--preview 'echo {}' --preview-window down:3:hidden:wrap --bind '?:toggle-preview'"
to the fzf_opts
but that doesn't change anything.
from atuin.
Has anyone been able to get this working properly with multiline shell history? If there's a history command that is multiline, it shows up as multiple entries in the fzf list, which makes this fzf-based search unusable :(
from atuin.
Maybe we should ask fzf's maintainers to detect if atuin is in the path and use that instead of history.
from atuin.
I'm looking forward to this feature! @ellie Each time I write a command and press the UP key to auto-complete current cmd, TUI appears and I had a bit distracting DX. It would be great if we are able to use it with fzf
feature enabled only. 😇
i.e. something like the following, but atuin
powered. :)
from atuin.
@ellie, there’s a better alternative to fzf written in Rust: skim. Unlike fzf, it can be used as a library, so maybe it’d make sense to integrate it into atuin?
from atuin.
Yeah that seems to be a bug. It's looking for the ATUIN_SESSION
environment variable, even though its not needed in your example
from atuin.
Yup the bug is with the bash script! The ATUIN_SESSION
variable is actually needed for history to be properly recorded though, so I'll get the bash plugin fixed.
As well as that, you'll probably want a nice way of listing only the command for fzf
, so that'll need sorting too
from atuin.
Hey @neerajbadlani!
Once #89 merges, you should be able to do something like this
atuin h l --cmd-only | fzf
from atuin.
Thanks @ellie , above works and is close to what i want . However I see duplicate entries in history .
Also , new to rust ecosystem , since brew install --HEAD dint work , so had to do manual installation .
How do i tell rust to install in specific directory ?
[main:atuin] cargo install --root $(brew --prefix)
error: Using `cargo install` to install the binaries for the package in current working directory is no longer supported, use `cargo install --path .` instead. Use `cargo build` if you want to simply build the package.
from atuin.
Thanks , I am able to integrate it with fzf properly now , exactly similar to what fzf provides , but with machine machine and session sync .
2 things remaining : 1 . Duplicate Entries 2 . Sorted Histories ( Recent , Frequency , .. )
Should I close this and open another issue for those ?
from atuin.
Something like this should work :)
https://stackoverflow.com/questions/11532157/remove-duplicate-lines-without-sorting
We could add a unique flag, but I'd rather not unless it's 100% necessary
Another issue for sorted history would be good! I've been thinking of how we can better prioritise things
from atuin.
^ kind ping @ellie 🙏
from atuin.
this thing works
export ATUIN_NOBIND="true"
eval "$(atuin init zsh)"
zle -N _atuinr_widget _atuinr
_atuinr() {
atuin history list --cmd-only | fzf
}
bindkey '^r' _atuinr_widget
The only difference is that it immediately executes the code instead of put it into the shell input.
I don't understand how to fix it.
any ideas?
from atuin.
your
I have
atuin
working withfzf
andzsh-autosuggestions
I don't have the time to review it now, or to publish my entire dotfiles but I can dump the important bits. Some of it is a little messy but it's decently documented. Pastebin@hd-deman You can write stuff into the shell input by setting it in the buffer like this: BUFFER="some stuff"
Perfect. just what I needed. Thanks
from atuin.
This doesn't work for multiline entries in the shell history. Has anyone been able to solve that?
from atuin.
Has anyone been able to get this working properly with multiline shell history? If there's a history command that is multiline, it shows up as multiple entries in the fzf list, which makes this fzf-based search unusable :(
Also wondering this
from atuin.
Related Issues (20)
- how to choose one history without execute HOT 6
- zsh: after selecting command from history, can't go to zsh's vim mode HOT 4
- Proposal: `atuin config` should list all config files and dirs
- Env var option to disable atuin or make session history volatile for integrated Terminals (VS Code, IDEs)
- How to completely uninstall? HOT 3
- Segmentation fault when HOME env does not exist HOT 4
- [Feature Request] Edit command while selecting command HOT 2
- Neural-network based prediction/ranking algorithm (ala mcfly)
- Interactive commands not saving to history HOT 2
- Text overflow on website HOT 1
- Initial cargo install fails because of missing `cargo` executable in path HOT 1
- multiline commands in Zsh history get corrupted after import HOT 2
- The up key UI does not show the history on windows' MSYS2 bash HOT 1
- fish shell init failing on v3.3.1 HOT 2
- Please update the ring crate to 17.x HOT 2
- Configure "Enter" behaviour like "tab" HOT 3
- macOS + iterm ctrl-n binding issues HOT 5
- Show host and user in the inspector HOT 1
- Reassure the user sync is happening HOT 1
- Error while editing a command prefix with "-" or "--" HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from atuin.