别名有效,但无法手动 运行 命令
Alias works but can't run the command manually
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")
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")