bash 如何将当前路径复制到剪贴板?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15689912/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to copy to the clipboard the current path?
提问by ziiweb
How can I copy the current path in the bash terminal, using just one command?
如何仅使用一个命令复制 bash 终端中的当前路径?
采纳答案by Jo So
Needs xselinstalled:
需要xsel安装:
pwd | xsel -i
(if you don't want the trailing newline, use printf %s "$(pwd)" | xsel -i(mostly correct) pwd | head -c -1 | xsel -i(perfectly correct))
(如果您不想要尾随换行符,请使用printf %s "$(pwd)" | xsel -i(大部分正确)pwd | head -c -1 | xsel -i(完全正确))
Update August 2014: The xselprogram is broken: See my bugreport.
更新2014年8月:该xsel程序被打破:看我的错误报告。
Probably you can get along with xclipas well.
或许你们也可以相处xclip。
回答by stevenelberger
pwd | tr -d '\n' | pbcopy
Try this... Best I can come up with on my phone.
试试这个......我能在手机上想出的最好方法。

