summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/clipboard.zsh2
-rw-r--r--lib/completion.zsh3
-rw-r--r--lib/functions.zsh14
-rw-r--r--lib/git.zsh21
-rw-r--r--lib/misc.zsh7
-rw-r--r--lib/termsupport.zsh7
6 files changed, 34 insertions, 20 deletions
diff --git a/lib/clipboard.zsh b/lib/clipboard.zsh
index 333f58dd8..6102f3324 100644
--- a/lib/clipboard.zsh
+++ b/lib/clipboard.zsh
@@ -54,7 +54,7 @@ function detect-clipboard() {
if [[ "${OSTYPE}" == darwin* ]] && (( ${+commands[pbcopy]} )) && (( ${+commands[pbpaste]} )); then
function clipcopy() { pbcopy < "${1:-/dev/stdin}"; }
function clippaste() { pbpaste; }
- elif [[ "${OSTYPE}" == cygwin* ]]; then
+ elif [[ "${OSTYPE}" == (cygwin|msys)* ]]; then
function clipcopy() { cat "${1:-/dev/stdin}" > /dev/clipboard; }
function clippaste() { cat /dev/clipboard; }
elif [ -n "${WAYLAND_DISPLAY:-}" ] && (( ${+commands[wl-copy]} )) && (( ${+commands[wl-paste]} )); then
diff --git a/lib/completion.zsh b/lib/completion.zsh
index c7db2eb7b..c932bc925 100644
--- a/lib/completion.zsh
+++ b/lib/completion.zsh
@@ -71,3 +71,6 @@ if [[ $COMPLETION_WAITING_DOTS = true ]]; then
zle -N expand-or-complete-with-dots
bindkey "^I" expand-or-complete-with-dots
fi
+
+# automatically load bash completion functions
+autoload -Uz bashcompinit && bashcompinit
diff --git a/lib/functions.zsh b/lib/functions.zsh
index 9f8736bd7..91e9cf895 100644
--- a/lib/functions.zsh
+++ b/lib/functions.zsh
@@ -3,11 +3,12 @@ function zsh_stats() {
}
function uninstall_oh_my_zsh() {
- env ZSH=$ZSH sh $ZSH/tools/uninstall.sh
+ env ZSH="$ZSH" sh "$ZSH/tools/uninstall.sh"
}
function upgrade_oh_my_zsh() {
- env ZSH=$ZSH sh $ZSH/tools/upgrade.sh
+ env ZSH="$ZSH" sh "$ZSH/tools/upgrade.sh"
+ rm -rf "$ZSH/log/update.lock"
}
function take() {
@@ -21,7 +22,7 @@ function open_command() {
case "$OSTYPE" in
darwin*) open_cmd='open' ;;
cygwin*) open_cmd='cygstart' ;;
- linux*) ! [[ $(uname -a) =~ "Microsoft" ]] && open_cmd='xdg-open' || {
+ linux*) [[ "$(uname -r)" != *icrosoft* ]] && open_cmd='nohup xdg-open' || {
open_cmd='cmd.exe /c start ""'
[[ -e "$1" ]] && { 1="$(wslpath -w "${1:a}")" || return 1 }
} ;;
@@ -31,12 +32,7 @@ function open_command() {
;;
esac
- # don't use nohup on OSX
- if [[ "$OSTYPE" == darwin* ]]; then
- ${=open_cmd} "$@" &>/dev/null
- else
- nohup ${=open_cmd} "$@" &>/dev/null
- fi
+ ${=open_cmd} "$@" &>/dev/null
}
#
diff --git a/lib/git.zsh b/lib/git.zsh
index 640561e97..00cb00b19 100644
--- a/lib/git.zsh
+++ b/lib/git.zsh
@@ -12,11 +12,21 @@ function git_prompt_info() {
function parse_git_dirty() {
local STATUS
local -a FLAGS
- FLAGS=('--porcelain' '--ignore-submodules=dirty')
+ FLAGS=('--porcelain')
if [[ "$(command git config --get oh-my-zsh.hide-dirty)" != "1" ]]; then
if [[ "$DISABLE_UNTRACKED_FILES_DIRTY" == "true" ]]; then
FLAGS+='--untracked-files=no'
fi
+ case "$GIT_STATUS_IGNORE_SUBMODULES" in
+ git)
+ # let git decide (this respects per-repo config in .gitmodules)
+ ;;
+ *)
+ # if unset: ignore dirty submodules
+ # other values are passed to --ignore-submodules
+ FLAGS+="--ignore-submodules=${GIT_STATUS_IGNORE_SUBMODULES:-dirty}"
+ ;;
+ esac
STATUS=$(command git status ${FLAGS} 2> /dev/null | tail -n1)
fi
if [[ -n $STATUS ]]; then
@@ -189,3 +199,12 @@ function git_current_user_name() {
function git_current_user_email() {
command git config user.email 2>/dev/null
}
+
+# Output the name of the root directory of the git repository
+# Usage example: $(git_repo_name)
+function git_repo_name() {
+ local repo_path
+ if repo_path="$(git rev-parse --show-toplevel 2>/dev/null)" && [[ -n "$repo_path" ]]; then
+ echo ${repo_path:t}
+ fi
+}
diff --git a/lib/misc.zsh b/lib/misc.zsh
index 40ffa479d..61571afc9 100644
--- a/lib/misc.zsh
+++ b/lib/misc.zsh
@@ -22,7 +22,7 @@ env_default 'PAGER' 'less'
env_default 'LESS' '-R'
## super user alias
-alias _='sudo'
+alias _='sudo '
## more intelligent acking for ubuntu users
if which ack-grep &> /dev/null; then
@@ -31,10 +31,5 @@ else
alias afind='ack -il'
fi
-# only define LC_CTYPE if undefined
-if [[ -z "$LC_CTYPE" && -z "$LC_ALL" ]]; then
- export LC_CTYPE=${LANG%%:*} # pick the first entry from LANG
-fi
-
# recognize comments
setopt interactivecomments
diff --git a/lib/termsupport.zsh b/lib/termsupport.zsh
index aa14f3f07..f5e367fcb 100644
--- a/lib/termsupport.zsh
+++ b/lib/termsupport.zsh
@@ -75,8 +75,9 @@ function omz_termsupport_preexec {
title '$CMD' '%100>...>$LINE%<<'
}
-precmd_functions+=(omz_termsupport_precmd)
-preexec_functions+=(omz_termsupport_preexec)
+autoload -U add-zsh-hook
+add-zsh-hook precmd omz_termsupport_precmd
+add-zsh-hook preexec omz_termsupport_preexec
# Keep Apple Terminal.app's current working directory updated
@@ -99,7 +100,7 @@ if [[ "$TERM_PROGRAM" == "Apple_Terminal" ]] && [[ -z "$INSIDE_EMACS" ]]; then
}
# Use a precmd hook instead of a chpwd hook to avoid contaminating output
- precmd_functions+=(update_terminalapp_cwd)
+ add-zsh-hook precmd update_terminalapp_cwd
# Run once to get initial cwd set
update_terminalapp_cwd
fi