@ -21,6 +21,7 @@ function main
set -g OMF_PATH "$OMF_PATH_DEFAULT"
set -g OMF_CONFIG "$OMF_CONFIG_DEFAULT"
set -g OMF_CHANNEL stable
# Ensure repository URL ends with .git
set OMF_REPO_URI (echo $OMF_REPO_URI | command sed 's/\.git//').git
@ -33,6 +34,7 @@ function main
Install Oh My Fish
Options:
--channel=<channel> Download a specific release channel, either \"stable\" or \"dev\" (default is \"$OMF_CHANNEL\").
--config=<path> Put config in a specific path (default is $OMF_CONFIG_DEFAULT).
--help, -h Show this help message.
--noninteractive Disable interactive questions (assume no, use with --yes to assume yes).
@ -43,6 +45,15 @@ Options:
"
return 0
case '--channel=stable'
set -g OMF_CHANNEL stable
case '--channel=dev'
set -g OMF_CHANNEL dev
case '--channel=*'
abort "Unknown release channel \""(echo "$argv[1]" | command cut -d= -f2)"\"."
case '--config=*'
echo "$argv[1]" | command cut -d= -f2 | command sed -e "s#~#$HOME#" | read -g OMF_CONFIG
@ -139,12 +150,23 @@ end
# Downloads and installs the framework from GitHub.
function install_from_github
say "Using release channel \"$OMF_CHANNEL\"."
say "Cloning $OMF_REPO_BRANCH from $OMF_REPO_URI..."
if not command git clone -q --depth 1 - b $OMF_REPO_BRANCH $OMF_REPO_URI "$OMF_PATH"
if not command git clone -q -b " $OMF_REPO_BRANCH" " $OMF_REPO_URI" "$OMF_PATH"
abort "Error cloning repository!"
end
if test $OMF_CHANNEL = stable
# Get the commit for the latest release.
set -l hash (command git --git-dir "$OMF_PATH/.git" --work-tree "$OMF_PATH" rev-list --tags='v*' --max-count=1 ^ /dev/null)
# Get the release tag.
and set -l tag (command git --git-dir "$OMF_PATH/.git" --work-tree "$OMF_PATH" describe --tags $hash)
# Checkout the release.
and command git --git-dir "$OMF_PATH/.git" --work-tree "$OMF_PATH" checkout --quiet tags/$tag
or report error "Error getting latest version!"
end
set_git_remotes
end
@ -275,6 +297,8 @@ function install_config
test -f "$OMF_CONFIG/bundle";
or echo "theme default" > "$OMF_CONFIG/bundle"
test -f "$OMF_CONFIG/channel";
or echo $OMF_CHANNEL > "$OMF_CONFIG/channel"
test -f "$OMF_CONFIG/theme"
or echo "default" > "$OMF_CONFIG/theme"
@ -433,11 +457,17 @@ function is_version_compatible -a lhs rhs
set -q argv[2]
or return 1
# Sort the versions to get the lesser one.
set -l sorted (printf "$lhs\n$rhs\n" | command sort -n -t '.' -k 1,1 -k 2,2 -k 3,3 -k 4,4)
# Right-hand side must be the largest version.
test "$rhs" = (get_latest_version "$lhs" "$rhs")
end
# Left-hand side must be the smallest version.
test "$lhs" = "$sorted[1]"
# Returns the newest version from a given list of versions.
function get_latest_version
# Sort the version in descending order and output the top result.
for v in $argv
echo "$v"
end | command sort -r -n -t '.' -k 1,1 -k 2,2 -k 3,3 -k 4,4 | command head -n 1
end