调用后如何将OS X bash别名命令回显到终端(如!cmd)? [英] How to echo OS X bash alias' command to terminal after calling it (like !cmd)?

查看:104
本文介绍了调用后如何将OS X bash别名命令回显到终端(如!cmd)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在〜/ .bash_profile中定义了别名,例如。 alias vaguppro ='vagrant up --provision

In ~/.bash_profile aliases are defined, eg. alias vaguppro='vagrant up --provision

我想要的是的回声在终端中键入 vaguppro 后,请vagrant up --provision

What I want is an echo of vagrant up --provision after typing vaguppro in the terminal.

类似于when一种是在终端中键入 ls -hal ,然后再次键入!ls 。在执行之前,终端中会出现 ls -hal 的回声。

Similar to when one types ls -hal in the terminal, then again type !ls. There's an echo of ls -hal in the terminal before execution.

某些解决方案

vaguppro='vagrant up --provision'
alias vaguppro='echo $vaguppro && $vaguppro'

或下面的andlrc函数解决方案。

or andlrc's function solution below.

推荐答案

您可能会发现此快捷方式很有用:

You may find this shortcut useful:

   shell-expand-line (M-C-e)
          Expand the line as the shell does.  This performs alias and his‐
          tory expansion as well as all of the shell word expansions.  See
          HISTORY EXPANSION below for a description of history expansion.

换句话说,如果您写 vaguppro 然后在bash的默认Emacs模式下按 Ctrl + Alt + E ,它将在当前行中扩展别名并将其转换为浪费--provision 。然后,您可以按Enter键照常运行。

In other words, if you write vaguppro and press Ctrl+Alt+E in bash' default Emacs mode, it will expand aliases in the current line and turn it into vagrant up --provision. You can then press enter to run as usual.

这篇关于调用后如何将OS X bash别名命令回显到终端(如!cmd)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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