Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
oh-my-zsh
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
github
oh-my-zsh
Commits
f0f792fa
Unverified
Commit
f0f792fa
authored
Nov 30, 2021
by
Marc Cornellà
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(cli): add `omz version` command
parent
bf303965
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
0 deletions
+23
-0
cli.zsh
lib/cli.zsh
+23
-0
No files found.
lib/cli.zsh
View file @
f0f792fa
...
...
@@ -29,6 +29,7 @@ function _omz {
'reload:Reload the current zsh session'
'theme:Manage themes'
'update:Update Oh My Zsh'
'version:Show the version'
)
if
((
CURRENT
==
2
))
;
then
...
...
@@ -164,6 +165,7 @@ Available commands:
reload Reload the current zsh session
theme <command> Manage themes
update Update Oh My Zsh
version Show the version
EOF
}
...
...
@@ -777,3 +779,24 @@ function _omz::update {
[[
"
$zsh
"
=
-
*
||
-o
login
]]
&&
exec
-l
"
${
zsh
#-
}
"
||
exec
"
$zsh
"
fi
}
function
_omz::version
{
(
cd
"
$ZSH
"
# Get the version name:
# 1) try tag-like version
# 2) try name-rev
# 3) try branch name
local
version
version
=
$(
command
git describe
--tags
HEAD 2>/dev/null
)
\
||
version
=
$(
command
git name-rev
--no-undefined
--name-only
--exclude
=
"remotes/*"
HEAD 2>/dev/null
)
\
||
version
=
$(
command
git symbolic-ref
--quiet
--short
HEAD 2>/dev/null
)
# Get short hash for the current HEAD
local
commit
=
$(
command
git rev-parse
--short
HEAD 2>/dev/null
)
# Show version and commit hash
printf
"%s (%s)
\n
"
"
$version
"
"
$commit
"
)
}
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