New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
help with counsel-shell-command #689
Comments
Try this: (defun counsel-shell-command-history ()
(interactive)
(ivy-read "cmd: " shell-command-history
:action 'insert
:caller 'counsel-shell-command-history))
(define-key minibuffer-local-shell-command-map
(kbd "C-r") 'counsel-shell-command-history) Invoke your |
Thanks, after some tweaking i got my function down to this, which works as I expected. I tried your variant but get "Command attempted to use minibuffer while in minebuffer. I'm happy with what I came up with, but would like to get your version to work also. Again thanks for your help.
|
You also need With you command, you have no option to alter the previous command before running it. With mine, you can do it, but it takes an extra RET. |
@njdan5691 I had to add Though having the option to edit the command does seem nice. @abo-abo when I try your version, it inserts the command into the current buffer, not the minibuffer? And |
Do you have the latest ivy version? |
I believe I do |
@therockmandolinist It should insert into the current buffer. Was the minibuffer current when you called the command? You need to call it through a binding when already in the minibuffer, not through |
Oh yeah, I see. Nevermind, I was being silly and calling the function by name. Thanks for clearing that up! |
This is what I ended up with, the @abo-abo version wrapped in use-package. Works perfect, thanks.
|
The new command Thanks to all for contributing to the discussion. |
I don't use counsel-mode, I need to use find-file without the counsel extension, because I use environment variables when locating my files, and have not figured out how to do that with counsel yet. |
@abo-abo, I've been trying, without success to replicate your counsel-shell-command-history for use with dired-do-async-shell-command. Do you have any idea how to get a similar C-r map to what you've done with the regular shell command? I can't seem to figure out which map to put the define-key into. EDIT: This is solved for apparently all minibuffer now via: |
@JohnLunzer glad you found the solution. The code you used is also part of |
This commit binds "C-r" in the shell-command prompt (minibuffer) so that it brings up a command history search using ivy. The behaviour is very similar to the way fzf behaves when pressing "C-r" at a bash/zsh prompt. Original source code and discussion: abo-abo/swiper#689 (comment)
This commit binds "C-r" in the shell-command prompt (minibuffer) so that it brings up a command history search using ivy. The behaviour is very similar to the way fzf behaves when pressing "C-r" at a bash/zsh prompt. Original source code and discussion: abo-abo/swiper#689 (comment)
Hi,
I use M-: (shell-command) often, and have turned on the history, I would love to have a counsel interface instead of the default behavior. I'm pretty new to elisp but this snippet was my first attempt
at it, using counsel-describe-function as a start. Well obviously this did not work. Would someone be kind enough to help.
Thanks in advance
The text was updated successfully, but these errors were encountered: