在 Mac OS X 中运行终端时如何找出别名(在 bash 意义上)的定义位置 [英] How to find out where alias (in the bash sense) is defined when running Terminal in Mac OS X

查看:21
本文介绍了在 Mac OS X 中运行终端时如何找出别名(在 bash 意义上)的定义位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何找出系统上定义了别名的位置?我指的是在从 Mac OS X (10.6.3) 启动的终端会话中使用的那种别名.

How can I find out where an alias is defined on my system? I am referring to the kind of alias that is used within a Terminal session launched from Mac OS X (10.6.3).

例如,如果我在终端命令提示符下输入不带参数的 alias 命令,我会得到我设置的别名列表,例如:

For example, if I enter the alias command with no parameters at a Terminal command prompt, I get a list of aliases that I have set, for example:

alias mysql='/usr/local/mysql/bin/mysql'

但是,我已经在各种启动文件中使用 Spotlight 和 mdfind 在我的系统中进行了搜索,但到目前为止找不到定义此别名的位置.(我很久以前做的,没有写下我分配别名的地方).

However, I have searched all over my system using Spotlight and mdfind in various startup files and so far can not find where this alias has been defined. ( I did it a long time ago and didn't write down where I assigned the alias).

推荐答案

对于 OSX,这个 2 步序列对我来说效果很好,在定位我很久以前创建的别名时无法定位到预期的位置 (~/.zshrc).

For OSX, this 2-step sequence worked well for me, in locating an alias I'd created long ago and couldn't locate in expected place (~/.zshrc).

cweekly:~ $ which la
la: aliased to ls -lAh

cweekly:~$ grep -r ' ls -lAh' ~
/Users/cweekly//.oh-my-zsh/lib/aliases.zsh:alias la='ls -lAh'

啊哈!~/.oh-my-zsh/lib/aliases.zsh 中的隐藏".我在 .oh-my-zsh 中略过,但忽略了 lib/aliases.zsh.

Aha! "Hiding" in ~/.oh-my-zsh/lib/aliases.zsh. I had poked around a bit in .oh-my-zsh but had overlooked lib/aliases.zsh.

这篇关于在 Mac OS X 中运行终端时如何找出别名(在 bash 意义上)的定义位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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