I am trying to create a fish shell function that trim new lines from input and then input the clipboard Will copy.
How do I write this function so that it will happen;
- Process pipeline input (it works now)
- The function was pipe input
- In this case, immediately exit that a value argument Or pipe line, will now exit without any value in the
tr pipelineCode:
< Code> Function Copy - Copy 'trim new lines and clipboard' tr -d '\ n' | Pbcopy end
Updates that improve new lines:
Function Copy - Copy 'trim new lines and copy to clipboard' cat $ argv ^ / dev / null | While reading -l line set argv $ argv $ line end test- "$ argv"; And $ argv echo -n $ i finally return to me. Tr-d '\ n' | Pbcopy endThis was a great challenge, but with some small things it was possible. If you type
copy without any arguments, it will wait your input indefinitely.If you do not care about multi-line copy
| You can also removeread and thencopy before tr-d '\ n' . Because readings by Newline end, then it will automatically accept up to the first new line, for example,copy \ nme will be copied onlycopy .code:
Copy the function - copy 'trim new lines and clipboard' cat $ argv ^ / dev / null | Tr-d '\ n' | Reading-L input set-ql input; Or set -l input $ argv if test -n "$ input" $ input echo. Tr-d '\ n' | Pbcopy End EndExample:
one ?? Goo copy \ nme | Copy the clipboard: copy â ?? Copy copy \ nyou clipboard: copyyou â ?? ¤ echo. Copy clipboard: copy one ?? ¤ Copy (Waiting indefinitely ...)
Comments
Post a Comment