简体   繁体   English

如何在复制到剪贴板时删除换行符

[英]How to remove newline character when copying to clipboard

I'm using alot readlink command, and what I'm trying to do is to create a short cut for this. 我正在使用很多readlink命令,而我正在尝试做的是为此创建一个捷径。 I've added this to ~/.bashrc 我已将此添加到~/.bashrc

rl() { readlink -f "$1" | xclip -i -selection clipboard; }

But when I want to paste it by pressing ctrl+v , terminal is trying to execute a command. 但是当我想通过按ctrl+v粘贴它时,终端正在尝试执行命令。 Which is not what I want, I suspect it because there is a newline character at the end. 这不是我想要的,我怀疑它是因为最后有一个换行符。

So the question is how to make this command copy to the clipboard and make the cursor stay at the the same line when pasting it? 那么问题是如何将此命令复制到剪贴板并使光标在粘贴时保持在同一行?

Just found an answer: 刚刚找到答案:

  -n, --no-newline do not output the trailing newline 
rl() { readlink -fn "$1" | xclip -i -selection clipboard; }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM