summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/directories.zsh10
-rw-r--r--lib/git.zsh34
-rw-r--r--lib/history.zsh4
-rw-r--r--lib/misc.zsh6
-rw-r--r--lib/prompt_info_functions.zsh19
-rw-r--r--lib/theme-and-appearance.zsh7
6 files changed, 33 insertions, 47 deletions
diff --git a/lib/directories.zsh b/lib/directories.zsh
index 14064b86f..cf87bd7e4 100644
--- a/lib/directories.zsh
+++ b/lib/directories.zsh
@@ -21,7 +21,15 @@ alias 9='cd -9'
alias md='mkdir -p'
alias rd=rmdir
-alias d='dirs -v | head -10'
+
+function d () {
+ if [[ -n $1 ]]; then
+ dirs "$@"
+ else
+ dirs -v | head -10
+ fi
+}
+compdef _dirs d
# List directory contents
alias lsa='ls -lah'
diff --git a/lib/git.zsh b/lib/git.zsh
index b92373153..640561e97 100644
--- a/lib/git.zsh
+++ b/lib/git.zsh
@@ -10,13 +10,10 @@ function git_prompt_info() {
# Checks if working tree is dirty
function parse_git_dirty() {
- local STATUS=''
+ local STATUS
local -a FLAGS
- FLAGS=('--porcelain')
+ FLAGS=('--porcelain' '--ignore-submodules=dirty')
if [[ "$(command git config --get oh-my-zsh.hide-dirty)" != "1" ]]; then
- if [[ $POST_1_7_2_GIT -gt 0 ]]; then
- FLAGS+='--ignore-submodules=dirty'
- fi
if [[ "$DISABLE_UNTRACKED_FILES_DIRTY" == "true" ]]; then
FLAGS+='--untracked-files=no'
fi
@@ -181,28 +178,6 @@ function git_prompt_status() {
echo $STATUS
}
-# Compares the provided version of git to the version installed and on path
-# Outputs -1, 0, or 1 if the installed version is less than, equal to, or
-# greater than the input version, respectively.
-function git_compare_version() {
- local INPUT_GIT_VERSION INSTALLED_GIT_VERSION i
- INPUT_GIT_VERSION=(${(s/./)1})
- INSTALLED_GIT_VERSION=($(command git --version 2>/dev/null))
- INSTALLED_GIT_VERSION=(${(s/./)INSTALLED_GIT_VERSION[3]})
-
- for i in {1..3}; do
- if [[ $INSTALLED_GIT_VERSION[$i] -gt $INPUT_GIT_VERSION[$i] ]]; then
- echo 1
- return 0
- fi
- if [[ $INSTALLED_GIT_VERSION[$i] -lt $INPUT_GIT_VERSION[$i] ]]; then
- echo -1
- return 0
- fi
- done
- echo 0
-}
-
# Outputs the name of the current user
# Usage example: $(git_current_user_name)
function git_current_user_name() {
@@ -214,8 +189,3 @@ function git_current_user_name() {
function git_current_user_email() {
command git config user.email 2>/dev/null
}
-
-# This is unlikely to change so make it all statically assigned
-POST_1_7_2_GIT=$(git_compare_version "1.7.2")
-# Clean up the namespace slightly by removing the checker function
-unfunction git_compare_version
diff --git a/lib/history.zsh b/lib/history.zsh
index d8bbd41c4..52e45bf4c 100644
--- a/lib/history.zsh
+++ b/lib/history.zsh
@@ -12,12 +12,12 @@ function omz_history {
builtin fc "$@"
else
# unless a number is provided, show all history events (starting from 1)
- [[ ${@[-1]} = *[0-9]* ]] && builtin fc -l "$@" || builtin fc -l "$@" 1
+ [[ ${@[-1]-} = *[0-9]* ]] && builtin fc -l "$@" || builtin fc -l "$@" 1
fi
}
# Timestamp format
-case $HIST_STAMPS in
+case ${HIST_STAMPS-} in
"mm/dd/yyyy") alias history='omz_history -f' ;;
"dd.mm.yyyy") alias history='omz_history -E' ;;
"yyyy-mm-dd") alias history='omz_history -i' ;;
diff --git a/lib/misc.zsh b/lib/misc.zsh
index b30822b50..40ffa479d 100644
--- a/lib/misc.zsh
+++ b/lib/misc.zsh
@@ -1,7 +1,7 @@
-## Load smart urls if available
-# bracketed-paste-magic is known buggy in zsh 5.1.1 (only), so skip it there; see #4434
autoload -Uz is-at-least
-if [[ $ZSH_VERSION != 5.1.1 ]]; then
+
+# *-magic is known buggy in some versions; disable if so
+if [[ $DISABLE_MAGIC_FUNCTIONS != true ]]; then
for d in $fpath; do
if [[ -e "$d/url-quote-magic" ]]; then
if is-at-least 5.1; then
diff --git a/lib/prompt_info_functions.zsh b/lib/prompt_info_functions.zsh
index 1d5c23e41..5069c4b21 100644
--- a/lib/prompt_info_functions.zsh
+++ b/lib/prompt_info_functions.zsh
@@ -10,9 +10,15 @@
# Dummy implementations that return false to prevent command_not_found
# errors with themes, that implement these functions
# Real implementations will be used when the respective plugins are loaded
-function chruby_prompt_info hg_prompt_info pyenv_prompt_info \
- rbenv_prompt_info svn_prompt_info vi_mode_prompt_info \
- virtualenv_prompt_info jenv_prompt_info {
+function chruby_prompt_info \
+ rbenv_prompt_info \
+ hg_prompt_info \
+ pyenv_prompt_info \
+ svn_prompt_info \
+ vi_mode_prompt_info \
+ virtualenv_prompt_info \
+ jenv_prompt_info \
+{
return 1
}
@@ -22,10 +28,13 @@ function rvm_prompt_info() {
[ -f $HOME/.rvm/bin/rvm-prompt ] || return 1
local rvm_prompt
rvm_prompt=$($HOME/.rvm/bin/rvm-prompt ${=ZSH_THEME_RVM_PROMPT_OPTIONS} 2>/dev/null)
- [[ "${rvm_prompt}x" == "x" ]] && return 1
- echo "${ZSH_THEME_RVM_PROMPT_PREFIX:=(}${rvm_prompt}${ZSH_THEME_RVM_PROMPT_SUFFIX:=)}"
+ [[ -z "${rvm_prompt}" ]] && return 1
+ echo "${ZSH_THEME_RUBY_PROMPT_PREFIX}${rvm_prompt}${ZSH_THEME_RUBY_PROMPT_SUFFIX}"
}
+ZSH_THEME_RVM_PROMPT_OPTIONS="i v g"
+
+
# use this to enable users to see their ruby version, no matter which
# version management system they use
function ruby_prompt_info() {
diff --git a/lib/theme-and-appearance.zsh b/lib/theme-and-appearance.zsh
index 96f34aa81..5016d86ca 100644
--- a/lib/theme-and-appearance.zsh
+++ b/lib/theme-and-appearance.zsh
@@ -19,7 +19,7 @@ if [[ "$DISABLE_LS_COLORS" != "true" ]]; then
# coreutils, so prefer it to "gls".
gls --color -d . &>/dev/null && alias ls='gls --color=tty'
colorls -G -d . &>/dev/null && alias ls='colorls -G'
- elif [[ "$OSTYPE" == darwin* ]]; then
+ elif [[ "$OSTYPE" == (darwin|freebsd)* ]]; then
# this is a good alias, it works by default just using $LSCOLORS
ls -G . &>/dev/null && alias ls='ls -G'
@@ -45,11 +45,10 @@ setopt prompt_subst
[[ -n "$WINDOW" ]] && SCREEN_NO="%B$WINDOW%b " || SCREEN_NO=""
-# Apply theming defaults
-PS1="%n@%m:%~%# "
-
# git theming default: Variables for theming the git info prompt
ZSH_THEME_GIT_PROMPT_PREFIX="git:(" # Prefix at the very beginning of the prompt, before the branch name
ZSH_THEME_GIT_PROMPT_SUFFIX=")" # At the very end of the prompt
ZSH_THEME_GIT_PROMPT_DIRTY="*" # Text to display if the branch is dirty
ZSH_THEME_GIT_PROMPT_CLEAN="" # Text to display if the branch is clean
+ZSH_THEME_RUBY_PROMPT_PREFIX="("
+ZSH_THEME_RUBY_PROMPT_SUFFIX=")"