mirror of
https://github.com/oh-my-fish/oh-my-fish
synced 2024-11-03 15:40:32 +00:00
[dpaste] Add compatibility with non GNU *nix
This commit is contained in:
parent
b3d40bb35d
commit
32c1a02690
@ -15,21 +15,31 @@ function __dpaste_set_defaults
|
|||||||
if [ -z $dpaste_url ]
|
if [ -z $dpaste_url ]
|
||||||
set -g dpaste_url 'https://dpaste.de/api/?format=url'
|
set -g dpaste_url 'https://dpaste.de/api/?format=url'
|
||||||
end
|
end
|
||||||
|
set -g __dpaste_send_url $dpaste_url
|
||||||
end
|
end
|
||||||
|
|
||||||
function __dpaste_send
|
function __dpaste_send
|
||||||
# echo $dpaste_url >&2
|
|
||||||
# echo $__dpaste_send_url >&2
|
|
||||||
curl -F "$dpaste_keyword=<-" $__dpaste_send_url
|
curl -F "$dpaste_keyword=<-" $__dpaste_send_url
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function __sed
|
||||||
|
set sed_extended_regexp_flag -r
|
||||||
|
switch (uname)
|
||||||
|
case *BSD
|
||||||
|
set sed_extended_regexp_flag -E
|
||||||
|
case Darwin
|
||||||
|
set sed_extended_regexp_flag -E
|
||||||
|
end
|
||||||
|
sed $sed_extended_regexp_flag $argv
|
||||||
|
end
|
||||||
|
|
||||||
function __dpaste_parse_expires
|
function __dpaste_parse_expires
|
||||||
set expires_spec "-t $__dpaste_expires_choises"
|
set expires_spec "-t $__dpaste_expires_choises"
|
||||||
set expires (echo $argv | sed -r "s/.*$expires_spec.*/\1/" | sed 's/hour/3600/' | sed 's/week/604800/' | sed 's/month/2592000/')
|
set expires (echo $argv | __sed "s/.*$expires_spec.*/\1/" | sed 's/hour/3600/' | sed 's/week/604800/' | sed 's/month/2592000/')
|
||||||
if [ -z (echo $expires | sed -r "s/$__dpaste_expires_choises//") ]
|
if [ -z (echo $expires | __sed "s/$__dpaste_expires_choises//") ]
|
||||||
set __dpaste_send_url "$__dpaste_send_url&expires=$expires"
|
set __dpaste_send_url "$__dpaste_send_url&expires=$expires"
|
||||||
end
|
end
|
||||||
echo $argv | sed -r "s/$expires_spec//" | xargs
|
echo $argv | __sed "s/$expires_spec//" | xargs
|
||||||
end
|
end
|
||||||
|
|
||||||
function __dpaste_help
|
function __dpaste_help
|
||||||
@ -54,7 +64,6 @@ end
|
|||||||
|
|
||||||
function dpaste
|
function dpaste
|
||||||
__dpaste_set_defaults
|
__dpaste_set_defaults
|
||||||
set -g __dpaste_send_url $dpaste_url
|
|
||||||
__dpaste_parse_help $argv
|
__dpaste_parse_help $argv
|
||||||
or begin
|
or begin
|
||||||
set argv (__dpaste_parse_expires $argv)
|
set argv (__dpaste_parse_expires $argv)
|
||||||
|
Loading…
Reference in New Issue
Block a user