mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-11-12 21:39:48 +01:00
Add helper to get the value of an alias only
This commit is contained in:
parent
1120f97305
commit
dbef8b1a92
1 changed files with 30 additions and 0 deletions
|
@ -15,3 +15,33 @@ function take() {
|
|||
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"
|
||||
}
|
Loading…
Reference in a new issue