echo SHELL
因为当前shell 默认是的zsh
所以要在配置里更改alias需要在~/.zashrc里面 而不是在 ~/.bashrc里面
否则会报如下错误
/home/amerrnath/.bashrc:17: command not found: shopt
/home/amerrnath/.bashrc:25: command not found: shopt
/home/amerrnath/.bashrc:109: command not found: shopt
/usr/share/bash-completion/bash_completion:35: parse error near `]]’
Switch to bash:
exec bash
Then
source ~/.bashrc
Switching to bash will not effect on new terminal window. But if you want to switch current window to zsh.
Switch to zsh:
exec zsh
bash/zsh中alias如何组合多个命令
参考:https://segmentfault.com/q/1010000000202221
以上但是似乎不行?
其中cd '${1}
表示cd /xxx/xxx/ ${1}
就是/xxx/xxx/
0,1,2分别代表你的命令和后面的第一个,第二个参数
比如你的命令叫test.sh,然后需要填入参数-f test进行运行
完整命令
test.sh -f test
那{0}就是test.sh
{1}就是-f
{2}就是test
或者
main.sh 25 43 当执行脚本main.sh时候,
后面接了25 43 参数,
那么$0代表第一个参数main.sh $1代表25 $2代表43
正确做法应该写在函数内拼接多个命令:
sudo nano ~/.zshrc
在文件最后加入:
bb(){
cd ${1}
ls
pwd
}
alias cdd='bb'
也可以加入 ls重命名为ls-lah
alias ls='ls -lah --color=auto'
-a 显示所有文件,包括
隐藏
文件(.xxx)-l 显示详细信息
-d 查看目录属性
-h 人性化显示文件大小
-i 显示inode
更新配置
. ~/.zshrc
输入bb
或者ccd
成功