系统:debian8
shell:zsh
为了添加对python的支持,重新编译了vim7.4,安装到了/usr/local/vim74,而且在.zshrc里面设置了alias vim='/usr/local/vim74/bin/vim',在zsh里面用vim,一切正常。
但是用sudo vim的时候提示:sudo:vim:找不到命令,必须sudo /usr/local/vim74/bin/vim 这样才行,请问这是什么原因?
另外问两个相关的问题:
1、是否我用zsh就修改.zshrc就可以?不用管.bashrc?
2、alias都是在哪里定义的?.zshrc和.bashrc我都看了,只有一部分
When you execute
sudo vim
, vim is searched for in the root user's$PATH
but the global directory
/usr/bin:/usr/sbin There is no vim in
The correct approach is
sudo vim
时,是在root用户的$PATH
里查找vim然而全局目录
/usr/bin:/usr/sbin
里 并没有vim正确的做法是
然后使用
sudoedit filename
进行编辑PS:强烈反对编译时
Then use./configure --prefix=/usr/local/vim74
rrreeesudoedit filename
to edit🎜 🎜PS: We strongly oppose the practice of./configure --prefix=/usr/local/vim74
during compilation🎜You set it up
.zshrc
是~/.zshrc
. This setting is only effective for the current user.When Zsh starts, it will read the following configuration files in order:
/etc/zsh/zshenv
~/.zshenv
/etc/zsh/zprofile
/etc/profile
~/.zprofile
/etc/zsh/zshrc
~/.zshrc
/etc/zsh/zlogin
~/.zlogin
/etc/zsh/zlogout
~/.zlogout
From Zsh_(Simplified Chinese)
Your question is more about how to configure alias, please answer this. How to configure alias:
(1) Add a line in .bashrc: alias startvim='sudo /usr/local/vim74/bin/vim'
(2) Execute source .bashrc in the terminal to make the configuration take effect
After two steps, Just execute startvim again