summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/compfix.zsh2
-rw-r--r--lib/correction.zsh1
-rw-r--r--lib/functions.zsh26
-rw-r--r--lib/git.zsh34
-rw-r--r--lib/history.zsh13
-rw-r--r--lib/misc.zsh6
-rw-r--r--lib/prompt_info_functions.zsh2
-rw-r--r--lib/spectrum.zsh2
-rw-r--r--lib/termsupport.zsh4
-rw-r--r--lib/theme-and-appearance.zsh5
10 files changed, 28 insertions, 67 deletions
diff --git a/lib/compfix.zsh b/lib/compfix.zsh
index 68decc1ed..b09b283f2 100644
--- a/lib/compfix.zsh
+++ b/lib/compfix.zsh
@@ -18,7 +18,7 @@ function handle_completion_insecurities() {
insecure_dirs=( ${(f@):-"$(compaudit 2>/dev/null)"} )
# If no such directories exist, get us out of here.
- (( ! ${#insecure_dirs} )) && return
+ [[ -z "${insecure_dirs}" ]] && return
# List ownership and permissions of all insecure directories.
print "[oh-my-zsh] Insecure completion-dependent directories detected:"
diff --git a/lib/correction.zsh b/lib/correction.zsh
index 3e1415a0b..c635236b5 100644
--- a/lib/correction.zsh
+++ b/lib/correction.zsh
@@ -1,4 +1,5 @@
if [[ "$ENABLE_CORRECTION" == "true" ]]; then
+ alias cp='nocorrect cp'
alias ebuild='nocorrect ebuild'
alias gist='nocorrect gist'
alias heroku='nocorrect heroku'
diff --git a/lib/functions.zsh b/lib/functions.zsh
index 7410ae645..9f8736bd7 100644
--- a/lib/functions.zsh
+++ b/lib/functions.zsh
@@ -11,23 +11,20 @@ function upgrade_oh_my_zsh() {
}
function take() {
- mkdir -p $1
- cd $1
+ mkdir -p $@ && cd ${@:$#}
}
function open_command() {
- emulate -L zsh
- setopt shwordsplit
-
local open_cmd
# define the open command
case "$OSTYPE" in
darwin*) open_cmd='open' ;;
cygwin*) open_cmd='cygstart' ;;
- linux*) [[ $(uname -a) =~ "Microsoft" ]] && \
- open_cmd='cmd.exe /c start' || \
- open_cmd='xdg-open' ;;
+ linux*) ! [[ $(uname -a) =~ "Microsoft" ]] && open_cmd='xdg-open' || {
+ open_cmd='cmd.exe /c start ""'
+ [[ -e "$1" ]] && { 1="$(wslpath -w "${1:a}")" || return 1 }
+ } ;;
msys*) open_cmd='start ""' ;;
*) echo "Platform $OSTYPE not supported"
return 1
@@ -36,9 +33,9 @@ function open_command() {
# don't use nohup on OSX
if [[ "$OSTYPE" == darwin* ]]; then
- $open_cmd "$@" &>/dev/null
+ ${=open_cmd} "$@" &>/dev/null
else
- nohup $open_cmd "$@" &>/dev/null
+ nohup ${=open_cmd} "$@" &>/dev/null
fi
}
@@ -54,8 +51,7 @@ function open_command() {
# 1 if it does not exist
#
function alias_value() {
- alias "$1" | sed "s/^$1='\(.*\)'$/\1/"
- test $(alias "$1")
+ (( $+aliases[$1] )) && echo $aliases[$1]
}
#
@@ -83,7 +79,7 @@ function try_alias_value() {
# 0 if the variable exists, 3 if it was set
#
function default() {
- test `typeset +m "$1"` && return 0
+ (( $+parameters[$1] )) && return 0
typeset -g "$1"="$2" && return 3
}
@@ -97,8 +93,8 @@ function default() {
# 0 if the env variable exists, 3 if it was set
#
function env_default() {
- env | grep -q "^$1=" && return 0
- export "$1=$2" && return 3
+ (( ${${(@f):-$(typeset +xg)}[(I)$1]} )) && return 0
+ export "$1=$2" && return 3
}
diff --git a/lib/git.zsh b/lib/git.zsh
index b55b762d7..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
- 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 7d4e59d00..52e45bf4c 100644
--- a/lib/history.zsh
+++ b/lib/history.zsh
@@ -1,7 +1,6 @@
## History wrapper
function omz_history {
- # Delete the history file if `-c' argument provided.
- # This won't affect the `history' command output until the next login.
+ local clear list
zparseopts -E c=clear l=list
if [[ -n "$clear" ]]; then
@@ -12,18 +11,18 @@ function omz_history {
# if -l provided, run as if calling `fc' directly
builtin fc "$@"
else
- # otherwise, call `fc -l 1` to show all available
- # history (and pass additional parameters)
- builtin fc "$@" -l 1
+ # unless a number is provided, show all history events (starting from 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' ;;
- *) alias history='omz_history' ;;
+ "") alias history='omz_history' ;;
+ *) alias history="omz_history -t '$HIST_STAMPS'" ;;
esac
## History file configuration
diff --git a/lib/misc.zsh b/lib/misc.zsh
index 3052b7710..b30822b50 100644
--- a/lib/misc.zsh
+++ b/lib/misc.zsh
@@ -18,13 +18,11 @@ fi
## jobs
setopt long_list_jobs
-## pager
-env_default PAGER 'less'
-env_default LESS '-R'
+env_default 'PAGER' 'less'
+env_default 'LESS' '-R'
## super user alias
alias _='sudo'
-alias please='sudo'
## more intelligent acking for ubuntu users
if which ack-grep &> /dev/null; then
diff --git a/lib/prompt_info_functions.zsh b/lib/prompt_info_functions.zsh
index 335c02a3d..1d5c23e41 100644
--- a/lib/prompt_info_functions.zsh
+++ b/lib/prompt_info_functions.zsh
@@ -12,7 +12,7 @@
# 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 {
+ virtualenv_prompt_info jenv_prompt_info {
return 1
}
diff --git a/lib/spectrum.zsh b/lib/spectrum.zsh
index 87092d8ae..312ab2248 100644
--- a/lib/spectrum.zsh
+++ b/lib/spectrum.zsh
@@ -1,7 +1,7 @@
#! /bin/zsh
# A script to make using 256 colors in zsh less painful.
# P.C. Shyamshankar <sykora@lucentbeing.com>
-# Copied from http://github.com/sykora/etc/blob/master/zsh/functions/spectrum/
+# Copied from https://github.com/sykora/etc/blob/master/zsh/functions/spectrum/
typeset -AHg FX FG BG
diff --git a/lib/termsupport.zsh b/lib/termsupport.zsh
index 871ab28df..aa14f3f07 100644
--- a/lib/termsupport.zsh
+++ b/lib/termsupport.zsh
@@ -21,7 +21,7 @@ function title {
print -Pn "\e]2;$2:q\a" # set window name
print -Pn "\e]1;$1:q\a" # set tab name
;;
- screen*)
+ screen*|tmux*)
print -Pn "\ek$1:q\e\\" # set screen hardstatus
;;
*)
@@ -80,7 +80,7 @@ preexec_functions+=(omz_termsupport_preexec)
# Keep Apple Terminal.app's current working directory updated
-# Based on this answer: http://superuser.com/a/315029
+# Based on this answer: https://superuser.com/a/315029
# With extra fixes to handle multibyte chars and non-UTF-8 locales
if [[ "$TERM_PROGRAM" == "Apple_Terminal" ]] && [[ -z "$INSIDE_EMACS" ]]; then
diff --git a/lib/theme-and-appearance.zsh b/lib/theme-and-appearance.zsh
index 96f34aa81..6b6528273 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,9 +45,6 @@ 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