ubuntu bashrc里alias加参数如何做?

通过function来做


示例:

alias ttt='test() { echo $1;}; test'

然后终端输入:ttt 33,就会输出33


如推送代码到远程服务器的命令(git push --no-thin aosp HEAD:refs/for/远程分支名):

git push --no-thin aosp HEAD:refs/for/mp_mt6737_trunk

(mp_mt6737_trunk是远程分支,当存在多个项目时,分支是不一样的,通过“git branch -a”可以查到,如何通过alias简化输入呢?),示例如下(通过 function +$1 实现):


alias pushcode='push() { git push --no-thin aosp HEAD:refs/for/$1;}; push'

使用时在终端输入:pushcode 远程分支名



完整示例:

查看远程分支:
git branch -a

remotes/m/mp_6737 -> aosp/mp_mt6737_trunk

推送代码
pushcode mp_mt6737_trunk



参考:http://forum.ubuntu.org.cn/viewtopic.php?t=148071

相关文章

目录前言一、创建Hadoop用户二、更新apt和安装Vim编辑器三、...
原文连接:https://www.cnblogs.com/yasmi/p/5192694.html ...
电脑重启后,打开VirtualBox,发现一直用的虚拟机莫名的消失...
参见:https://blog.csdn.net/weixin_38883338/article/deta...
Ubuntu 18.04 LTS 已切换到 Netplan 来配置网络接口。Netpla...
介绍每个 Web 服务都可以通过特定的 URL 在 Internet 上访问...