我在OSX上,我需要把这样的东西,别名blah=“/usr/bin/blah”在配置文件中,但我不知道配置文件在哪里。
当前回答
cd /etc
sudo vi bashrc
添加如下内容:
alias ll="ls -lrt"
最后重启终端。
其他回答
脚本和程序的配置文件是~/。bashrc和使用Terminal时加载的配置文件是~/.bash_login。
我认为最好的方法是把所有东西都放在~/.bashrc中。
对于您的特定问题,只需输入(这将覆盖任何现有的~/.bashrc):
echo "alias blah=\"/usr/bin/blah\"" >>~/.bashrc
输入终端和~/。Bashrc文件将与您的新别名一起创建。之后,只需编辑文件,添加新的别名,函数,设置等。
您可能希望在主目录中编辑.bashrc文件。
我只是打开zshrc与sublime,并编辑它。
subl .zshrc
在sublime上加上这个:
alias blah="/usr/bin/blah"
在terminal中执行如下命令:
source ~/.zshrc
完成了。
要创建永久别名快捷方式,请将其放在.bash_profile文件中,并将.bashrc文件指向.bash_profile文件。遵循以下步骤(我正在创建一个名为bnode的别名命令来在ES6代码上运行babel transpiler):
Go to terminal command prompt and type “cd” (this will take you to the home directory. Note: even though your programming files may be located on your “D: drive”, your “.bash” files may be located on your “C: drive” ) To see the location of the home directory, type “pwd” (this will show you the home directory path and where the .bash files are probably located) To see all dot "." files in the home directory, type “ls -la” (this will show ALL files including hidden dot "." files) You will see 2 files: “.bash_profile” and “.bashrc” Open .bashrc file in VS Code Editor or your IDE and enter “source ~/.bash_profile” in first line (to point .bashrc file to .bash_profile) Open .bash_profile file in VS Code Editor and enter “alias bnode='./node_modules/.bin/babel-node'” (to create permanent bnode shortcut to execute as bash command) Save and close both files Now open the file you want to execute (index.js) and open in terminal command prompt and run file by using command “bnode index.js” Now your index.js file will execute but before creating bnode alias in .bash_profile file you would get the error "bash: bnode command not found" and it would not recognize and give errors on some ES6 code. Helpful link to learn about dotfiles: https://dotfiles.github.io/
我希望这能有所帮助!好运!
我认为这是正确的方式:
1)去终点站。开放的~ / . bashrc。如果不存在则添加
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
2)打开~/.bash_aliases。如果不存在:touch ~/。打开~/.bash_aliases &&
3)增加新的别名 -编辑.bash_aliases文件并重启终端或打印source ~/.bash_aliases - print echo "alias clr='clear'" >> ~/。Bash_aliases && source ~/。Bash_aliases你的别名是别名clr='clear'。
4)添加行源~/。bash_alias到~/。bash_profile文件。它需要在终端的每个init中加载别名。
推荐文章
- 安装tzdata非交互式
- 访问限制:'Application'类型不是API(必需库rt.jar的限制)
- 为什么在Mac OS X v10.9 (Mavericks)的终端中apt-get功能不起作用?
- 在Bash中检查变量是否存在于列表中
- 查看PS命令的全部输出
- 确保一次只运行一个shell脚本实例的快速方法
- 如何在Windows命令提示符下运行.sh ?
- “你有邮件”的消息在终端,os X
- 如何从命令行将每两行合并为一行?
- 如何复制在bash所有目录和文件递归?
- Mac OS X中的环境变量
- 在Bash命令提示符上添加git分支
- 匹配前后的Grep字符?
- 如何从macOS完全卸载蟒蛇
- 如何在Makefile中设置子进程的环境变量