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
7eeb1e19
Unverified
Commit
7eeb1e19
authored
Aug 10, 2021
by
Marc Cornellà
Browse files
refactor(lib): refactor take functions
parent
c2492881
Changes
1
Hide whitespace changes
Inline
Side-by-side
lib/functions.zsh
View file @
7eeb1e19
...
@@ -41,26 +41,27 @@ function mkcd takedir() {
...
@@ -41,26 +41,27 @@ function mkcd takedir() {
}
}
function
takeurl
()
{
function
takeurl
()
{
data
=
$(
mktemp
)
local
data thedir
curl
-L
$1
>
$data
data
=
"
$(
mktemp
)
"
tar
xf
$data
curl
-L
"
$1
"
>
"
$data
"
thedir
=
$(
tar
tf
$data
|
head
-1
)
tar
xf
"
$data
"
rm
$data
thedir
=
"
$(
tar
tf
"
$data
"
|
head
-1
)
"
cd
$thedir
rm
"
$data
"
cd
"
$thedir
"
}
}
function
takegit
()
{
function
takegit
()
{
git clone
$1
git clone
"
$1
"
cd
$(
basename
${
1
%%.git
}
)
cd
"
$(
basename
${
1
%%.git
}
)
"
}
}
function
take
()
{
function
take
()
{
if
[[
$1
=
~ ^
(
https?|ftp
)
.
*
\.
tar
\.
(
gz|bz2|xz
)
$
]]
;
then
if
[[
$1
=
~ ^
(
https?|ftp
)
.
*
\.
tar
\.
(
gz|bz2|xz
)
$
]]
;
then
takeurl
$1
takeurl
"
$1
"
elif
[[
$1
=
~ ^
([
A-Za-z0-9]
\+
@|https?|git|ssh|ftps?|rsync
)
.
*
\.
git/?
$
]]
;
then
elif
[[
$1
=
~ ^
([
A-Za-z0-9]
\+
@|https?|git|ssh|ftps?|rsync
)
.
*
\.
git/?
$
]]
;
then
takegit
$1
takegit
"
$1
"
else
else
takedir
$1
takedir
"
$@
"
fi
fi
}
}
...
...
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