zsh-users / zaw Goto Github PK
View Code? Open in Web Editor NEWzsh anything.el-like widget.
License: BSD 3-Clause "New" or "Revised" License
zsh anything.el-like widget.
License: BSD 3-Clause "New" or "Revised" License
I'm not that into zsh scripting.
Is there any way to configure zaw in a way, that (at least for the history section) the commands will get executed immediately?
Hey! I'm using zaw to search my history, and love it there...
Is there anyway to let zaw accept input from stdin? ie use it as an interactive grep ?
For example, I'd like to do something like this:
instead of the following to find files with both "it" and "test" in their names:
find . | grep it | grep test
I'd like to see if I could use zaw to select the files, like:
find . | zaw
if I run this, then zaw takes stdin and allows me to select items from stdin by doing interactive searches. Once selected, then zaw outputs the contents to the cmd line. Maybe it rewrites the command as
find . | zaw it test
I know this is fuzzy and not exactly how zaw works, but it seems to me that it could fit this use case somehow... kind of like https://github.com/mooz/percol
I've just installed zaw with zplug
zplug zsh-users/zaw
and disabled all other zplug plugins, and confirmed that zaw is in fact installed:
brandon@Brandons-MacBook-Air ~ % zplug status
[zplug] Start to get remote status 1 plugins in parallel
✔ Up-to-date zsh-users/zaw
[zplug] Elapsed time: 0.7313 sec.
==> All packages are up-to-date!
but when I enter ^x
I see no response. According to the README I should see a list of sources at this point.
My Zsh version is 5.8:
brandon@Brandons-MacBook-Air ~ % zsh --version
zsh --version
zsh 5.8 (x86_64-apple-darwin20.0)
zaw-print-src
seems to verify that zaw is installed:
brandon@Brandons-MacBook-Air ~ % zaw-print-src
source name shortcut widget name
----------------------------------------
aliases zaw-aliases
applications zaw-applications
bookmark zaw-bookmark
command-output zaw-command-output
commands zaw-commands
fasd zaw-fasd
fasd-directories zaw-fasd-directories
fasd-files zaw-fasd-files
functions zaw-functions
git-branches zaw-git-branches
git-files zaw-git-files
git-files-legacy zaw-git-files-legacy
git-log zaw-git-log
git-recent-all-branches zaw-git-recent-all-branches
git-recent-branches zaw-git-recent-branches
git-reflog zaw-git-reflog
git-status zaw-git-status
history zaw-history
locate zaw-locate
open-file zaw-open-file
perldoc zaw-perldoc
process zaw-process
programs zaw-programs
screens zaw-screens
searcher zaw-searcher
ssh-hosts zaw-ssh-hosts
tmux zaw-tmux
widgets zaw-widgets
Would it be possible that, when using zaw-history
, only unique entries are displayed (maybe with like a count or something). For instance say I use the command abc
all the time but occasionally abcd
. Currently if I have used abc
more than max-lines
times since the last abcd
command, I only see a list of abc
that I can choose from; it would be a lot more useful if I would see both. It would also make it easier to navigate through the list.
Note: I'm aware of removing "duplicates" in your history but that only works if they were run consecutively (unless there are other options I"m unaware of).
Thanks.
First of all, thank you very much for the plugin, I can't imagine to work without!
Did you think about adding Fasd (https://github.com/clvv/fasd) as a source ?
I believe other users would appreciate it as well.
One of the great features of (helm
/anything.el
) is the ability to have one command for multiple sources. For example helm-mini
includes the sources helm-source-buffer-list
and helm-source-recentf
. In this way, you can potentially cast a wide "net" of possible candidates and filter them down to what you want very quickly, instead of having to determine which type of candidate you want and then call the correct command.
It would, of course, be awesome if zaw
supported this workflow as well.
When I use zaw for a history lookup and press Enter on my match the following gets displayed:
No such widget .zaw-history
Seems this is linux based. I am trying to get it functional on OSX:
brew list
, and set name and exec_ outside the while loop. Works, but is not too helpful since many brews are dependencies and not standalone apps. Need to work this out.Overall, a neat utility, should be extended for OSX. (I've never used anything.el so don't know the background -- vim user here). Thx.
/usr/share/applications/*.desktop
does not exist on Mac OS X. mdfind 'kMDItemKind == "Application"'
can be used to find all Applications followed by open
to open them. mdfind
lists the pull path to the item.
Would be great to be able to use zaw as a completion widget for commands with loads of options like gpg for example. I did a bit of research on this some time ago but couldn't figure out how to do it.
If anyone has any ideas about the best way to accomplish this, let us know in the comments below.
From #94
There is no documentation for writing zaw source. We should write it on Wiki.
This repository's latest commit is over a year old, and there are lots of great pull requests. I really want some of those incorporated(git log, various improvements to git sources, etc), but I don't want to maintain a fork and work to pull all these in. I'm sure I'm not the only one who would like some of these great features.
If nobody in the zsh-users group has time or desire to go through the pull requests and merge the good ones, I'm happy to do it if you add me to the group. Or we should find somebody else who is willing. I just want zaw to stay alive and adopt some of these PRs.
I'm trying to write a plugin that is context sensitive - it's behaviour depends on the words on the current command line. I tried using the completion special parameters $CURRENT and $words as documented in the zsh manual, but their values don't seem to match the current state of the command line. Can anyone help me here?
Right now 'pattern not found' is highlighted in red but it's not customisable; it ought to be.
fasd
returns files and directories ordered by ascending frecency (i.e. relevance), and the zaw source displays them in that order, leaving the most relevant item at the bottom of the list. fasd
should be called with a -R
parameter to reverse its output.
Was hoping to find a zsh alternative to FZF.
What I'd like to do is to be able to search backward through my history with the contents I may have already typed on the command line.
Is there a way to do this with zsh/zaw?
Currently if I enter zaw, after having already typed on the command line, I have to retype it in zaw.
Example:
ssh someserver
Now I think, "What was that port again?" so I open zaw and I have to retype ssh someserver
to find it.
Should we consider splitting sources off into other repositories?
We've gotten to the point where we have a lot, and while some are probably widely used (history, git, cdr maybe), others are probably less so. I've recently whipped up some quick sources for personal use (one for todoman, a few for mpd) that are probably a little too uncommonly used and maybe a little too rough to include in the main repository, but I would still like to share them with other users of zaw and those programs.
I think it might be good to include in the readme a solicitation for others to host their own sources and tell us the URLs of their repos, and then have a list of source URLs with descriptions of those sources. That way we could invite more participation without needing to make pull requests and without filling the main repo with lots of sources for programs that aren't often used, while also giving them some visibility.
What do you think, @termoshtt and other interested parties?
As an example of what such repos would look like, I put up my mpd sources here. We could conceivably have several such repos listed in the readme, especially for sources of programs that we the maintainers don't use (eg. we've had a PR for a docker source sitting around forever, but I have not felt motivated to learn docker just to test the source).
Man, you have changed my life! This thing is awesome! I use anything.el all the time in emacs... now I have it in zsh.
I was confused at first on the usage of the main keybinding ^x;. I think you need to make it clearer in the Readme that you need to press after you select the source to use it.
My first inclination was to press '^x;' then immediately start typing my filter query. Or to select a source using '^n' then start typing. This of course would give me a "pattern not found". I realize now that I need to press '^x;', then select the source, then press '', then type my filter query.
Under "usage" in the Readme, I think "1. select 'source' and press ''" would help a lot.
Keep up the good work!
Hi there, I'm trying to use Zaw for the first time. I've followed the installation directions. I cloned zaw to a folder in my home directory, and then sourced zaw.zsh
from my .zshrc
.
When I try to run zaw-history
(or any zaw*
command) directly, I get : zaw-history:zle: widgets can only be called when ZLE is active
. Additionally, when I press ctrl-x
, nothing happens.
Even if I source zaw.zsh
in my terminal, ctrl-x
still doesn't work.
Any suggestions?
I have setopt hist_find_no_dups
, but whenever I search in my history, I see duplicates for all the commands I've run more than once.
I do not want to set hist_ignore_all_dups
because it's valuable to go back and see a previously executed sequence of commands. If duplicates are removed, then that sequence of commands becomes modified and it's harder to piece together.
Is it possible to make accept-search
the default action and accept-line
the alternative action? Also, I'm wondering if it's possible to use custom keybindings other than meta + enter
--sadly I couldn't find out how to send meta + enter
in iTerm 2 on macOS.
You need to check for BSD ps
.
ps: No user named 'x'
ps: illegal option -- -
usage: ps [-AaCcEefhjlMmrSTvwXx] [-O fmt | -o fmt] [-G gid[,gid...]]
[-g grp[,grp...]] [-u [uid,uid...]]
[-p pid[,pid...]] [-t tty[,tty...]] [-U user[,user...]]
ps [-L]
filter:
[1/1]
First of all, thank you for the very nice widget. I have been using it already for some years.
Currently I have started to get following error when I press Enter on the selected item:
zaw-action:2: number expected
I have also found out that if I comment out styles in zaw-action(), everything gets executed as before:
#local -a styles=(default alt)
Do I need to add some style settings to make it work?
In my source I have only one action. But having only one element in actions
and act_descriptions
arrays does not execute the action for me when candidate selected. To work around this I had to duplicate the elements. Maybe I misunderstand something?
function zaw-src-mywidget() {
candidates=('HELLO' 'WORLD')
actions=(zaw-src-mycall zaw-src-mycall) # <-- dublicates
act_descriptions=("description" "description") # <-- dublicates
}
function zaw-src-mycall() {
LBUFFER="choice was $1"
}
zaw-register-src -n mywidget zaw-src-mywidget
I've been maintaining zaw (read: accepting pull requests) for some time, but I don't think I really have time for it anymore. I mostly don't use zsh anymore since I'm building and using rash (which doesn't currently have any of the advantages of an extensible editor like zsh does, but eventually I plan on it).
Sorry I'm probably not going to fix any more zaw issues going forward.
% cd ~zaw
% setopt no_short_loops
% rm -f *.zwc
% zcompile zaw.plugin.zsh
zsh: parse error near `source'
zcompile: can't read file: zaw.plugin.zsh
It's about those lines of zaw.plugin.zsh
:
# load zaw sources
setopt local_options extended_glob
local src_dir="${cur_dir}/sources" f
if [[ -d "${src_dir}" ]]; then
for f ("${src_dir}"/^*.zwc) source "${f}"
fi
You really shouldn't use short_loops, they're intended for interactive use (they have drawback – they limit Zsh's parser capability to detect syntax errors). So, to fix, to first lines of zaw.plugin.zsh:
function() {
zmodload zsh/parameter
autoload -U is-at-least
There should be added:
setopt localoptions short_loops
The question is whether zaw want's to change some of Zsh's options. If yes, then better, and overall better, rewrite the loop:
if [[ -d "${src_dir}" ]]; then
for f ("${src_dir}"/^*.zwc) source "${f}"
fi
-->
if [[ -d "${src_dir}" ]]; then
for f in "${src_dir}"/^*.zwc; do
source "${f}"
done
fi
and forget about any problems with short_loops.
I started using zaw since last 2 days and I am loving it. I noticed when playing around if I press Tab or Ctrl+I in the zaw-history. I can't go back.
zaw-history is incapable of displaying multiline commands properly.
After 5e46652 hist_find_no_dups randomizes entries order, which is terribly inconvenient. The order of entries should always have more recent items on top.
the output is like this. Is is possible to escape and show the colors.
^[[1;32mREADME.rst^[[0m:^[[1;33m2^[[0m:^[[34mzaw^[[0m - zsh anything.el-like widget^[[0m^[[K
^[[1;32mREADME.rst^[[0m:^[[1;33m10^[[0m: $ git clone git://github.com/zsh-users/^[[34mzaw^[[0m.git^[[0m^[[K
^[[1;32mREADME.rst^[[0m:^[[1;33m16^[[0m: $ echo "source ${PWD}/^[[34mzaw^[[0m/^[[34mzaw^[[0m.zsh" >> ~/.zshrc^[[0m^[[K
^[[1;32mREADME.rst^[[0m:^[[1;33m18^[[0m:and restart zsh or manualy source ``^[[34mzaw^[[0m.zsh``.^[[0m^[[K
^[[1;32mREADME.rst^[[0m:^[[1;33m24^[[0m:1. Trigger `^[[34mzaw^[[0m` by pressing ``Ctrl-x ;`` (``^x;``).^[[0m^[[K
^[[1;32mREADME.rst^[[0m:^[[1;33m56^[[0m:^[[34mzaw^[[0m automaticaly create shortcut widgets for each sources^[[0m^[[K
^[[1;32mREADME.rst^[[0m:^[[1;33m59^[[0m:for example, execute ``bindkey '^R' ^[[34mzaw^[[0m-history`` and^[[0m^[[K
^[[1;32mREADME.rst^[[0m:^[[1;33m62^[[0m:you can get all available shortcut widgets' name using ``^[[34mzaw^[[0m-print-src``::^[[0m^[[K
^[[1;32mREADME.rst^[[0m:^[[1;33m64^[[0m: $ ^[[34mzaw^[[0m-print-src^[[0m^[[K
^[[1;32mREADME.rst^[[0m:^[[1;33m67^[[0m: ack ^[[34mzaw^[[0m-ack^[[0m^[[K
^[[1;32mREADME.rst^[[0m:^[[1;33m68^[[0m: applications ^[[34mzaw^[[0m-applications^[[0m^[[K
^[[1;32mREADME.rst^[[0m:^[[1;33m69^[[0m: bookmark ^[[34mzaw^[[0m-bookmark^[[0m^[[K
^[[1;32mREADME.rst^[[0m:^[[1;33m70^[[0m: git-files ^[[34mzaw^[[0m-git-files^[[0m^[[K
^[[1;32mREADME.rst^[[0m:^[[1;33m71^[[0m: git-files-legacy ^[[34mzaw^[[0m-git-files-legacy^[[0m^[[K
^[[1;32mREADME.rst^[[0m:^[[1;33m72^[[0m: history ^[[34mzaw^[[0m-history^[[0m^[[K
^[[1;32mREADME.rst^[[0m:^[[1;33m73^[[0m: open-file ^[[34mzaw^[[0m-open-file^[[0m^[[K
On Mac OS X, there is an open
command which ought to be used in lieu of the non-existent gnome-open
. Linux also has xdg-open
.
I would like to see zaw-history exported out of zaw. It's the most useful part, and I suspect 99% of users just use that.
Some time ago arrow keys completely stopped working. Ctrl+n/p work fine.
When I press them escape sequences are entered into filter field for history (^[OB for down).
All arrow keys work fine in zsh command line.
I found Ctrl+X, ;, Ctrl+I to provide a feature that I didn't see on the README. Would be nice to make it more visible.
I am seeing
(anon):5: unrecognized modifier `A'
on launch.
When using the following configuration (~/.zshrc
):
HISTSIZE=5000
SAVEHIST=2500
HISTFILE=~/.zhist
source ~/.zplug/init.zsh
zstyle :filter-select hist-find-no-dups yes
zplug zsh-users/zaw
zplug zsh-users/zsh-syntax-highlighting, defer:2
zplug load
bindkey '^R' zaw-history
and I do the following:
zaw
's interactive history searchI get the following error:
_zsh_highlight:17: bad set of key/value pairs for associative array
If I remove the line zstyle :filter-select hist-find-no-dups yes
from my configuration the error message stops appearing.
Is there a way to set a keybinding for any of the alternative options?
I know about the Meta-Enter for the first alternative option, but can you set other keys for the other options?
Invoking a zaw source with zle zaw zaw-source-foo
allows to pass arbitrary parameters to the source function,
zle zaw zaw-source-foo "my" "arguments"
When the widget is invoked in the short form,
zle zaw-foo "my" "arguments"
then the parameters are not passed on to the source function.
zstyle ':filter-select:highlighting' marked
should be documented.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.