From f516b7c7f5e630ab04d31e5f7da5f443b21f173f Mon Sep 17 00:00:00 2001 From: drm00 Date: Fri, 25 Apr 2014 14:15:14 +0200 Subject: add check for colored ls on openbsd. (retry of #2225) --- lib/theme-and-appearance.zsh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/theme-and-appearance.zsh b/lib/theme-and-appearance.zsh index 0353f9db4..2c6d4912c 100644 --- a/lib/theme-and-appearance.zsh +++ b/lib/theme-and-appearance.zsh @@ -12,8 +12,11 @@ then # otherwise, leave ls as is, because NetBSD's ls doesn't support -G gls --color -d . &>/dev/null 2>&1 && alias ls='gls --color=tty' elif [[ "$(uname -s)" == "OpenBSD" ]]; then - # On OpenBSD, test if "colorls" is installed (this one supports colors); - # otherwise, leave ls as is, because OpenBSD's ls doesn't support -G + # On OpenBSD, "gls" (ls from GNU coreutils) and "colorls" (ls from base, + # with color and multibyte support) are available from ports. "colorls" + # will be installed on purpose and can't be pulled in by installing + # coreutils, so prefer it to "gls". + gls --color -d . &>/dev/null 2>&1 && alias ls='gls --color=tty' colorls -G -d . &>/dev/null 2>&1 && alias ls='colorls -G' else ls --color -d . &>/dev/null 2>&1 && alias ls='ls --color=tty' || alias ls='ls -G' -- cgit v1.2.3-70-g09d2 From a9e97e5d2da90cf3e2b4575888fe585972ebcc74 Mon Sep 17 00:00:00 2001 From: Andrew Janke Date: Sat, 14 Feb 2015 19:05:27 -0500 Subject: Remove terminalapp plugin and fold its implementation in to lib/termsupport.zsh. Replaces the redundant Terminal.app support that was recently added to termsupport. --- lib/termsupport.zsh | 43 +++++++++++++++++++++++------- plugins/terminalapp/terminalapp.plugin.zsh | 39 --------------------------- 2 files changed, 33 insertions(+), 49 deletions(-) delete mode 100644 plugins/terminalapp/terminalapp.plugin.zsh (limited to 'lib') diff --git a/lib/termsupport.zsh b/lib/termsupport.zsh index e1c2e2f93..da74dfdba 100644 --- a/lib/termsupport.zsh +++ b/lib/termsupport.zsh @@ -53,14 +53,37 @@ precmd_functions+=(omz_termsupport_precmd) preexec_functions+=(omz_termsupport_preexec) -# Runs before showing the prompt, to update the current directory in Terminal.app -function omz_termsupport_cwd { - # Notify Terminal.app of current directory using undocumented OSC sequence - # found in OS X 10.9 and 10.10's /etc/bashrc - if [[ $TERM_PROGRAM == Apple_Terminal ]] && [[ -z $INSIDE_EMACS ]]; then - local PWD_URL="file://$HOSTNAME${PWD// /%20}" - printf '\e]7;%s\a' "$PWD_URL" - fi -} +# Keep Apple Terminal.app's current working directory updated +# Based on this answer: http://superuser.com/a/315029 + +if [[ "$TERM_PROGRAM" == "Apple_Terminal" ]] && [[ -z "$INSIDE_EMACS" ]]; then + # Emits the control sequence to notify Terminal.app of the cwd + function update_terminalapp_cwd() { + # Identify the directory using a "file:" scheme URL, including + # the host name to disambiguate local vs. remote paths. + + # Percent-encode the pathname. + local URL_PATH='' + { + # Use LANG=C to process text byte-by-byte. + local i ch hexch LANG=C + for ((i = 1; i <= ${#PWD}; ++i)); do + ch="$PWD[i]" + if [[ "$ch" =~ [/._~A-Za-z0-9-] ]]; then + URL_PATH+="$ch" + else + hexch=$(printf "%02X" "'$ch") + URL_PATH+="%$hexch" + fi + done + } + + local PWD_URL="file://$HOST$URL_PATH" + printf '\e]7;%s\a' "$PWD_URL" + } -precmd_functions+=(omz_termsupport_cwd) + # Use a precmd hook instead of a chpwd hook to avoid contaminating output + precmd_functions+=(update_terminalapp_cwd) + # Run once to get initial cwd set + update_terminalapp_cwd +fi diff --git a/plugins/terminalapp/terminalapp.plugin.zsh b/plugins/terminalapp/terminalapp.plugin.zsh deleted file mode 100644 index 6e47ee188..000000000 --- a/plugins/terminalapp/terminalapp.plugin.zsh +++ /dev/null @@ -1,39 +0,0 @@ -# Set Apple Terminal.app resume directory -# based on this answer: http://superuser.com/a/315029 -# 2012-10-26: (javageek) Changed code using the updated answer - -# Tell the terminal about the working directory whenever it changes. -if [[ "$TERM_PROGRAM" == "Apple_Terminal" ]] && [[ -z "$INSIDE_EMACS" ]]; then - update_terminal_cwd() { - # Identify the directory using a "file:" scheme URL, including - # the host name to disambiguate local vs. remote paths. - - # Percent-encode the pathname. - local URL_PATH='' - { - # Use LANG=C to process text byte-by-byte. - local i ch hexch LANG=C - for ((i = 1; i <= ${#PWD}; ++i)); do - ch="$PWD[i]" - if [[ "$ch" =~ [/._~A-Za-z0-9-] ]]; then - URL_PATH+="$ch" - else - hexch=$(printf "%02X" "'$ch") - URL_PATH+="%$hexch" - fi - done - } - - local PWD_URL="file://$HOST$URL_PATH" - #echo "$PWD_URL" # testing - printf '\e]7;%s\a' "$PWD_URL" - } - - # Register the function so it is called whenever the working - # directory changes. - autoload add-zsh-hook - add-zsh-hook precmd update_terminal_cwd - - # Tell the terminal about the initial directory. - update_terminal_cwd -fi -- cgit v1.2.3-70-g09d2 From 3a18c33f17fb73ead87f3c532b3f5c21ea192e10 Mon Sep 17 00:00:00 2001 From: Andrew Janke Date: Sat, 14 Feb 2015 20:30:03 -0500 Subject: In termsupport, use LC_CTYPE instead of LANG to enable byte-by-byte text processing. LANG doesn't seem to actually work. --- lib/termsupport.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/termsupport.zsh b/lib/termsupport.zsh index da74dfdba..9ff8a811c 100644 --- a/lib/termsupport.zsh +++ b/lib/termsupport.zsh @@ -65,8 +65,8 @@ if [[ "$TERM_PROGRAM" == "Apple_Terminal" ]] && [[ -z "$INSIDE_EMACS" ]]; then # Percent-encode the pathname. local URL_PATH='' { - # Use LANG=C to process text byte-by-byte. - local i ch hexch LANG=C + # Use LC_CTYPE=C to process text byte-by-byte. + local i ch hexch LC_CTYPE=C for ((i = 1; i <= ${#PWD}; ++i)); do ch="$PWD[i]" if [[ "$ch" =~ [/._~A-Za-z0-9-] ]]; then -- cgit v1.2.3-70-g09d2 From 702ff1ca9167455d2df385790e9023f758d5fc33 Mon Sep 17 00:00:00 2001 From: Andrew Janke Date: Tue, 17 Feb 2015 00:49:53 -0500 Subject: Add support for non-UTF-8 encodings in caller's locale. --- lib/termsupport.zsh | 77 ++++++++++++++++++++++++++++++++++------------------- 1 file changed, 50 insertions(+), 27 deletions(-) (limited to 'lib') diff --git a/lib/termsupport.zsh b/lib/termsupport.zsh index 9ff8a811c..70b54301d 100644 --- a/lib/termsupport.zsh +++ b/lib/termsupport.zsh @@ -55,35 +55,58 @@ preexec_functions+=(omz_termsupport_preexec) # Keep Apple Terminal.app's current working directory updated # Based on this answer: http://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 - # Emits the control sequence to notify Terminal.app of the cwd - function update_terminalapp_cwd() { - # Identify the directory using a "file:" scheme URL, including - # the host name to disambiguate local vs. remote paths. - - # Percent-encode the pathname. - local URL_PATH='' - { - # Use LC_CTYPE=C to process text byte-by-byte. - local i ch hexch LC_CTYPE=C - for ((i = 1; i <= ${#PWD}; ++i)); do - ch="$PWD[i]" - if [[ "$ch" =~ [/._~A-Za-z0-9-] ]]; then - URL_PATH+="$ch" - else - hexch=$(printf "%02X" "'$ch") - URL_PATH+="%$hexch" - fi - done - } - - local PWD_URL="file://$HOST$URL_PATH" - printf '\e]7;%s\a' "$PWD_URL" + + # URL-encodes a string + # Outputs the encoded string on stdout + # Returns nonzero if encoding failed + function _omz_urlencode() { + local url_str='' + { + local str=$1 + + # URLs must use UTF-8 encoding; convert if required + local encoding=${LC_CTYPE/*./} + if [[ $encoding != UTF-8 ]]; then + str=$(iconv -f $encoding -t UTF-8) + if [[ $? != 0 ]]; then + echo "Error converting string from $encoding to UTF-8" >&2 + return 1 + fi + fi + + # Use LC_CTYPE=C to process text byte-by-byte + local i ch hexch LC_CTYPE=C + for ((i = 1; i <= ${#str}; ++i)); do + ch="$str[i]" + if [[ "$ch" =~ [/._~A-Za-z0-9-] ]]; then + url_str+="$ch" + else + hexch=$(printf "%02X" "'$ch") + url_str+="%$hexch" + fi + done + echo $url_str } + } - # Use a precmd hook instead of a chpwd hook to avoid contaminating output - precmd_functions+=(update_terminalapp_cwd) - # Run once to get initial cwd set - update_terminalapp_cwd + # Emits the control sequence to notify Terminal.app of the cwd + function update_terminalapp_cwd() { + # Identify the directory using a "file:" scheme URL, including + # the host name to disambiguate local vs. remote paths. + + # Percent-encode the pathname. + local URL_PATH=$(_omz_urlencode $PWD) + [[ $? != 0 ]] && return 1 + local PWD_URL="file://$HOST$URL_PATH" + # Undocumented Terminal.app-specific control sequence + printf '\e]7;%s\a' $PWD_URL + } + + # Use a precmd hook instead of a chpwd hook to avoid contaminating output + precmd_functions+=(update_terminalapp_cwd) + # Run once to get initial cwd set + update_terminalapp_cwd fi -- cgit v1.2.3-70-g09d2 From 187cf07c9148d5d6dda9b8ac1b453bd6e39ea550 Mon Sep 17 00:00:00 2001 From: Andrew Janke Date: Tue, 17 Feb 2015 00:54:54 -0500 Subject: For unspecified encodings, assume it's UTF-8 or compatible (e.g. ASCII) and muddle through without character encoding conversion. --- lib/termsupport.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/termsupport.zsh b/lib/termsupport.zsh index 70b54301d..ef9f0e5f1 100644 --- a/lib/termsupport.zsh +++ b/lib/termsupport.zsh @@ -69,7 +69,7 @@ if [[ "$TERM_PROGRAM" == "Apple_Terminal" ]] && [[ -z "$INSIDE_EMACS" ]]; then # URLs must use UTF-8 encoding; convert if required local encoding=${LC_CTYPE/*./} - if [[ $encoding != UTF-8 ]]; then + if [[ -n $encoding && $encoding != UTF-8 ]]; then str=$(iconv -f $encoding -t UTF-8) if [[ $? != 0 ]]; then echo "Error converting string from $encoding to UTF-8" >&2 -- cgit v1.2.3-70-g09d2 From cb37c934c0e1083897b501e5b8a85340e3b7e470 Mon Sep 17 00:00:00 2001 From: Andrew Janke Date: Sat, 21 Feb 2015 16:00:40 -0500 Subject: Remove unnecessary braces. --- lib/termsupport.zsh | 48 +++++++++++++++++++++++------------------------- 1 file changed, 23 insertions(+), 25 deletions(-) (limited to 'lib') diff --git a/lib/termsupport.zsh b/lib/termsupport.zsh index ef9f0e5f1..7cb3791e6 100644 --- a/lib/termsupport.zsh +++ b/lib/termsupport.zsh @@ -63,33 +63,31 @@ if [[ "$TERM_PROGRAM" == "Apple_Terminal" ]] && [[ -z "$INSIDE_EMACS" ]]; then # Outputs the encoded string on stdout # Returns nonzero if encoding failed function _omz_urlencode() { + local str=$1 local url_str='' - { - local str=$1 - - # URLs must use UTF-8 encoding; convert if required - local encoding=${LC_CTYPE/*./} - if [[ -n $encoding && $encoding != UTF-8 ]]; then - str=$(iconv -f $encoding -t UTF-8) - if [[ $? != 0 ]]; then - echo "Error converting string from $encoding to UTF-8" >&2 - return 1 - fi - fi - # Use LC_CTYPE=C to process text byte-by-byte - local i ch hexch LC_CTYPE=C - for ((i = 1; i <= ${#str}; ++i)); do - ch="$str[i]" - if [[ "$ch" =~ [/._~A-Za-z0-9-] ]]; then - url_str+="$ch" - else - hexch=$(printf "%02X" "'$ch") - url_str+="%$hexch" - fi - done - echo $url_str - } + # URLs must use UTF-8 encoding; convert if required + local encoding=${LC_CTYPE/*./} + if [[ -n $encoding && $encoding != UTF-8 ]]; then + str=$(iconv -f $encoding -t UTF-8) + if [[ $? != 0 ]]; then + echo "Error converting string from $encoding to UTF-8" >&2 + return 1 + fi + fi + + # Use LC_CTYPE=C to process text byte-by-byte + local i ch hexch LC_CTYPE=C + for ((i = 1; i <= ${#str}; ++i)); do + ch="$str[i]" + if [[ "$ch" =~ [/._~A-Za-z0-9-] ]]; then + url_str+="$ch" + else + hexch=$(printf "%02X" "'$ch") + url_str+="%$hexch" + fi + done + echo $url_str } # Emits the control sequence to notify Terminal.app of the cwd -- cgit v1.2.3-70-g09d2 From 88f42b6132adedff7557170168416d575569b56e Mon Sep 17 00:00:00 2001 From: Andrew Janke Date: Sat, 21 Feb 2015 16:25:28 -0500 Subject: Add support for variant "utf8" locale suffix spelling. Fix dumb bug in iconv call that would cause it to hang. --- lib/termsupport.zsh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/termsupport.zsh b/lib/termsupport.zsh index 7cb3791e6..52622f5ab 100644 --- a/lib/termsupport.zsh +++ b/lib/termsupport.zsh @@ -64,12 +64,12 @@ if [[ "$TERM_PROGRAM" == "Apple_Terminal" ]] && [[ -z "$INSIDE_EMACS" ]]; then # Returns nonzero if encoding failed function _omz_urlencode() { local str=$1 - local url_str='' + local url_str="" # URLs must use UTF-8 encoding; convert if required local encoding=${LC_CTYPE/*./} - if [[ -n $encoding && $encoding != UTF-8 ]]; then - str=$(iconv -f $encoding -t UTF-8) + if [[ -n $encoding && $encoding != UTF-8 && $encoding != utf8 ]]; then + str=$(echo $str | iconv -f $encoding -t UTF-8) if [[ $? != 0 ]]; then echo "Error converting string from $encoding to UTF-8" >&2 return 1 -- cgit v1.2.3-70-g09d2 From ea6adc5a0a3332e541a812a2da0e94c73e2102da Mon Sep 17 00:00:00 2001 From: Andrew Janke Date: Fri, 29 May 2015 22:59:07 -0400 Subject: Add omz_diagnostic_dump() to help with bug reports. --- lib/diagnostics.zsh | 280 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 280 insertions(+) create mode 100644 lib/diagnostics.zsh (limited to 'lib') diff --git a/lib/diagnostics.zsh b/lib/diagnostics.zsh new file mode 100644 index 000000000..cca13f4e4 --- /dev/null +++ b/lib/diagnostics.zsh @@ -0,0 +1,280 @@ +# diagnostics.zsh +# +# Diagnostic and debugging support for oh-my-zsh + +# omz_diagnostic_dump() +# +# Author: Andrew Janke +# +# Usage: +# +# omz_diagnostic_dump [-v] [-V] [file] +# +# NOTE: This is a work in progress. Its interface and behavior are going to change, +# and probably in non-back-compatible ways. +# +# Outputs a bunch of information about the state and configuration of +# oh-my-zsh, zsh, and the user's system. This is intended to provide a +# bunch of context for diagnosing your own or a third party's problems, and to +# be suitable for posting to public bug reports. +# +# The output is human-readable and its format may change over time. It is not +# suitable for parsing. All the output is in one single file so it can be posted +# as a gist or bug comment on GitHub. GitHub doesn't support attaching tarballs +# or other files to bugs; otherwise, this would probably have an option to produce +# tarballs that contain copies of the config and customization files instead of +# catting them all in to one file. +# +# This is intended to be widely portable, and run anywhere that oh-my-zsh does. +# Feel free to report any portability issues as bugs. +# +# This is written in a defensive style so it still works (and can detect) cases when +# basic functionality like echo and which have been redefined. In particular, almost +# everything is invoked with "builtin" or "command", to work in the face of user +# redefinitions. +# +# OPTIONS +# +# [file] Specifies the output file. If not given, a file in the current directory +# is selected automatically. +# +# -v Increase the verbosity of the dump output. May be specified multiple times. +# Verbosity levels: +# 0 - Basic info, shell state, omz configuration, git state +# 1 - (default) Adds key binding info and configuration file contents +# 2 - Adds zcompdump file contents +# +# -V Reduce the verbosity of the dump output. May be specified multiple times. +# +# TODO: +# * Multi-file capture +# * Add automatic gist uploading +# * Consider whether to move default output file location to TMPDIR. More robust +# but less user friendly. +# +function omz_diagnostic_dump() { + emulate -L zsh + + local thisfcn=omz_diagnostic_dump + local -A opts + local opt_verbose opt_noverbose opt_outfile + local timestamp=$(date +%Y%m%d-%H%M%S) + local outfile=omz_diagdump_$timestamp.txt + builtin zparseopts -A opts -D -- "v+=opt_verbose" "V+=opt_noverbose" + local verbose n_verbose=${#opt_verbose} n_noverbose=${#opt_noverbose} + (( verbose = 1 + n_verbose - n_noverbose )) + + if [[ ${#*} > 0 ]]; then + opt_outfile=$1 + fi + if [[ ${#*} > 1 ]]; then + builtin echo "$thisfcn: error: too many arguments" >&2 + return 1 + fi + if [[ -n "$opt_outfile" ]]; then + outfile="$opt_outfile" + fi + + # Always write directly to a file so terminal escape sequences are + # captured cleanly + _omz_diag_dump_one_big_text &> "$outfile" + if [[ $? != 0 ]]; then + builtin echo "$thisfcn: error while creating diagnostic dump; see $outfile for details" + fi + + builtin echo + builtin echo Diagnostic dump file created at: "$outfile" + builtin echo + builtin echo To share this with OMZ developers, post it as a gist on GitHub + builtin echo at "https://gist.github.com" and share the link to the gist. + builtin echo + builtin echo "WARNING: This dump file contains all your zsh and omz configuration files," + builtin echo "so don't share it publicly if there's sensitive information in them." + builtin echo + +} + +function _omz_diag_dump_one_big_text() { + local program programs progfile md5 + + builtin echo oh-my-zsh diagnostic dump + builtin echo + + # Basic system and zsh information + command date + command uname -a + builtin echo OSTYPE=$OSTYPE + command zsh --version + builtin echo User: $USER + builtin echo + + # Installed programs + programs=(sh zsh ksh bash sed cat grep find git posh) + for program in $programs; do + local md5_str="" md5="" link_str="" extra_str="" + progfile=$(builtin which $program) + if [[ $? == 0 ]]; then + if [[ -e $progfile ]]; then + if builtin whence md5 &>/dev/null; then + extra_str+=" $(md5 -q $progfile)" + fi + if [[ -h "$progfile" ]]; then + extra_str+=" ( -> ${file:A} )" + fi + fi + builtin printf '%-9s %-20s %s\n' "$program is" "$progfile" "$extra_str" + else + builtin echo "$program: not found" + fi + done + builtin echo + builtin echo Versions: + builtin echo "zsh: $(zsh --version)" + builtin echo "bash: $(bash --version | command grep bash)" + builtin echo "git: $(git --version)" + builtin echo "grep: $(grep --version)" + builtin echo + + # Core command definitions + _omz_diag_dump_check_core_commands || return 1 + builtin echo + + # ZSH Process state + builtin echo Process state: + builtin echo pwd: $PWD + if builtin whence pstree &>/dev/null; then + builtin echo Process tree for this shell: + pstree -p $$ + else + ps -fT + fi + builtin set | command grep -a '^\(ZSH\|plugins\|TERM\|LC_\|LANG\|precmd\|chpwd\|preexec\|FPATH\|TTY\|DISPLAY\|PATH\)\|OMZ' + builtin echo + #TODO: Should this include `env` instead of or in addition to `export`? + builtin echo Exported: + builtin echo $(builtin export | command sed 's/=.*//') + builtin echo + builtin echo Locale: + command locale + builtin echo + + # Zsh configuration + builtin echo Zsh configuration: + builtin echo setopt: $(builtin setopt) + builtin echo + + # Oh-my-zsh installation + builtin echo oh-my-zsh installation: + command ls -ld ~/.z* + command ls -ld ~/.oh* + builtin echo + builtin echo oh-my-zsh git state: + (cd $ZSH && builtin echo "HEAD: $(git rev-parse HEAD)" && git remote -v && git status | command grep "[^[:space:]]") + if [[ $verbose -ge 1 ]]; then + (cd $ZSH && git reflog --date=default | command grep pull) + fi + builtin echo + if [[ -e $ZSH_CUSTOM ]]; then + local custom_dir=$ZSH_CUSTOM + if [[ -h $custom_dir ]]; then + custom_dir=$(cd $custom_dir && pwd -P) + fi + builtin echo "oh-my-zsh custom dir:" + builtin echo " $ZSH_CUSTOM ($custom_dir)" + (cd ${custom_dir:h} && command find ${custom_dir:t} -name .git -prune -o -print) + builtin echo + fi + + # Key binding and terminal info + if [[ $verbose -ge 1 ]]; then + builtin echo "bindkey:" + builtin bindkey + builtin echo + builtin echo "infocmp:" + command infocmp + builtin echo + fi + + # Configuration file info + local zdotdir=${ZDOTDIR:-$HOME} + builtin echo "Zsh configuration files:" + local cfgfile cfgfiles + cfgfiles=( /etc/zshenv /etc/zprofile /etc/zshrc /etc/zlogin /etc/zlogout + $zdotdir/.zshenv $zdotdir/.zprofile $zdotdir/.zshrc $zdotdir/.zlogin $zdotdir/.zlogout ) + command ls -lad $cfgfiles 2>&1 + builtin echo + if [[ $verbose -ge 1 ]]; then + for cfgfile in $cfgfiles; do + _omz_diag_dump_echo_file_w_header $cfgfile + done + fi + builtin echo "Zsh compdump files:" + local dumpfile dumpfiles + command ls -lad $zdotdir/.zcompdump* + dumpfiles=( $zdotdir/.zcompdump*(N) ) + if [[ $verbose -ge 2 ]]; then + for dumpfile in $dumpfiles; do + _omz_diag_dump_echo_file_w_header $dumpfile + done + fi + +} + +function _omz_diag_dump_check_core_commands() { + builtin echo "Core command check:" + local redefined name builtins externals + redefined=() + # All the zsh non-module builtin commands + # These are taken from the zsh reference manual for 5.0.2 + # Commands from modules should not be included. + # (For back-compatibility, if any of these are newish, they should be removed, + # or at least made conditional on the version of the current running zsh.) + # "history" is also excluded because OMZ is known to redefine that + builtins=( alias autoload bg bindkey break builtin bye cd chdir command + comparguments compcall compctl compdescribe compfiles compgroups compquote comptags + comptry compvalues continue declare dirs disable disown echo echotc echoti emulate + enable eval exec exit export false fc fg float functions getln getopts hash + integer jobs kill let limit local log logout noglob popd print printf + pushd pushln pwd r read readonly rehash return sched set setopt shift + source suspend test times trap true ttyctl type typeset ulimit umask unalias + unfunction unhash unlimit unset unsetopt vared wait whence where which zcompile + zle zmodload zparseopts zregexparse zstyle ) + builtins_fatal=( builtin command local ) + externals=( zsh ) + for name in $builtins; do + if [[ $(builtin whence -w $name) != "$name: builtin" ]]; then + builtin echo "builtin '$name' has been redefined" + builtin which $name + redefined+=$name + fi + done + for name in $externals; do + if [[ $(builtin whence -w $name) != "$name: command" ]]; then + builtin echo "command '$name' has been redefined" + builtin which $name + redefined+=$name + fi + done + + if [[ -n "$redefined" ]]; then + builtin echo "SOME CORE COMMANDS HAVE BEEN REDEFINED: $redefined" + else + builtin echo "All core commands are defined normally" + fi + +} + +function _omz_diag_dump_echo_file_w_header() { + local file=$1 + if [[ ( -f $file || -h $file ) ]]; then + builtin echo "========== $file ==========" + if [[ -h $file ]]; then + builtin echo "========== ( => ${file:A} ) ==========" + fi + command cat $file + builtin echo "========== end $file ==========" + builtin echo + fi +} + + -- cgit v1.2.3-70-g09d2 From 82c1288cb25b1567b4d17f33a75192de1b9f4634 Mon Sep 17 00:00:00 2001 From: Andrew Janke Date: Sat, 6 Jun 2015 01:19:29 -0400 Subject: Include some bash rc files; improve formatting; more version info --- lib/diagnostics.zsh | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'lib') diff --git a/lib/diagnostics.zsh b/lib/diagnostics.zsh index cca13f4e4..7991b64c8 100644 --- a/lib/diagnostics.zsh +++ b/lib/diagnostics.zsh @@ -104,12 +104,12 @@ function _omz_diag_dump_one_big_text() { command date command uname -a builtin echo OSTYPE=$OSTYPE - command zsh --version + builtin echo ZSH_VERSION=$ZSH_VERSION builtin echo User: $USER builtin echo # Installed programs - programs=(sh zsh ksh bash sed cat grep find git posh) + programs=(sh zsh ksh bash sed cat grep ls find git posh) for program in $programs; do local md5_str="" md5="" link_str="" extra_str="" progfile=$(builtin which $program) @@ -119,7 +119,7 @@ function _omz_diag_dump_one_big_text() { extra_str+=" $(md5 -q $progfile)" fi if [[ -h "$progfile" ]]; then - extra_str+=" ( -> ${file:A} )" + extra_str+=" ( -> ${progfile:A} )" fi fi builtin printf '%-9s %-20s %s\n' "$program is" "$progfile" "$extra_str" @@ -128,8 +128,9 @@ function _omz_diag_dump_one_big_text() { fi done builtin echo - builtin echo Versions: + builtin echo Command Versions: builtin echo "zsh: $(zsh --version)" + builtin echo "this zsh session: $ZSH_VERSION" builtin echo "bash: $(bash --version | command grep bash)" builtin echo "git: $(git --version)" builtin echo "grep: $(grep --version)" @@ -199,8 +200,12 @@ function _omz_diag_dump_one_big_text() { local zdotdir=${ZDOTDIR:-$HOME} builtin echo "Zsh configuration files:" local cfgfile cfgfiles + # Some files for bash that zsh does not use are intentionally included + # to help with diagnosing behavior differences between bash and zsh cfgfiles=( /etc/zshenv /etc/zprofile /etc/zshrc /etc/zlogin /etc/zlogout - $zdotdir/.zshenv $zdotdir/.zprofile $zdotdir/.zshrc $zdotdir/.zlogin $zdotdir/.zlogout ) + $zdotdir/.zshenv $zdotdir/.zprofile $zdotdir/.zshrc $zdotdir/.zlogin $zdotdir/.zlogout + ~/.zsh-pre-oh-my-zsh + /etc/bashrc /etc/profile ~/.bashrc ~/.profile ~/.bash_profile ~/.bash_logout ) command ls -lad $cfgfiles 2>&1 builtin echo if [[ $verbose -ge 1 ]]; then @@ -208,6 +213,7 @@ function _omz_diag_dump_one_big_text() { _omz_diag_dump_echo_file_w_header $cfgfile done fi + builtin echo builtin echo "Zsh compdump files:" local dumpfile dumpfiles command ls -lad $zdotdir/.zcompdump* @@ -274,6 +280,12 @@ function _omz_diag_dump_echo_file_w_header() { command cat $file builtin echo "========== end $file ==========" builtin echo + elif [[ -d $file ]]; then + builtin echo "File '$file' is a directory" + elif [[ ! -e $file ]]; then + builtin echo "File '$file' does not exist" + else + command ls -lad "$file" fi } -- cgit v1.2.3-70-g09d2 From afadb5a7fba061bc1b6da1df3b00e20ede4a5cba Mon Sep 17 00:00:00 2001 From: Andrew Janke Date: Sat, 6 Jun 2015 11:04:14 -0400 Subject: diagnostics: add zstyle state to output --- lib/diagnostics.zsh | 3 +++ 1 file changed, 3 insertions(+) (limited to 'lib') diff --git a/lib/diagnostics.zsh b/lib/diagnostics.zsh index 7991b64c8..6dede0664 100644 --- a/lib/diagnostics.zsh +++ b/lib/diagnostics.zsh @@ -163,6 +163,9 @@ function _omz_diag_dump_one_big_text() { builtin echo Zsh configuration: builtin echo setopt: $(builtin setopt) builtin echo + builtin echo zstyle: + builtin zstyle + builtin echo # Oh-my-zsh installation builtin echo oh-my-zsh installation: -- cgit v1.2.3-70-g09d2 From af68165207ea757e303fdbab365ac9e3f11c8530 Mon Sep 17 00:00:00 2001 From: Andrew Janke Date: Sat, 6 Jun 2015 11:50:05 -0400 Subject: Fix name of backed-up zshrc --- lib/diagnostics.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/diagnostics.zsh b/lib/diagnostics.zsh index 6dede0664..023ba42b9 100644 --- a/lib/diagnostics.zsh +++ b/lib/diagnostics.zsh @@ -207,7 +207,7 @@ function _omz_diag_dump_one_big_text() { # to help with diagnosing behavior differences between bash and zsh cfgfiles=( /etc/zshenv /etc/zprofile /etc/zshrc /etc/zlogin /etc/zlogout $zdotdir/.zshenv $zdotdir/.zprofile $zdotdir/.zshrc $zdotdir/.zlogin $zdotdir/.zlogout - ~/.zsh-pre-oh-my-zsh + ~/.zsh.pre-oh-my-zsh /etc/bashrc /etc/profile ~/.bashrc ~/.profile ~/.bash_profile ~/.bash_logout ) command ls -lad $cfgfiles 2>&1 builtin echo -- cgit v1.2.3-70-g09d2 From 01e355fb1e5dc3982efeecee699a96254f3f44e6 Mon Sep 17 00:00:00 2001 From: Michele Bologna Date: Wed, 20 May 2015 17:36:46 +0200 Subject: In addition to the already existing variables ZSH_THEME_GIT_PROMPT for behind, ahead and diverged remote, I added ZSH_THEME_GIT_PROMPT_EQUAL_REMOTE. --- lib/git.zsh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/git.zsh b/lib/git.zsh index caa7e6329..baf863717 100644 --- a/lib/git.zsh +++ b/lib/git.zsh @@ -36,7 +36,10 @@ git_remote_status() { ahead=$(command git rev-list ${hook_com[branch]}@{upstream}..HEAD 2>/dev/null | wc -l) behind=$(command git rev-list HEAD..${hook_com[branch]}@{upstream} 2>/dev/null | wc -l) - if [ $ahead -gt 0 ] && [ $behind -eq 0 ] + if [ $ahead -eq 0 ] && [ $behind -eq 0 ] + then + echo "$ZSH_THEME_GIT_PROMPT_EQUAL_REMOTE" + elif [ $ahead -gt 0 ] && [ $behind -eq 0 ] then git_remote_status="$ZSH_THEME_GIT_PROMPT_AHEAD_REMOTE" git_remote_status_detailed="$ZSH_THEME_GIT_PROMPT_AHEAD_REMOTE_COLOR$ZSH_THEME_GIT_PROMPT_AHEAD_REMOTE$((ahead))%{$reset_color%}" -- cgit v1.2.3-70-g09d2 From 9813ff5f24c6ce8409490d7ef8b8c4458f2a6a66 Mon Sep 17 00:00:00 2001 From: Andrew Janke Date: Sun, 28 Jun 2015 16:54:04 -0400 Subject: omz_diagnostic_dump: Add umask and $fpath listing. This helps catch issues with compinit and insecure directories. --- lib/diagnostics.zsh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/diagnostics.zsh b/lib/diagnostics.zsh index 023ba42b9..f5f15deaa 100644 --- a/lib/diagnostics.zsh +++ b/lib/diagnostics.zsh @@ -106,6 +106,7 @@ function _omz_diag_dump_one_big_text() { builtin echo OSTYPE=$OSTYPE builtin echo ZSH_VERSION=$ZSH_VERSION builtin echo User: $USER + builtin echo umask: $(umask) builtin echo # Installed programs @@ -159,13 +160,19 @@ function _omz_diag_dump_one_big_text() { command locale builtin echo - # Zsh configuration + # Zsh installation and configuration builtin echo Zsh configuration: builtin echo setopt: $(builtin setopt) builtin echo builtin echo zstyle: builtin zstyle builtin echo + builtin echo 'compaudit output:' + compaudit + builtin echo + builtin echo '$fpath directories:' + command ls -lad $fpath + builtin echo # Oh-my-zsh installation builtin echo oh-my-zsh installation: @@ -195,7 +202,7 @@ function _omz_diag_dump_one_big_text() { builtin bindkey builtin echo builtin echo "infocmp:" - command infocmp + command infocmp -L builtin echo fi -- cgit v1.2.3-70-g09d2 From bca720fa9549f7fe4687acd1aaf91720428657e9 Mon Sep 17 00:00:00 2001 From: Andrew Janke Date: Thu, 9 Jul 2015 20:50:57 -0400 Subject: diagnostics: include detailed OS version info if possible --- lib/diagnostics.zsh | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'lib') diff --git a/lib/diagnostics.zsh b/lib/diagnostics.zsh index f5f15deaa..53c6548de 100644 --- a/lib/diagnostics.zsh +++ b/lib/diagnostics.zsh @@ -55,6 +55,8 @@ function omz_diagnostic_dump() { emulate -L zsh + builtin echo "Generating diagnostic dump; please be patient..." + local thisfcn=omz_diagnostic_dump local -A opts local opt_verbose opt_noverbose opt_outfile @@ -108,6 +110,8 @@ function _omz_diag_dump_one_big_text() { builtin echo User: $USER builtin echo umask: $(umask) builtin echo + _omz_diag_dump_os_specific_version + builtin echo # Installed programs programs=(sh zsh ksh bash sed cat grep ls find git posh) @@ -299,4 +303,28 @@ function _omz_diag_dump_echo_file_w_header() { fi } +function _omz_diag_dump_os_specific_version() { + local osname osver version_file version_files + case "$OSTYPE" in + darwin*) + osname=$(command sw_vers -productName) + osver=$(command sw_vers -productVersion) + builtin echo "OS Version: $osname $osver build $(sw_vers -buildVersion)" + ;; + cygwin) + command systeminfo | command grep "^OS Name\|^OS Version" + ;; + esac + + if builtin which lsb_release >/dev/null; then + builtin echo "OS Release: $(command lsb_release -s -d)" + fi + + version_files=( /etc/*-release(N) /etc/*-version(N) /etc/*_version(N) ) + for version_file in $version_files; do + builtin echo "$version_file:" + command cat "$version_file" + builtin echo + done +} -- cgit v1.2.3-70-g09d2 From dcb175d4309a41723ebeb561a8089115d9e7126b Mon Sep 17 00:00:00 2001 From: leycec Date: Sat, 11 Jul 2015 01:20:23 -0400 Subject: Insecure completion handler added. A new "lib/compfix.zsh" script defining a new handle_completion_insecurities() function has been added, which handles insecure completion directories by notifying users of said insecurities and moving away all existing completion caches to a temporary directory. While intended to be called at startup, this function is generally callable at any time (e.g., for testing). --- lib/compfix.zsh | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 lib/compfix.zsh (limited to 'lib') diff --git a/lib/compfix.zsh b/lib/compfix.zsh new file mode 100644 index 000000000..208aaadb1 --- /dev/null +++ b/lib/compfix.zsh @@ -0,0 +1,60 @@ +# Handle completions insecurities (i.e., completion-dependent directories with +# insecure ownership or permissions) by: +# +# * Human-readably notifying the user of these insecurities. +# * Moving away all existing completion caches to a temporary directory. Since +# any of these caches may have been generated from insecure directories, they +# are all suspect now. Failing to do so typically causes subsequent compinit() +# calls to fail with "command not found: compdef" errors. (That's bad.) +function handle_completion_insecurities() { + # List of the absolute paths of all unique insecure directories, split on + # newline from compaudit()'s output resembling: + # + # There are insecure directories: + # /usr/share/zsh/site-functions + # /usr/share/zsh/5.0.6/functions + # /usr/share/zsh + # /usr/share/zsh/5.0.6 + # + # Since the ignorable first line is printed to stderr and thus not captured, + # stderr is squelched to prevent this output from leaking to the user. + local -aU insecure_dirs + insecure_dirs=( ${(f@):-"$(compaudit 2>/dev/null)"} ) + + # If no such directories exist, get us out of here. + if (( ! ${#insecure_dirs} )); then + print "[oh-my-zsh] No insecure completion-dependent directories detected." + return + fi + + # List ownership and permissions of all insecure directories. + print "[oh-my-zsh] Insecure completion-dependent directories detected:" + ls -ld "${(@)insecure_dirs}" + print "[oh-my-zsh] For safety, completions will be disabled until you manually fix all" + print "[oh-my-zsh] insecure directory permissions and ownership and restart oh-my-zsh." + print "[oh-my-zsh] See the above list for directories with group or other writability.\n" + + # Locally enable the "NULL_GLOB" option, thus removing unmatched filename + # globs from argument lists *AND* printing no warning when doing so. Failing + # to do so prints an unreadable warning if no completion caches exist below. + setopt local_options null_glob + + # List of the absolute paths of all unique existing completion caches. + local -aU zcompdump_files + zcompdump_files=( "${ZSH_COMPDUMP}"(.) "${ZDOTDIR:-${HOME}}"/.zcompdump* ) + + # Move such caches to a temporary directory. + if (( ${#zcompdump_files} )); then + # Absolute path of the directory to which such files will be moved. + local ZSH_ZCOMPDUMP_BAD_DIR="${ZSH_CACHE_DIR}/zcompdump-bad" + + # List such files first. + print "[oh-my-zsh] Insecure completion caches also detected:" + ls -l "${(@)zcompdump_files}" + + # For safety, move rather than permanently remove such files. + print "[oh-my-zsh] Moving to \"${ZSH_ZCOMPDUMP_BAD_DIR}/\"...\n" + mkdir -p "${ZSH_ZCOMPDUMP_BAD_DIR}" + mv "${(@)zcompdump_files}" "${ZSH_ZCOMPDUMP_BAD_DIR}/" + fi +} -- cgit v1.2.3-70-g09d2 From fa254458688acf0bede8567b2bb5793a9ed944d6 Mon Sep 17 00:00:00 2001 From: Andrew Janke Date: Wed, 22 Jul 2015 12:59:39 -0400 Subject: diagnostics: include output file name in dump output --- lib/diagnostics.zsh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/diagnostics.zsh b/lib/diagnostics.zsh index 53c6548de..f38239110 100644 --- a/lib/diagnostics.zsh +++ b/lib/diagnostics.zsh @@ -101,7 +101,9 @@ function _omz_diag_dump_one_big_text() { builtin echo oh-my-zsh diagnostic dump builtin echo - + builtin echo $outfile + builtin echo + # Basic system and zsh information command date command uname -a -- cgit v1.2.3-70-g09d2 From 14b4ba83c35c34f4a1f3a69c9967f502ee2d6528 Mon Sep 17 00:00:00 2001 From: Andrew Janke Date: Sun, 9 Aug 2015 16:28:47 -0400 Subject: Move urlencode/urldecode functions to core lib --- lib/functions.zsh | 134 ++++++++++++++++++++++++++++++++++++++++++++++++++++ lib/termsupport.zsh | 33 +------------ 2 files changed, 135 insertions(+), 32 deletions(-) (limited to 'lib') diff --git a/lib/functions.zsh b/lib/functions.zsh index 17f5f9cbf..5c1a5a283 100644 --- a/lib/functions.zsh +++ b/lib/functions.zsh @@ -73,3 +73,137 @@ function env_default() { env | grep -q "^$1=" && return 0 export "$1=$2" && return 3 } + + +# Required for $langinfo +zmodload zsh/langinfo + +# URL-encode a string +# +# Encodes a string using RFC 2396 URL-encoding (%-escaped). +# See: https://www.ietf.org/rfc/rfc2396.txt +# +# By default, reserved characters and unreserved "mark" characters are +# not escaped by this function. This allows the common usage of passing +# an entire URL in, and encoding just special characters in it, with +# the expectation that reserved and mark characters are used appropriately. +# The -r and -m options turn on escaping of the reserved and mark characters, +# respectively, which allows arbitrary strings to be fully escaped for +# embedding inside URLs, where reserved characters might be misinterpreted. +# +# Prints the encoded string on stdout. +# Returns nonzero if encoding failed. +# +# Usage: +# omz_urlencode [-r] [-m] +# +# -r causes reserved characters (;/?:@&=+$,) to be escaped +# +# -m causes "mark" characters (_.!~*''()-) to be escaped +# +# -P causes spaces to be encoded as '%20' instead of '+' +function omz_urlencode() { + emulate -L zsh + zparseopts -D -E -a opts r m P + + local in_str=$1 + local url_str="" + local spaces_as_plus + if [[ -z $opts[(r)-P] ]]; then spaces_as_plus=1; fi + local str="$in_str" + + # URLs must use UTF-8 encoding; convert str to UTF-8 if required + local encoding=$langinfo[CODESET] + local safe_encodings + safe_encodings=(UTF-8 utf8 US-ASCII) + if [[ -z ${safe_encodings[(r)$encoding]} ]]; then + str=$(echo -E "$str" | iconv -f $encoding -t UTF-8) + if [[ $? != 0 ]]; then + echo "Error converting string from $encoding to UTF-8" >&2 + return 1 + fi + fi + + # Use LC_CTYPE=C to process text byte-by-byte + local i byte ord LC_ALL=C + export LC_ALL + local reserved=';/?:@&=+$,' + local mark='_.!~*''()-' + local dont_escape="[A-Za-z0-9" + if [[ -z $opts[(r)-r] ]]; then + dont_escape+=$reserved + fi + # $mark must be last because of the "-" + if [[ -z $opts[(r)-m] ]]; then + dont_escape+=$mark + fi + dont_escape+="]" + + # Implemented to use a single printf call and avoid subshells in the loop, + # for performance (primarily on Windows). + local url_str="" + for (( i = 1; i <= ${#str}; ++i )); do + byte="$str[i]" + if [[ "$byte" =~ "$dont_escape" ]]; then + url_str+="$byte" + else + if [[ "$byte" == " " && -n $spaces_as_plus ]]; then + url_str+="+" + else + ord=$(( [##16] #byte )) + url_str+="%$ord" + fi + fi + done + echo -E "$url_str" +} + +# URL-decode a string +# +# Decodes a RFC 2396 URL-encoded (%-escaped) string. +# This decodes the '+' and '%' escapes in the input string, and leaves +# other characters unchanged. Does not enforce that the input is a +# valid URL-encoded string. This is a convenience to allow callers to +# pass in a full URL or similar strings and decode them for human +# presentation. +# +# Outputs the encoded string on stdout. +# Returns nonzero if encoding failed. +# +# Usage: +# omz_urldecode - prints decoded string followed by a newline +function omz_urldecode { + emulate -L zsh + local encoded_url=$1 + + echo -e input $1 + # Work bytewise, since URLs escape UTF-8 octets + local caller_encoding=$langinfo[CODESET] + local LC_ALL=C + export LC_ALL + + # Change + back to ' ' + local tmp=${encoded_url:gs/+/ /} + # Protect other escapes to pass through the printf unchanged + tmp=${tmp:gs/\\/\\\\/} + # Handle %-escapes by turning them into `\xXX` printf escapes + tmp=${tmp:gs/%/\\x/} + echo -E "before decode $tmp" + local decoded + eval "decoded=\$'$tmp'" + + # Now we have a UTF-8 encoded string in the variable. We need to re-encode + # it if caller is in a non-UTF-8 locale. + local safe_encodings + safe_encodings=(UTF-8 utf8 US-ASCII) + if [[ -z ${safe_encodings[(r)$caller_encoding]} ]]; then + decoded=$(echo -E "$decoded" | iconv -f UTF-8 -t $caller_encoding) + if [[ $? != 0 ]]; then + echo "Error converting string from UTF-8 to $caller_encoding" >&2 + return 1 + fi + fi + + echo -E "$decoded" +} + diff --git a/lib/termsupport.zsh b/lib/termsupport.zsh index 52622f5ab..726cdce41 100644 --- a/lib/termsupport.zsh +++ b/lib/termsupport.zsh @@ -59,44 +59,13 @@ preexec_functions+=(omz_termsupport_preexec) if [[ "$TERM_PROGRAM" == "Apple_Terminal" ]] && [[ -z "$INSIDE_EMACS" ]]; then - # URL-encodes a string - # Outputs the encoded string on stdout - # Returns nonzero if encoding failed - function _omz_urlencode() { - local str=$1 - local url_str="" - - # URLs must use UTF-8 encoding; convert if required - local encoding=${LC_CTYPE/*./} - if [[ -n $encoding && $encoding != UTF-8 && $encoding != utf8 ]]; then - str=$(echo $str | iconv -f $encoding -t UTF-8) - if [[ $? != 0 ]]; then - echo "Error converting string from $encoding to UTF-8" >&2 - return 1 - fi - fi - - # Use LC_CTYPE=C to process text byte-by-byte - local i ch hexch LC_CTYPE=C - for ((i = 1; i <= ${#str}; ++i)); do - ch="$str[i]" - if [[ "$ch" =~ [/._~A-Za-z0-9-] ]]; then - url_str+="$ch" - else - hexch=$(printf "%02X" "'$ch") - url_str+="%$hexch" - fi - done - echo $url_str - } - # Emits the control sequence to notify Terminal.app of the cwd function update_terminalapp_cwd() { # Identify the directory using a "file:" scheme URL, including # the host name to disambiguate local vs. remote paths. # Percent-encode the pathname. - local URL_PATH=$(_omz_urlencode $PWD) + local URL_PATH=$(omz_urlencode -P $PWD) [[ $? != 0 ]] && return 1 local PWD_URL="file://$HOST$URL_PATH" # Undocumented Terminal.app-specific control sequence -- cgit v1.2.3-70-g09d2 From 96c34cebae5da3a52e7da0d61188c1f9822a9c2e Mon Sep 17 00:00:00 2001 From: Andrew Janke Date: Sun, 9 Aug 2015 16:37:12 -0400 Subject: Add a deprecation comment. --- lib/functions.zsh | 2 -- plugins/terminalapp/terminalapp.plugin.zsh | 6 ++++++ 2 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 plugins/terminalapp/terminalapp.plugin.zsh (limited to 'lib') diff --git a/lib/functions.zsh b/lib/functions.zsh index 5c1a5a283..2a962669c 100644 --- a/lib/functions.zsh +++ b/lib/functions.zsh @@ -176,7 +176,6 @@ function omz_urldecode { emulate -L zsh local encoded_url=$1 - echo -e input $1 # Work bytewise, since URLs escape UTF-8 octets local caller_encoding=$langinfo[CODESET] local LC_ALL=C @@ -188,7 +187,6 @@ function omz_urldecode { tmp=${tmp:gs/\\/\\\\/} # Handle %-escapes by turning them into `\xXX` printf escapes tmp=${tmp:gs/%/\\x/} - echo -E "before decode $tmp" local decoded eval "decoded=\$'$tmp'" diff --git a/plugins/terminalapp/terminalapp.plugin.zsh b/plugins/terminalapp/terminalapp.plugin.zsh new file mode 100644 index 000000000..7c0c278b9 --- /dev/null +++ b/plugins/terminalapp/terminalapp.plugin.zsh @@ -0,0 +1,6 @@ +# This file is intentionally empty. +# +# The terminalapp plugin is deprecated and may be removed in a future release. +# Its functionality has been folded in to the core lib/termsupport.zsh, which +# is loaded for all users. You can remove terminalapp from your $plugins list +# once all your systems are updated to the current version of Oh My Zsh. -- cgit v1.2.3-70-g09d2 From 47d19cc56425aa7c550d845726111ee8bd9520d1 Mon Sep 17 00:00:00 2001 From: Andrew Janke Date: Mon, 17 Aug 2015 20:55:41 -0400 Subject: Add defensive `emulate -L zsh` to termsupport functions --- lib/termsupport.zsh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/termsupport.zsh b/lib/termsupport.zsh index 726cdce41..ff61d5329 100644 --- a/lib/termsupport.zsh +++ b/lib/termsupport.zsh @@ -7,6 +7,7 @@ # (In screen, only short_tab_title is used) # Limited support for Apple Terminal (Terminal can't set window and tab separately) function title { + emulate -L zsh [[ "$EMACS" == *term* ]] && return # if $2 is unset use $1 as default @@ -26,6 +27,7 @@ ZSH_THEME_TERM_TITLE_IDLE="%n@%m: %~" # Runs before showing the prompt function omz_termsupport_precmd { + emulate -L zsh if [[ $DISABLE_AUTO_TITLE == true ]]; then return fi @@ -35,11 +37,11 @@ function omz_termsupport_precmd { # Runs before executing the command function omz_termsupport_preexec { + emulate -L zsh if [[ $DISABLE_AUTO_TITLE == true ]]; then return fi - emulate -L zsh setopt extended_glob # cmd name only, or if this is sudo or ssh, the next cmd @@ -61,6 +63,7 @@ if [[ "$TERM_PROGRAM" == "Apple_Terminal" ]] && [[ -z "$INSIDE_EMACS" ]]; then # Emits the control sequence to notify Terminal.app of the cwd function update_terminalapp_cwd() { + emulate -L zsh # Identify the directory using a "file:" scheme URL, including # the host name to disambiguate local vs. remote paths. -- cgit v1.2.3-70-g09d2 From 46ddd88fe056ee84064536ce9b34f86bba6b53ca Mon Sep 17 00:00:00 2001 From: Andrew Janke Date: Fri, 4 Sep 2015 14:13:00 -0400 Subject: diagnostics: switch to shasum, filter sysinfo using lines shasum seems more widely available than md5/md5sum, and we don't have to worry about dealing with the different signatures and output formats of md5 and md5sum then. sysinfo outputs localized message labels, so we can't just grep for "OS Type". But OS is the first thing it outputs, so we can probably just grab those lines by line number. Switched to doing that. --- lib/diagnostics.zsh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/diagnostics.zsh b/lib/diagnostics.zsh index f38239110..afc33829b 100644 --- a/lib/diagnostics.zsh +++ b/lib/diagnostics.zsh @@ -117,13 +117,16 @@ function _omz_diag_dump_one_big_text() { # Installed programs programs=(sh zsh ksh bash sed cat grep ls find git posh) + local progfile="" extra_str="" sha_str="" for program in $programs; do - local md5_str="" md5="" link_str="" extra_str="" + extra_str="" sha_str="" progfile=$(builtin which $program) if [[ $? == 0 ]]; then if [[ -e $progfile ]]; then - if builtin whence md5 &>/dev/null; then - extra_str+=" $(md5 -q $progfile)" + if builtin whence shasum &>/dev/null; then + sha_str=($(command shasum $progfile)) + sha_str=$sha_str[1] + extra_str+=" SHA $sha_str" fi if [[ -h "$progfile" ]]; then extra_str+=" ( -> ${progfile:A} )" @@ -314,7 +317,7 @@ function _omz_diag_dump_os_specific_version() { builtin echo "OS Version: $osname $osver build $(sw_vers -buildVersion)" ;; cygwin) - command systeminfo | command grep "^OS Name\|^OS Version" + command systeminfo | command head -4 | command tail -2 ;; esac -- cgit v1.2.3-70-g09d2 From 3976e040350bd9ac9423252b97dee28d3762adc2 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Wed, 19 Aug 2015 09:03:43 +0200 Subject: Use proper if comparison --- lib/completion.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/completion.zsh b/lib/completion.zsh index 452c0dfe7..e848ea2dd 100644 --- a/lib/completion.zsh +++ b/lib/completion.zsh @@ -58,7 +58,7 @@ zstyle ':completion:*:*:*:users' ignored-patterns \ # ... unless we really want to. zstyle '*' single-ignored show -if [ "x$COMPLETION_WAITING_DOTS" = "xtrue" ]; then +if [[ $COMPLETION_WAITING_DOTS = true ]]; then expand-or-complete-with-dots() { echo -n "\e[31m......\e[0m" zle expand-or-complete -- cgit v1.2.3-70-g09d2 From 6a8d406eaa715814dc5a6df08960d1fe62e5c066 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Sun, 16 Aug 2015 22:19:59 +0200 Subject: Use prompt expansion sequence to color red the output This makes it clearer and possibly more portable for different platforms. --- lib/completion.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/completion.zsh b/lib/completion.zsh index e848ea2dd..81250d9e1 100644 --- a/lib/completion.zsh +++ b/lib/completion.zsh @@ -60,7 +60,7 @@ zstyle '*' single-ignored show if [[ $COMPLETION_WAITING_DOTS = true ]]; then expand-or-complete-with-dots() { - echo -n "\e[31m......\e[0m" + print -Pn "%{%F{red}......%f%}" zle expand-or-complete zle redisplay } -- cgit v1.2.3-70-g09d2 From b42efeb87ebdcb89510b8ffbcf210494f194109e Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Sat, 22 Aug 2015 21:21:41 +0200 Subject: Switch off line wrapping in case dots occupy extra line This commit uses the (hopefully) standard rmam and smam escape sequences which toggle off and on line wrapping respectively. This is so that extra dots that don't fit the current line won't be displayed in the next line, which would in turn make the shell display a new prompt on the next line after the dots are hidden. I've added a check for $terminfo rmam and smam values to be sure we have them before printing them out. If this commit breaks something post an issue with your terminal emulator and $TERM value and we'll figure out what went wrong. --- lib/completion.zsh | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'lib') diff --git a/lib/completion.zsh b/lib/completion.zsh index 81250d9e1..f5b292471 100644 --- a/lib/completion.zsh +++ b/lib/completion.zsh @@ -60,7 +60,11 @@ zstyle '*' single-ignored show if [[ $COMPLETION_WAITING_DOTS = true ]]; then expand-or-complete-with-dots() { + # toggle line-wrapping off and back on again + [[ -n "$terminfo[rmam]" && -n "$terminfo[smam]" ]] && echoti rmam print -Pn "%{%F{red}......%f%}" + [[ -n "$terminfo[rmam]" && -n "$terminfo[smam]" ]] && echoti smam + zle expand-or-complete zle redisplay } -- cgit v1.2.3-70-g09d2