I'm really like AUTOCD option in zsh but widget names make it less comfortable in use. The problem is when I'm e.g. in my home directory, type "down" and press Tab I would expect completion for "Downloads" but on the first place in auto-completion is "down-line-or-beginning-search". Downloads is on the second pace what cause that I have to press tab additionally twice. It makes this process not to much ergonomic.
Does anybody know how to exclude widget names from zsh auto-completion?
zstyle ':completion:*:*:-command-:*:*' ignored-patterns 'down-line-or-beginning-search'
Related
I use zsh 5.8 (oh-my-zsh + my custom configs) with iTerm2.
I want every zsh instance to store the command to the history every time I type it and share the history with the others.
It basically works as I want, but the problem is, if I (manually) quit iTerm2 with multiple tabs open (e.g. so that I can recover those tabs after reboot), the zsh_history file loses most of its content and contains only the first N commands.
My guess is the zsh instances kind of compete with each other in the last moment.
HISTSIZE and SAVEHIST are set largely enough (10000000).
setopt prints:
alwaystoend
autocd
autopushd
noclobber
completeinword
extendedhistory
noflowcontrol
histexpiredupsfirst
histfcntllock
histignoredups
histignorespace
histverify
incappendhistory
interactive
interactivecomments
login
longlistjobs
monitor
promptsubst
pushdignoredups
pushdminus
sharehistory
shinstdin
zle
Is there any way I can prevent this from happening?
EDIT: After seeing the comment, I disabled inc_append_history, but it's happening again.
EDIT2: Disabled appendhistory as well, but still the same.
EDIT3: After manually unsetting histsavebycopy (i.e., nohistsavebycopy), looking good so far.
EDIT4: Since the last change (EDIT3), I've experienced zsh: corrupt history file once.
EDIT5: Lost some history even without the corrupt history file error.
I have a simple issue with zsh. Sometimes, I am in a directory with multiples sub-directories.
So, when I do a $ ls[TAB] or $cd[TAB], I list all these sub-directories.
But how to accept one of the suggestions for sub-directories? Is there a short cut or a key to choose a directory to go deeper in this directory.
I must precise that I don't know systematically the content of these subdirectories, so I can't often choose a subdirectory in which the first letter of filename could allow me to choose automatically the sub-directory to explore.
I was looking for a solution on the web but documentation about zsh completion is pretty big.
Edit: simplest solution to accomplish the desired effect:
press [/] key to 'accept' the current suggested directory ; then press again [tab] key to show suggestions of its subdirectories
Old suggested solution:
Install https://ohmyz.sh/
Then pressing the [tab] key displays a list and the first item is highlighted.
Hit the [tab] key again to choose the desired item and hit the [enter] key to write it in the command line interface, without actually executing the command, only as if you have just typed it in.
Then you can continue hitting the [tab] key to select another subdirectory, and so on.
It also works on any autocompletable, not only dirs.
The only way I know is: double click your target + cmd c + cmd v and then press Enter.
So, to better explain what I'm asking for, I am writing a zsh plugin for quickly navigating up directories and I want to offer the ability to traverse into a directory by specifying a starting directory in $PWD.
For example, if I am in a directory ~/example/first/left/second and I wanted to go to a directory ~/example/first/right, I could call $ up first/right. I managed to get the functionality working just fine, but I want to offer tab completions in the same way cd ..[/..]* does.
At the moment, here is what I have
_up() {
local -a args
args=(`echo ${PWD#/} | sed 's/\// /g'`)
_arguments ':paths:($args[#])'
}
And so I currently have tab completions working for all of the initial options available, but past that point I have no idea how to get zsh to tab complete like paths past this point.
(1) For example, I want to set map gd g* in Qt's Fakevim like below but failed.
(2) And also I'd like to set F3 as the save command, how to do it?
(3) In Fakevim, it provides an option "Read .vimrc", but where to find the file .vimrc?
Thank you!
It doesn't look like there is a lot of documentation for FakeVim, so official sources might not exist. Most of this was obtained by experimentation.
If you want to dig deeper, I guess there's no source as official as the actual source: http://qt.gitorious.org/qt-creator/qt-creator/blobs/0809986e501415fe2c8508800b94b5b3169dc048/src/plugins/fakevim/fakevimplugin.cpp
User commands
First off, realize that in Tools>Options>FakeVim>User Command Mapping, you're only setting what your user actions will perform, not how you perform them.
By default, user command #1 is triggered by pressing Alt-V, then 1.
Alt-V, then 2, triggers user action #2, and so on.
You can change the keyboard shortcuts through the general QtCreator configuration interface, under Tools>Options>Environment>Keyboard. There is a "FakeVim" section with all the user actions listed. Select your user action of choice, press the little "erase" icon in the input field under "Shortcut", then press your desired shortcut key, which should appear in the input field.
Second, to finish a command where you would normally press enter, you should literally type in <CR> after the commands. You also need to enter in ':' to enter command mode.
So if you wanted to map the vim save command, ":w", to F3 via FakeVim, you would:
Go to Tools>Options>FakeVim>User Command Mapping.
Enter ":w<CR>" as one of the user commands (say #7).
Go to Tools>Options>Environment>Keyboard.
Find the FakeVim action "UserAction7".
Set F3 as a shortcut for it.
Now, every time you're in the editor, you should be able to click F3 and have the FakeVim :w command execute, which will save your file.
Note that there is also an option to set a shortcut for "Save" directly in the QtCreator keyboard settings, so for this particular shortcut you don't actually need to go through FakeVim.
Setting shortcuts for other vim commands should be similar. Note that you're restricted to the subset of vim commands that FakeVim implements. Refer to the source, linked above, for checking any particular command you're wondering about.
Vimrc file
On Linux this would be ~/.vimrc, a file in the user's home directory. I presume you're asking about Windows.
The best source I can find is this bug report about it being hard to use Fakevim's vimrc on Windows: https://bugreports.qt.io/browse/QTCREATORBUG-8748
Following that, the file Fakevim looks for is ".vimrc" in %USERPROFILE% (you can enter a name like that in Explorer to go to the folder). However, it's tricky to access a file with a name like that on Windows. (Thus why the real vim uses '_vimrc' on Windows -- but FakeVim apparently doesn't, at least at the moment.)
Here is a superuser page with workarounds for how to create such files on Windows: https://superuser.com/questions/64471/create-rename-a-file-folder-that-begins-with-a-dot-in-windows
I have completion menu configured in my zsh. It works great, no problem.
Now I want to make my zsh act like that:
Let's say there are 3 files in a directory:
somefile_first
somefile_second
somefile_third
Now when I press [TAB], I get completion menu with the first file placed in the command line.
But I want zsh to complete the common part of file names (in this example it would be somefile_), do not place anything else after the common part, and let me navigate through completion menu.
How do I do that?
I realize this question is old but I stumbled upon it when looking for the same answer. Here is what I found out.
AFAIK when using completion menu zsh will always place highlighted completion in the command line. However you can make it less hasty.
unsetopt menucomplete
setopt automenu
Changes the behaviour so
first TAB completes the common part
second lists completions without changing command line
third starts the menu and completes command line with highlighted completion
If you prefer no command line changes than fancy menu unset automenu too:
unsetopt menucomplete automenu
That gives bash-like completion. Only common part is completed and propositions are listed.