如何在命令行中创建永久的 zsh 别名? [英] How to make a permanent zsh alias in command-line?

查看:41
本文介绍了如何在命令行中创建永久的 zsh 别名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想永久存储 zsh 别名.当我创建别名并关闭 ITerm 并重新打开时,它就消失了!

I want to permanently store zsh aliases. When I make an alias and shut down ITerm and reopen and it's gone!

alias mkcd="function _mkcd(){mkdir "$1"; cd "$1"} _mkcd"

mkcd Ken
zsh: command not found: mkcd

如何使其永久化?

推荐答案

在您的主目录中创建一个文件 .zshrc 如果它不存在并将别名添加到文件中.

Create a file .zshrc in your home directory if it does not exist already and add the alias to the file.

下次打开终端时.它将可用.

Next time when you open the terminal. It will be available.

要在同一个会话中使用它,只需通过运行命令 来获取 .zshrc 文件..zshrc 从您的主目录.

To use it in the same session, just source the .zshrc file by running the command . .zshrc from your home directory.

这篇关于如何在命令行中创建永久的 zsh 别名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆