我在OSX上,我需要把这样的东西,别名blah=“/usr/bin/blah”在配置文件中,但我不知道配置文件在哪里。
当前回答
在root - ex用户下创建bash_profile
/user/username/.bash_profile
打开的文件
vim ~ / . bash_profile
添加别名为ex.(保存并退出)
alias mydir="cd ~/Documents/dirname/anotherdir"
在新终端中输入mydir -它应该会打开
/user/username/Documents/dirname/anotherdir
其他回答
我需要运行Postgres数据库并为此目的创建一个别名。具体工作思路如下:
$ nano ~/.bash_profile
# in the bash_profile, insert the following texts:
alias pgst="pg_ctl -D /usr/local/var/postgres start"
alias pgsp="pg_ctl -D /usr/local/var/postgres stop"
$ source ~/.bash_profile
### This will start the Postgres server
$ pgst
### This will stop the Postgres server
$ pgsp
在我的.bashrc文件中,默认存在以下行:
# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
因此,在我的平台中.bash_aliases是默认情况下用于别名的文件(也是我使用的文件)。我不是OS X用户,但我猜如果你打开你的.bashrc文件,你就能识别出平台中常用的别名文件是什么。
回家吧 打开. bashrc 在文件底部创建别名 别名alias_name='要做的命令' 例如:alias cdDesktop='cd /Desktop' 保存文件 源. bashrc 源~ / . bashrc 打开终端(Ctrl+Alt+T),输入cdDesktop并按enter
如果你在~/中加入blah="/usr/bin/blah"。Bashrc,然后您可以在登录shell中使用$blah作为输入/usr/bin/blah的替代
在root - ex用户下创建bash_profile
/user/username/.bash_profile
打开的文件
vim ~ / . bash_profile
添加别名为ex.(保存并退出)
alias mydir="cd ~/Documents/dirname/anotherdir"
在新终端中输入mydir -它应该会打开
/user/username/Documents/dirname/anotherdir