Zsh doesn't support anything but internal registers, and bash doesn't support register at all as far as I know. By and large, shells support vi commands, not vim commands.
In zsh, here's a proof-of-concept for accessing the X selection from command mode. For real use you'd want to elaborate on these techniques. I use the xsel
program, you can use xclip
instead; see How to copy from one vim instance to another using registers. You'll find the features I used in the zle manual.
vi-append-x-selection () { RBUFFER=$(xsel -o -p </dev/null)$RBUFFER; }
zle -N vi-append-x-selection
bindkey -a '^X' vi-append-x-selection
vi-yank-x-selection () { print -rn -- $CUTBUFFER | xsel -i -p; }
zle -N vi-yank-x-selection
bindkey -a '^Y' vi-yank-x-selection
The function vi-append-x-selection
inserts the current X selection after the cursor (similar to p
or P
). The function vi-yank-x-selection
copies the last killed or yanked text to the X selection. zle -N
declares the functions as zle widgets (i.e. edition commands). bindkey -a
sets bindings for vi command mode.
_kadmin
is probably a completer function for the kadmin
tool - not a directory. If you attempt completion on something that zsh
can't find as a command, a directory or a valid and known command argument completion, it then starts to offer completion functions as possible expansion candidates. By default, zsh
comes with a lot of completers, many of which you may not need - there are bundles for AIX, BSD, Cygwin, various Linux distributions, etc, and they all get read and installed into the shell. If you attempt an expansion on something zsh
can't find, it has all those installed completion functions to offer you instead.
You configure zsh
not to offer completer functions by putting this in your ~/.zshrc
:
zstyle ':completion:*:functions' ignored-patterns '_*'
Reload the file and you should no longer be offered completion functions for tools you don't have installed. Have a look at the zshcompsys
manpage for (a lot) more detail.
EDIT in reply to UPDATE 3
If _kadmin
is actually a user account, you can configure zsh
to not offer it in completions. It seems the approach is to list the user accounts you do want the shell to consider, which limits any names offered only to those listed. The zstyle
line is something like this:
zstyle ':completion:*' users asgeo1 root
I think you can list as many users as you like after the users
tag. The shell will then only offer those users' home directories as possible completions for the cd
function or builtin.
I don't know why adding the username to the ignored-patterns in the completion.zsh
file didn't work - did you reload your config after making the change?
Best Answer
The reason
noclobber
is not set by default is tradition. As a matter of user interface design, it's a good idea to make “create this new file” the easy action and to put an extra hurdle the more dangerous action “either create a new file or overwrite an existing file”. Thusnoclobber
is a good idea (>
to create a new file,>|
to potentially overwrite an existing file) and it would likely have been the default if the shell had been designed a few decades later.I strongly recommend to use the following in your interactive shell startup file (
.bashrc
or.zshrc
):In each case (redirection, copying, moving), the goal is to add an extra hurdle when the operation may have the side effect of erasing some existing data, even though erasing existing data is not the primary goal of the operation. I don't put
rm -i
in this list because erasing data is the primary goal ofrm
.Do note that
noclobber
and-i
are safety nets. If they trigger, you've done something wrong. So don't use them as an excuse to not check what you're overwriting! The point is that you should have checked that the output file doesn't exist. If you're toldfile exists: foo
oroverwrite 'foo'?
, it means you made a mistake and you should feel bad and be more careful. In particular, don't get into the habit of sayingy
if prompted to overwrite (arguably, the aliases should bealias cp='yes n | cp -i' mv='yes n | mv -i'
, but pressing Ctrl+C makes the output look better): if you did mean to overwrite, cancel the command, move or remove the output file, and run the command again.It's also important not to get into the habit of triggering those safeties because if you do, one day you'll be on a machine which doesn't have your configuration, and you'll lose data because the protections you were counting on aren't there.
noclobber
will only be set for interactive shells, since.bashrc
or.zshrc
is only read by interactive shells. Of course you shouldn't change shell options in a way that would affect scripts, since it could break those scripts.