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
dbef8b1a
Commit
dbef8b1a
authored
May 05, 2012
by
mapc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add helper to get the value of an alias only
parent
1120f973
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
0 deletions
+30
-0
functions.zsh
lib/functions.zsh
+30
-0
No files found.
lib/functions.zsh
View file @
dbef8b1a
...
@@ -15,3 +15,33 @@ function take() {
...
@@ -15,3 +15,33 @@ function take() {
cd
$1
cd
$1
}
}
#
# Get the value of an alias.
#
# Arguments:
# 1. alias - The alias to get its value from
# STDOUT:
# The value of alias $1 (if it has one).
# Return value:
# 0 if the alias was found,
# 1 if it does not exist
#
function
alias_value
()
{
alias
"
$1
"
|
sed
"s/^
$1
='
\(
.*
\)
'
$/
\1
/"
test
$(
alias
"
$1
"
)
}
#
# Try to get the value of an alias,
# otherwise return the input.
#
# Arguments:
# 1. alias - The alias to get its value from
# STDOUT:
# The value of alias $1, or $1 if there is no alias $1.
# Return value:
# Always 0
#
function
try_alias_value
()
{
alias_value
"
$1
"
||
echo
"
$1
"
}
\ 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