ohmyzsh/plugins/omz-bootstrap/lib/download.zsh
Marc Cornellà f74c8b2941 Change parameter checks and other style fixes
This commits contains the following modifications:

- Change parameter checks from number of parameters (`$#`) to content length of
  each parameter ( `-z "$1"` ).
  A command called with an empty string in the first parameter *still* receives one
  parameter (`$# = 1`), while checking the string length will work either way.

- Change commands that may be aliased to use the builtin / non-modified
  command, using the 'command' prefix (e.g. `git` -> `command git`).

- Changed the initialization sequence of the plugin, from using a function
  to being inline in the script.
  It also uses the $0 parameter which is set when the script is sourced, and
  it contains the script filepath.
  Example: with command `source test.sh` -> in test.sh, `$0` will be 'test.sh'.

- Various style fixes, including missing space and some comments.
2014-06-10 14:26:53 +02:00

21 lines
547 B
Bash

_clone_git() {
local url=$1; local folder=$2
if [[ ! -d "$folder" ]]; then
command git clone $url $folder
fi
}
_download_plugin() {
[[ -z "$1" || -z "$2" ]] && return 1
local url=$1; local name=$2
_clone_git $url $ZSH_CUSTOM/plugins/$name
_map_put plugins $name enabled
}
_download_theme() {
[[ -z "$1" || -z "$2" ]] && return 1
local url=$1; local theme=$2
_clone_git $url $ZSH_CUSTOM/themes/$theme
command ln -s $ZSH_CUSTOM/themes/$theme/$theme.zsh-theme $ZSH_CUSTOM/$theme.zsh-theme
_map_put themes theme $theme
}