Alias是linux中常用的别名命令,这么好的东东在mac中自然不会舍去。当有一些比较复杂的命令需要经常执行的时候,alias对效率的提升立竿见影。我的博客:http://blog.ithomer.net
示例1:
例如我就经常使用goagent,每次都要执行”python /Users/xhat/Downloads/goagent/local/proxy.py”,这是一个很痛苦的过程,往往cd半天,有时候甚至忘了路径。效率极低。那么通过alias现在可以这样改进:
1.编辑~/.bash_profile,通常这个文件是不存在的,那么新建它,有的话就打开修改添加。
2.vim ~/.bash_profile 添加alias go=”python /Users/xhat/Downloads/goagent/local/proxy.py”,这里需要注意的是,等号前后不能出现空格。
3.bash下执行”source ~/.bash_profile“,此条命令是使bash重新载入配置令刚才命令生效。
4.以后需要使用上述复杂命令,只需在bash中输入“go”即可。
要查看自定义的alias命令,直接在bash中输入alias即可查看。
示例2:
ubuntu 里面有命令“ll”,直接代替了“ls -l”命令,使用起来非常方便,但是Mac Book Pro系统默认没有“ll”命令,于是需要自己用别名(alias)来重设。
alias 别名步骤如下:
1) sudo vim /etc/profile(打开/etc/profile文件,并设为可写权限,并用管理员sudo权限修改)
2)alias ll=’ls -l’ (重置别名)
3)保存
4)source /etc/profile (source命令是修改文件/etc/profile生效)
5) 在shell终端,输入“alias”命令查看,如上图,或直接输入“ll”查看结果
分享到:
相关推荐
bash shell高级编程
主要是一份bash shell 4.2 的源码,共享给大家
Bash Shell 管理Linux
Cameron Newham and Bill Rosenblattham 《Learning the bash shell》是比较好的一本入门级经典教材,学linux shell 的不妨下来看看,不过是英文版的。
Bash shell编程参考手册,Linux编程必备。
学习Bash Shell的经典教材,推荐
bash shell
Bash Shell 编程高级教程 (中文版)
Learning the bash Shell, 3rd Edition This refreshed edition serves as the most valuable guide yet to the bash shell. It's full of practical examples of shell commands and programs guaranteed to ...
实验十二 Bash Shell相关指令练习
里面介绍了bash shell 的操作,令你快速上手bash
《Learning the bash Shell,3rd Edition,by Cameron Newham》, bash 的权威指南,本书中文版本下载地址:http://download.csdn.net/source/2244004。内容预览: Chapter 1. bash Basics Chapter 2. Command-Line ...
learn bash shell~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Apress.Pro Bash Programming.Scripting the GNULinux Shell.2Ed.2015
linux bash shell脚本文件.sh,自动输入sudo的密码 在脚本中使用sudo命令,将密码保存在脚本中,不需要手动输入密码
Pro Bash Programming teaches you how to effectively utilize the Bash shell in your programming. The Bash shell is a complete programming language, not merely a glue to combine external Linux commands....
Learning the bash Shell Unix SHell Programming 第三版 非扫描高清版 带完整书签 学习Bash编程的最佳法宝
1.概述 (SYNOPSIS) ...3.描述 (DESCRIPTION) ...18. 简单命令扩展("SIMPLE COMMAND EXPANSION") 19. 命令执行(COMMAND EXECUTION) 20. 命令执行环境(COMMAND EXECUTION ENVIRONMENT) 21. 环境(ENVIRONMENT) 22. 退出
Learning the bash Shell(中文版第二版)