bash - 别名有效,但无法手动运行命令
问题描述
alias git-repo="xdg-open '$(git config --get remote.origin.url | sed -e 's/:/\//g' -e 's/ssh\/\/\///g' -e 's/git@/https:\/\//g')'"
这个别名有效,但是当我尝试手动运行它时它不会:
xdg-open '$(git config --get remote.origin.url | sed -e 's/:/\//g' -e 's/ssh\/\/\///g' -e 's/git@/https:\/\//g')'
我究竟做错了什么?
解决方案
不应在引号中使用变量表达式。试试这个:
xdg-open $(git config --get remote.origin.url | sed -e "s/:/\//g" -e "s/ssh\/\/\///g" -e "s/git@/https:\/\//g")
推荐阅读
- http - http:// 是否被视为具有方案 http 和空路径的 URI?
- vuejs2 - 如何在单元测试中更新组件的属性?
- dart - 部分可见的底片 - 颤动
- angular - 自定义高阶可观察映射
- cassandra - Cassandra READ 请求丢弃
- delphi - 在 Delphi RAD Studio 10 中获取 TCombobox 的选定值
- ruby - NoMethodError in Welcome#show
- sql - 在 2 个查询之间添加一个空行
- php - 在不刷新表单内容的情况下,验证来自 ajax 的 php 表单中数据库的唯一键
- java - 没有类型作为方法参数的泛型 - 无法解析它的字段类型