Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
Ohmyzsh
Commits
b6d78df6
Commit
b6d78df6
authored
Oct 04, 2015
by
Andrew Janke
Browse files
clip*: add xsel support
parent
e4fdb083
Changes
2
Hide whitespace changes
Inline
Side-by-side
lib/clipboard.zsh
View file @
b6d78df6
...
...
@@ -31,15 +31,21 @@ function clipcopy() {
cat
$file
>
/dev/clipboard
fi
else
which xclip &>/dev/null
if
[[
$?
!=
0
]]
;
then
print
"clipcopy: Platform
$OSTYPE
not supported or xclip not installed"
>
&2
return
1
fi
if
[[
-z
$file
]]
;
then
xclip
-in
-selection
clipboard
if
which xclip &>/dev/null
;
then
if
[[
-z
$file
]]
;
then
xclip
-in
-selection
clipboard
else
xclip
-in
-selection
clipboard
$file
fi
elif
which xsel &>/dev/null
;
then
if
[[
-z
$file
]]
;
then
xsel
--clipboard
--input
else
cat
"
$file
"
| xsel
--clipboard
--input
fi
else
xclip
-in
-selection
clipboard
$file
print
"clipcopy: Platform
$OSTYPE
not supported or xclip/xsel not installed"
>
&2
return
1
fi
fi
}
...
...
@@ -50,6 +56,17 @@ function clipcopy() {
#
# clippaste - writes clipboard's contents to stdout
#
# clippaste | <command> - pastes contents and pipes it to another process
#
# clippaste > <file> - paste contents to a file
#
# Examples:
#
# # Pipe to another process
# clippaste | grep foo
#
# # Paste to a file
# clippaste > file.txt
function
clippaste
()
{
emulate
-L
zsh
if
[[
$OSTYPE
==
darwin
*
]]
;
then
...
...
@@ -57,11 +74,13 @@ function clippaste() {
elif
[[
$OSTYPE
==
cygwin
*
]]
;
then
cat
/dev/clipboard
else
which xclip &>/dev/null
if
[[
$?
!=
0
]]
;
then
print
"clipcopy: Platform
$OSTYPE
not supported or xclip not installed"
>
&2
if
which xclip &>/dev/null
;
then
xclip
-out
-selection
clipboard
elif
which xsel &>/dev/null
;
then
xsel
--clipboard
--output
else
print
"clipcopy: Platform
$OSTYPE
not supported or xclip/xsel not installed"
>
&2
return
1
fi
xclip
-out
-selection
clipboard
fi
}
\ No newline at end of file
}
plugins/copydir/copydir.plugin.zsh
View file @
b6d78df6
...
...
@@ -2,4 +2,4 @@
function
copydir
{
emulate
-L
zsh
print
-n
$PWD
| clipcopy
}
\ No newline at end of file
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment