I work on a lot of websites and often there is a blog directory. Issue is whenever there is i get this
➜ project-name git:(master) ✗ git log
zsh: correct 'log' to 'blog' [nyae]?
Can I just force it to never ever suggest git blog?
Add unsetopt correct_all to your zsh dotfiles (e.g., ~/.zshrc). This will disable this behavior for all corrections.
Seems like this worked from the comment from #gairfowl
autoload -U compinit && compinit
I'm using oh-my-zsh so I'm surprised this didnt work out of the box.
Related
fzf ctrl+r doesn't work anymore after I started to use zsh vi-mode. My zshrc file is here:
function zvm_config() {
ZVM_LINE_INIT_MODE=$ZVM_MODE_INSERT
ZVM_VI_INSERT_ESCAPE_BINDKEY=jk
}
source /opt/homebrew/opt/zplug/init.zsh
zplug "jeffreytse/zsh-vi-mode"
# Install plugins if there are plugins that have not been installed
if ! zplug check --verbose; then
printf "Install? [y/N]: "
if read -q; then
echo; zplug install
fi
fi
# Then, source plugins and add commands to $PATH
zplug load --verbose
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
If I separately run source ~/.fzf.zsh then it will work.
fzf keybindings seem to conflict with vi-mode. As mentioned here, Loading the fzf key bindings after loading the vi-mode plugin is one way to work around this issue. In my case, I was using oh-my-zsh and adding the fzf plugin after vi-mode in the plugins list fixed the issue.
I created a a CLI tool with PicoCLI. The library generates an auto-complete script. This works fine when sourced manually, i.e.
source /path/to/script
But when I put the line into ~/.zshrc it doesn't. No errors, just doesn't work. Tried different things like . /path/to/script, source <(cat /path/to/script), added execution permissions, added autoload -U +X compinit && compinit & autoload -U +X bashcompinit && bashcompinit (see here). No success, no idea what's wrong. According to the docs it should be fine (see here).
Thanks for any suggestion!
I'm aware there are many copies of this question here, but all of their answers recommend adding
ZSH_DISABLE_COMPFIX="true"
to the top of my ~/.zshrc file. I have done this and still every time I open zsh I am greeted with
zsh compinit: insecure directories, run compaudit for list.
Ignore insecure directories and continue [y] or abort compinit [n]?
It seems that others asking this question didn't have the quotes around the true in the first sample, but I have added that. I have also run
source ~/.zshrc
Which as far as I can tell reloads the zshrc configuration. This still gives me the above warning. I'm not sure if any of these details could be relevant but I'll include them:
This is a new zsh installation on an M1 Macbook running Big Sur
I also have Oh My Zsh installed on top of zsh
I earlier ran several export commands to set my nvm directory but I don't think that would be relevant
Any idea how to resolve this permissions issue? Thanks
Edit:
compaudit returns
/usr/local/share/zsh/site-functions
/usr/local/share/zsh
Also, here are the other nonstandard entries in my ~/.zshrc file (in order, but there is some built-in stuff inbetween):
ZSH_DISABLE_COMPFIX="true"
export NVM_DIR=~/.nvm
source $(brew --prefix nvm)/nvm.sh
export PATH="/usr/local/opt/icu4c/bin:$PATH"
export PATH="/usr/local/opt/icu4c/sbin:$PATH"
export PATH=$HOME/bin:/usr/local/bin:$PATH
plugins=(git)
source $ZSH/oh-my-zsh.sh
zstyle :compinstall filename '/Users/jonahsaltzman/.zshrc'
# End of lines configured by zsh-newuser-install
# The following lines were added by compinstall
autoload -Uz compinit
compinit
First of all, one problem here is that you’re running compinit twice: Once through OMZ (Oh My Zsh) – when you do source $ZSH/oh-my-zsh.sh – and once manually. You have two options to fix this:
If you want to keep using OMZ, then you should remove the bottom 3 lines from your .zshrc file.
If you want to stop using OMZ, then instead, you should remove both plugins=(git) and source $ZSH/oh-my-zsh.sh
Secondly, note that $ZSH_DISABLE_COMPFIX is specific to OMZ and is not used by compinit itself. It has no effect when you call compinit manually. You can remove it from your .zshrc
Finally, compinit doesn’t show that warning for nothing. Rather than suppress it, you should instead do chmod g-w,o-w on the directories listed by compaudit. That will fix the problem and make the warning go away.
You want to use:
compinit -u
To disable the annoying permissions test. It doesn't add any security on macOS. See the documentation at zshcompsys(1).
I'm trying to move .zshrc to a folder where I keep this kind of files synced with Github.
But now whenever I start a zsh session it doesn't use that config file.
Assuming I changed the file to ~/.dotfiles how can I add ~/.dotfiles/.zshrc to the PATH(?!) to make zsh start with that config?
Doing source ~./dotfiles/.zshrc only works for that session. Doesn't work anymore if I close the terminal.
You can symlink:
ln -s /path/to/original /path/to/symlink
For the zshrc you can do something like:
ln -s ~/.dotiles/.zshrc ~/.zshrc
One alternative to a symlink is to put this in ~/.zshenv:
ZDOTDIR=~/.dotfiles
If you want .zshenv in ~/.dotfiles as well, you can look into setting ZDOTDIR in one of the global configuration files (/etc/zshenv is a good choice).
Alternatively, you can do what I do and use GNU Stow. I've got my dotfiles in a repository, one subdirectory per category, like so:
dotfilerepo/zsh/.zshrc
dotfilerepo/zsh/.zlogin
dotfilerepo/git/.gitconfig
dotfilerepo/vim/.vimrc
then I can cd into repo and do stow zsh and it'll create a symlink from ~/.zshrc to repo/zsh/.zshrc, another from zsh/.zlogin to ~/.zlogin. stow vim to create symlinks from the vim subdirectory to ~, etc.
I've got a script, install-linkfarm, that does all the stow commands so when I move onto a new machine, I clone my repo, cd to it and run install-linkfarm and am good to go.
You can put this in ~/.zshrc, even as its entire contents:
if [ -r ~/.dotfiles/.zshrc ]; then
source ~/.dotfiles/.zshrc
fi
Please use the export command mentioned below to solve your problem.
export ZDOTDIR=$HOME/.dotfiles
In Linux, you can check if your zsh is loading /etc/zsh/zshrc, and edit it.
If that's the case, redirect this to your custom script by adding:
sh $HOME/.dotfiles/zshrc
Here is an interesting hack that doesn't require you to use sym-links.
In your .xsession, (or .*wmrc) have the following:
xterm -e 'zsh -c ". ~/.dotfiles/.zshrc; zsh"'.
instead of just:
xterm
Make sure to put the -e at the end after all of your other xterm options.
Zsh has a feature that lets it prompt for corrections to files in the current directory. Eg, if I say cd bar when I mean to say cd baz, then zsh will say: zsh: correct 'bar' to 'baz' [nyae]?
Normally, this works fine. However, sudo seems to mess things up. Specifically, suppose I want to version control my apache2 directory with git. I would type something like sudo git add . This is the correct command to run. However, zsh would prompt me with zsh: correct 'git' to '.git' [nyae]? as if it didn't know that git was a command, so it thought I was trying to refer to the .git folder.
Why is this happening? How can I get it to stop prompting me in those situations?
Thanks!
EDIT: It seems like zsh, by default, will consider all arguments to a command to be files or directories. However, I know that there is some functionality to extend this. For instance, if I type git sttab, then zsh will complete it to stash, status, or stripspace (with documentation on each of those). I would, ideally, like zsh to keep providing tips like these even with something like sudo (so, I would rather not do a nocorrect). How do I customize that functionality in zsh?
Either use nocorrect before the command itself, or define an alias
alias sudo="nocorrect sudo"