]> arthur.barton.de Git - ax-zsh.git/commitdiff
homebrew: Set HOMEBREW_AUTO_UPDATE_SECS to 10 minutes master
authorAlexander Barton <alex@barton.de>
Tue, 2 Apr 2024 18:59:22 +0000 (20:59 +0200)
committerAlexander Barton <alex@barton.de>
Tue, 2 Apr 2024 18:59:22 +0000 (20:59 +0200)
73 files changed:
.gitignore
.mailmap [new file with mode: 0644]
LICENSE.md
README.md
ax.zsh
bin/axttyinfo
bin/axzshctl
core/01_zprofile/01_zprofile.zshrc
core/11_terminal/11_terminal.zshrc
core/12_locale/12_locale.ax-io
core/20_home/20_home.ax-io [new file with mode: 0644]
core/20_home/20_home.zprofile [deleted file]
core/30_env/30_env.ax-io [new file with mode: 0644]
core/30_env/30_env.zprofile [deleted file]
core/30_env/30_env.zshrc
core/30_hostname/30_hostname.zprofile
core/30_path/30_path.zprofile [new file with mode: 0644]
core/40_axzsh/40_axzsh.zshrc [new file with mode: 0644]
core/40_axzsh/functions/_axzsh [new file with mode: 0644]
core/40_completion/40_completion.zshrc [new file with mode: 0644]
core/40_path/40_path.zprofile [deleted file]
core/40_prompt/40_prompt.zshrc [new file with mode: 0644]
core/50_axzsh/50_axzsh.zshrc [deleted file]
core/50_axzsh/functions/_axzsh [deleted file]
core/50_completion/50_completion.zshrc [deleted file]
core/50_path/50_path.zprofile [new file with mode: 0644]
core/50_prompt/50_prompt.zshrc [deleted file]
core/80_local_config/80_local_config.ax-io [new file with mode: 0644]
core/80_local_config/80_local_config.zprofile [deleted file]
core/99_cleanup/99_cleanup.zlogin
core/99_zlogin/99_zlogin.zshrc
default_plugins/bash_completion/bash_completion.zshrc [deleted file]
default_plugins/byebye/byebye.zlogout
default_plugins/cheat/cheat.zshrc
default_plugins/history/history.zshrc
default_plugins/less/less.zprofile
default_plugins/ssh/ssh.zshrc
default_plugins/std_aliases/std_aliases.zshrc
default_plugins/std_env/std_env.zprofile
default_plugins/std_functions/std_functions.zshrc
install.sh
plugins/00-newline/00-newline.ax-io [new file with mode: 0644]
plugins/00-newline/README.md [new file with mode: 0644]
plugins/autojump/README.md [new file with mode: 0644]
plugins/autojump/autojump.zshrc [new file with mode: 0644]
plugins/bat/README.md [new file with mode: 0644]
plugins/bat/bat.zshrc [new file with mode: 0644]
plugins/browser_select/README.md [new file with mode: 0644]
plugins/browser_select/browser_select.zprofile [new file with mode: 0644]
plugins/calendar/README.md [new file with mode: 0644]
plugins/calendar/calendar.ax-io [new file with mode: 0644]
plugins/editor_select/editor_select.zprofile
plugins/editor_select/editor_select.zshrc [new file with mode: 0644]
plugins/fzf/fzf.zshrc
plugins/git/git.zshrc
plugins/gnupg/gnupg.zshrc
plugins/googler/googler.zshrc
plugins/homebrew/README.md
plugins/homebrew/homebrew.zprofile
plugins/icalbuddy/icalbuddy.ax-io
plugins/iterm2/iterm2.zshrc
plugins/lsd/README.md [new file with mode: 0644]
plugins/lsd/lsd.zshrc [new file with mode: 0644]
plugins/neofetch/README.md [new file with mode: 0644]
plugins/neofetch/neofetch.ax-io [new file with mode: 0644]
plugins/remind/remind.ax-io
plugins/websearch/README.md [new file with mode: 0644]
plugins/websearch/websearch.zshrc [new file with mode: 0644]
themes/ax.axzshtheme
themes/axemoji.axzshtheme
themes/debian.axzshtheme
themes/ohmyzsh.axzshtheme
themes/starship.axzshtheme [new file with mode: 0644]

index 278727fa33d43f379075a034abc69da0b27e0b1d..2b05238eb40baba641300332e8358ebf5a0f8c61 100644 (file)
@@ -5,3 +5,4 @@ active_theme
 custom_themes/
 cache/
 repos/
+debug
diff --git a/.mailmap b/.mailmap
new file mode 100644 (file)
index 0000000..5630f6e
--- /dev/null
+++ b/.mailmap
@@ -0,0 +1,2 @@
+Alexander Barton <alex@barton.de> <abarton@thomas-daily.de>
+Alexander Barton <alex@barton.de> <alexander.barton@tomas-daily.de>
index e65154b3c9297c9cc2ddfb417d8b8b8af5d8f07b..11a61cb0c2257450d1111bce3f455731ee1759a0 100644 (file)
@@ -1,7 +1,7 @@
 The MIT License
 ===============
 
-- Copyright (c) 2015-2019 Alexander Barton <alex@barton.de>
+- Copyright (c) 2015-2023 Alexander Barton <alex@barton.de>
 
 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated documentation files (the "Software"), to deal
index 3ddbd0cb9287f4bae4d42f278a3b7e5943c8a11c..63bcfee6d8c21525779b9f0bb1b24c3cd6feda14 100644 (file)
--- a/README.md
+++ b/README.md
-AX-ZSH: Alex' Modular ZSH Configuration
-=======================================
+# AX-ZSH: Alex' Modular ZSH Configuration
 
-AX-ZSH is a modular configuration system for the Z shell (ZSH).
+[AX-ZSH] is a modular configuration system for the Z shell ([ZSH]).
 It provides sane defaults and is extendable by plugins.
 
-Installation
-------------
+AX-ZSH integrates well with [Powerlevel10k] and other extensions, even plugins
+of [OhMyZsh], see [below](#integration-with-other-projects).
 
-To install AX-ZSH, either download a source archive or use Git to clone it.
-Afterwards use the `install.sh` script inside of the source directory to set
-up the `~/.axzsh` directory.
+The homepage of [AX-ZSH] can be found at [GitHub]:
+<https://github.com/alexbarton/ax-zsh>.
 
-When using Git it is best to directly clone the AX-ZSH repository into the
-`~/.axzsh` directory and call `install.sh` from this location.
+## Installation
 
-Clone repository from _GitHub_ (<https://github.com/alexbarton/ax-zsh>):
+Prerequisites:
 
-    git clone https://github.com/alexbarton/ax-zsh.git ~/.axzsh
+* [ZSH] – obviously ;-)
+* [Git] (optional but recommended!)
 
-Then run the installer script:
+Installing AX-ZSH is a two-step process:
 
-    ~/.axzsh/install.sh
+1. Clone or copy the source files into the `~/.axzsh` directory,
+2. Run the `~/.axzsh/install.sh` script.
 
 The `install.sh` script creates symbolic links for `~/.zprofile`, `~/.zshrc`,
 `~/.zlogin`, and `~/.zlogout` (don't worry, already existing files are backed
 up).
 
-Now close and restart all your running ZSH session to activate AX-ZSH.
+*Note:* The installation is per-user and only changes/installs files into the
+home directory of the current user (`~`). AX-ZSH is not meant to be installed
+globally for all users on a system at once, and you don't need to become "root"
+or any other user with elevated privileges!
 
-To update AX-ZSH run `axzshctl upgrade`.
+### Installation using Git
 
-AX-ZSH & Local ZSH Configuration
---------------------------------
+When using [Git], the preferred method, it is best to directly clone the AX-ZSH
+repository into the `~/.axzsh` directory and call `install.sh` from this
+location:
 
-Plugins are loaded when they are linked into the `$AXZSH/active_plugins/`
-directory; see the _Customization_ section below for how to activate them.
+```sh
+git clone https://github.com/alexbarton/ax-zsh.git ~/.axzsh
+~/.axzsh/install.sh
+```
 
-Don't modify `~/.zprofile`, `~/.zshrc`, `~/.zlogin`, or `~/.zlogout`! These
-are links to "AX-ZSH"-private files that can become overwritten when updating.
+### Installation without Git
 
-You can use the following files for local ZSH configuration:
+*Note:* If you do not install AX-ZSH with [Git], you will not be able to upgrade
+itself afterwards with the integrated `axzsh upgrade` command! Therefore this
+method is *not recommended* for normal use!
 
-1. AX-ZSH doesn't use `~/.zshenv` in any way. So you can use this file for your
-   own purposes (for example, to set up some environment variables that AX-ZSH
-   relies on).
+```sh
+curl -Lo ax-zsh-master.zip https://github.com/alexbarton/ax-zsh/archive/refs/heads/master.zip
+unzip ax-zsh-master.zip
+mv ax-zsh-master ~/.axzsh
+~/.axzsh/install.sh
+```
 
-2. AX-ZSH reads the optional files `~/.zprofile.local`, `~/.zshrc.local`,
-   `~/.zlogin.local`, and `~/.zlogout.local` after its own core initialization
-   files when present.
+### Post-Installation Tasks
+
+After installing AX-ZSH, using Git or via an archive file, you should close all
+running ZSH sessions and restart them to activate AX-ZSH. And maybe you want to
+change your default shell to ZSH if you haven't already?
+
+For example like this:
+
+```sh
+# Set new default shell
+chsh -s $(command -v zsh)
+
+# Replace running shell with a ZSH login shell
+exec $(command -v zsh) -l
+```
+
+## Upgrade
+
+When you used Git to install AX-ZSH (and/or plugins), you can use the `axzshctl`
+command to upgrade AX-ZSH itself and external plugins like this:
+
+```sh
+axzshctl upgrade
+```
+
+## Usage
+
+AX-ZSH comes with a hopefully sane default configuration and can be extended
+using plugins. Different types of plugins are supported:
+
+* Plugins shipped with AX-ZSH.
+* Themes shipped with AX-ZSH.
+* 3rd-party plugins:
+  * installed manually into `$AXZSH/custom_plugins`
+  * stand-alone plugins stored on GitHub
+  * plugins of OhMyZsh from its GitHub repository
+* 3rd-party themes:
+  * installed manually into `$AXZSH/custom_themes`
+  * some stand-alone themes stored on GitHub
+
+### Check whether all locally available "useful" plug-ins are activated
+
+Most plugins can be enabled even when the commands they work with aren't
+available and won't do any harm. But to keep ZSH startup times low, you should
+only enable plugins that are useable on your local system and which you actually
+plan to use.
+
+You can use the following command to let AX-ZSH scan the status of all locally
+available plugins:
+
+```sh
+axzshctl check-plugins
+```
+
+It will summarize the status of all enabled plugins, and suggest to enable
+plugins which seem to make sense on the system and to disable enabled plugins
+that seem not to be supported (for example because of missing dependencies).
+
+### List enabled plugins
+
+Run the following command to list all currently enabled plugins:
+
+```sh
+axzshctl list-enabled
+```
+
+### Enable plugins
+
+AX-ZSH comes with a sane "core ZSH configuration", but it can show its true
+strengths when enabling additional plugins for additional tools and commands
+that are available on your system and you want to use.
+
+Different types of plugins are supported (see the introduction to the section
+"*usage*" above) which are differentiated by their identifier:
+
+* `<name>`: locally available plugin, either bundled with AX-ZSH itself, or
+  installed manually (see below).
+* `<repository>/<name>`: stand-alone [GitHub] repository.
+* `@ohmyzsh/<name>`: [OhMyZsh] plugin from the OhMyZsh GitHub
+  repository (see <https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins>).
+
+You can enable one or more plugins like this:
+
+```sh
+axzshctl enable-plugin <identifier> [<identifier> […]]
+```
+
+*Hint:* *Tab-completion* works for sub-commands and already locally available
+plugin names!
+
+Some examples:
+
+```sh
+# Enable some plugins bundled with AX-ZSH:
+axzshctl enable-plugin editor_select git ssh_autoadd
 
-Customization
--------------
+# Enable the Powerlevel10k "theme plugin" from GitHub, see
+# <https://github.com/romkatv/powerlevel10k>:
+axzshctl enable-plugin romkatv/powerlevel10k
 
-Use the `axzshctl` tool to enable, disable, and reset plugins. AXZSH
-initializes an alias which points to the actual location in `~/.axzsh/bin/`.
+# Enable the "fast-syntax-highlighting" plugin from GitHub, see
+# <https://github.com/zdharma-continuum/fast-syntax-highlighting>:
+axzshctl enable-plugin zdharma-continuum/fast-syntax-highlighting
 
-See `axzshctl --help` for details.
+# Enable the Git and tmux plugins of OhMyZsh:
+axzshctl enable-plugin @ohmyzsh/git @ohmyzsh/tmux
+```
+
+#### Custom local plugins
 
 You can link custom plugins stored in arbitrary directories using `axzshctl`
 by specifying the complete path name. Or you can place additional plugins into
-the `~/.axzsh/custom_plugins` folder which is searched by the `axzshctl` tool
+the `$AXZSH/custom_plugins` folder which is searched by the `axzshctl` tool
 by default.
 
 In addition you can set the `AXZSH_PLUGIN_D` variable (and `ZSH_CUSTOM` like
-"OhMyZsh") to specify additional plugin search directories.
+[OhMyZsh]) to specify additional plugin search directories.
+
+### Disable plugins
+
+Run the following command to disable a currently enabled plugin:
+
+```sh
+axzshctl disable-plugin <identifier> [<identifier> […]]
+```
+
+*Hint:* *Tab-completion* works for sub-commands and plugin names!
+
+### Update plugin cache
+
+AX-ZSH uses a "plugin cache" to speedup ZSH start times. This cache is
+automatically updated when using the `axzshctl` sub-commands, for example when
+enabling or disabling plugins, or when  upgrading the AX-ZSH installation and
+all plugins.
+
+But you *have to* update the cache when manually installing plugins or during
+development of a own local plugin after updating its code!
+
+Run the following command to update the AX-ZSH cache:
+
+```sh
+axzshctl update-caches
+```
+
+### Other `axzshctl` sub-commands
+
+Please run `axzshctl --help` to get a full list of a available sub-commands:
+
+```sh
+axzshctl --help
+```
+
+## Integration with other projects
+
+### Powerlevel10k
+
+AX-ZSH supports [Powerlevel10k] out of the box, you just have to install it as a
+plugin:
+
+```sh
+axzshctl enable-plugin romkatv/powerlevel10k
+```
+
+*Hint:* Once the Powerlevel10k plugin theme is installed, you can use the
+regular `axzshctl set-theme` command to enable it, like for any other installed
+theme: `axzshctl set-theme powerlevel10k`.
 
-Environment Variables
----------------------
+## AX-ZSH & local ZSH configuration
+
+Don't modify `~/.zprofile`, `~/.zshrc`, `~/.zlogin`, or `~/.zlogout`! These
+are links to "AX-ZSH"-private files that can become overwritten when updating.
+
+You can use the following files for local ZSH configuration:
+
+1. AX-ZSH doesn't use `~/.zshenv` in any way. So you can use this file for your
+   own purposes (for example, to set up some environment variables that AX-ZSH
+   relies on).
+
+2. AX-ZSH reads the optional files `~/.zprofile.local`, `~/.zshrc.local`,
+   `~/.zlogin.local`, and `~/.zlogout.local` after its own core initialization
+   files when present.
+
+## Environment variables
 
 Expected to be already set:
 
@@ -75,13 +245,24 @@ Expected to be already set:
 
 Validated and/or set up by core plugins:
 
-* `AXZSH`
+* `AXZSH` – AX-ZSH installation directory
 * `HOST`
 * `HOSTNAME` (same as HOST, deprecated)
 * `LOCAL_HOME`
 * `PS1`
 * `SHORT_HOST`
 * `TERM`
-* `XDG_RUNTIME_DIR`
+* `TMPDIR` (set and always ends with a "/")
 * `XDG_CACHE_HOME`
+* `XDG_RUNTIME_DIR`
 * `ZSH_CACHE_DIR`
+
+___
+[AX-ZSH]: <https://github.com/alexbarton/ax-zsh> "AX-ZSH Homepage"
+[Git]: <https://git-scm.com/> "Git Homepage"
+[GitHub]: <https://github.com/> "GitHub Homepage"
+[OhMyZsh]: <https://ohmyz.sh/> "OhMyZsh Homepage"
+[Powerlevel10k]: <https://github.com/romkatv/powerlevel10k> "Powerlevel10k Homepage"
+[ZSH]: <https://www.zsh.org/> "ZSH Homepage"
+
+[AX-ZSH] Copyright (c) 2015-2022 Alexander Barton <alex@barton.de>
diff --git a/ax.zsh b/ax.zsh
index 23eda0166f99d31368b2f0e19cec0de2f5acaef1..a0fb5d8b66e664e372a081ccfd2289df4d77cf6e 100644 (file)
--- a/ax.zsh
+++ b/ax.zsh
@@ -1,5 +1,5 @@
 # AX-ZSH: Alex' Modular ZSH Configuration
-# Copyright (c) 2015-2020 Alexander Barton <alex@barton.de>
+# Copyright (c) 2015-2024 Alexander Barton <alex@barton.de>
 
 script_name="${${(%):-%N}:t}"
 script_type="$script_name[2,-1]"
@@ -9,16 +9,41 @@ script_type="$script_name[2,-1]"
 # - $1: Script name
 # - $2: Stage name (ax-io, zprofile, zshrc, zlogin, zlogout)
 function axzsh_handle_stage {
-       name="$1"
-       type="$2"
+       local name="$1"
+       local type="$2"
 
        [[ -n "$AXZSH_DEBUG" ]] && echo "» $name ($type):"
 
+       # Look for some 3rd-party integrations ...
+
+       # --- Powerlevel10k ---
+       # Read in Powerlevel10k configuration file, if not already read:
+       [[ -z "$POWERLEVEL9K_CONFIG_FILE" && -r ~/.p10k.zsh ]] && source ~/.p10k.zsh
+       # Enable instant prompt. Should stay close to the top of ~/.zshrc.
+       # Initialization code that may require console input (password prompts,
+       # [y/n] confirmations, etc.) must be executed before this, so all ax-zsh
+       # plugins should do output in their "ax-io" stage only!
+       # Read the initialization script in the "zprofile" stage for login
+       # shells, and in the "zshrc" stage for non-login sub-shells (which have
+       # the profile already read in and therefore will skip the "ax-io" and
+       # "zprofile" stages and not catch up).
+       if [[ \
+               ( "$type" == "zprofile" ) || \
+               ( ! -o login && "$type" == "zshrc" && -n "$AXZSH_ZPROFILE_READ" ) \
+       ]]; then
+               p10k_instant_prompt="${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
+               if [[ -r "$p10k_instant_prompt" ]]; then
+                       [[ -n "$AXZSH_DEBUG" ]] && echo "  Reading \"$p10k_instant_prompt\" ..."
+                       source "$p10k_instant_prompt"
+               fi
+               unset p10k_instant_prompt
+       fi
+
        # Initialize cache
-       mkdir -p "$AXZSH/cache"
-       cache_file="$AXZSH/cache/$type.cache"
+       [[ -d "$AXZSH/cache" ]] || mkdir -p "$AXZSH/cache"
+       local cache_file="$AXZSH/cache/$type.cache"
 
-       cat_cmd=${commands[cat]:-cat}
+       local cat_cmd=${commands[cat]:-cat}
 
        if [[ -r "$cache_file" ]]; then
                # Cache file exists, use it!
@@ -32,22 +57,36 @@ function axzsh_handle_stage {
                [[ -n "$AXZSH_DEBUG" ]] \
                        && echo "   - Reading cache file \"$cache_file\" ..."
                source "$cache_file"
-               unfunction ax_plugin_init
+               (( $+functions[axzsh_plugin_init] )) && unfunction axzsh_plugin_init
        else
                # No cache file available.
+               local new_cache_file="$cache_file.NEW"
+
                # Setup list of plugins to load:
+               local plugin_list
                typeset -U plugin_list
                plugin_list=(
-                       "$AXZSH/core/"[0-5]*
+                       "$AXZSH/core/"[0-4]*
                        "$AXZSH/active_plugins/"*(N)
-                       "$AXZSH/core/"[6-9]*
+                       "$AXZSH/core/"[5-9]*
                )
 
                # Create new cache file:
-               if [[ -n "$cache_file" ]]; then
-                       [[ -n "$AXZSH_DEBUG" ]] \
-                               && echo "   (Writing new cache file to \"$cache_file\" ...)"
-                       printf "# %s\n\n" "$(LC_ALL=C date)" >"$cache_file"
+               [[ -n "$AXZSH_DEBUG" ]] \
+                       && echo "   (Writing new cache file to \"$new_cache_file\" ...)"
+               if ! printf "# %s\n\n" "$(LC_ALL=C date)" >"$new_cache_file"; then
+                       unset new_cache_file
+               else
+                       # New cache file successfully created ...
+                       if [[ "$type" = "ax-io" ]]; then
+                               # AX-IO Stage:
+                               # Write an initial PATH variable to the cache
+                               # file, which becomes overwritten by the path
+                               # plugin at the "zprofile" stage later on, but
+                               # this way "ax-io" stage plugins have a somewhat
+                               # saner PATH to begin with ...
+                               printf 'export PATH="%s"\n\n' "$PATH" >>"$new_cache_file"
+                       fi
                fi
 
                # Read in all the plugins for the current "type":
@@ -57,16 +96,21 @@ function axzsh_handle_stage {
                        if [[ "$plugin:t" == "99_cleanup" && "$type" = "zshrc" ]]; then
                                if [[ -r "$AXZSH_THEME" ]]; then
                                        source "$AXZSH_THEME"
-                                       if [[ -n "$cache_file" ]]; then
+                                       if [[ -n "$new_cache_file" ]]; then
                                                # Source the theme in the new cache file:
-                                               echo "# BEGIN Theme" >>"$cache_file"
-                                               echo 'source "$AXZSH_THEME"' >>"$cache_file"
-                                               echo "# END Theme" >>"$cache_file"
+                                               echo "# BEGIN Theme" >>"$new_cache_file"
+                                               echo 'source "$AXZSH_THEME"' >>"$new_cache_file"
+                                               echo "# END Theme" >>"$new_cache_file"
                                        fi
                                fi
                        fi
-                       axzsh_load_plugin "$plugin" "$type" "$cache_file"
+                       axzsh_load_plugin "$plugin" "$type" "$new_cache_file"
                done
+
+               if [[ -n "$cache_file" && -n "$new_cache_file" && -r "$new_cache_file" ]]; then
+                       # Move newly created cache file in place:
+                       mv "$new_cache_file" "$cache_file"
+               fi
        fi
 }
 
@@ -112,6 +156,10 @@ function axzsh_load_plugin {
                        # Oh My ZSH plugin with "zsh-" prefix stripped
                        type="plugin.zsh"
                        fname="$dname/${plugin_short##zsh-}.plugin.zsh"
+               elif [[ -r "$dname/${plugin%.plugin.zsh}.plugin.zsh" ]]; then
+                       # Oh My ZSH plugin with ".plugin.zsh" suffix in its name
+                       type="plugin.zsh"
+                       fname="$dname/${plugin}"
                elif [[ -r "$dname/init.zsh" ]]; then
                        # Prezto module
                        type="init.zsh"
@@ -161,7 +209,7 @@ function axzsh_load_plugin {
 
                if [[ -n "$cache_file" ]]; then
                        # Add plugin data to cache
-                       printf "# BEGIN: %s\nax_plugin_init()\n{\n" "$fname" >>"$cache_file"
+                       printf "# BEGIN: %s\naxzsh_plugin_init()\n{\n" "$fname" >>"$cache_file"
                        case "$fname" in
                                *"/repos/"*)
                                        echo "[[ -n \"\$AXZSH_DEBUG\" ]] && echo '     - $plugin ($type): \"$fname\" ...'" >>$cache_file
@@ -171,7 +219,7 @@ function axzsh_load_plugin {
                                        echo "[[ -n \"\$AXZSH_DEBUG\" ]] && echo '     - $plugin ($type, cached) ...'" >>$cache_file
                                        "$cat_cmd" "$fname" >>"$cache_file"
                        esac
-                       printf "}\nax_plugin_init\n# END: %s\n\n" "$fname" >>"$cache_file"
+                       printf "}\naxzsh_plugin_init\n# END: %s\n\n" "$fname" >>"$cache_file"
                fi
        fi
 
@@ -191,14 +239,17 @@ fi
 [[ -n "$SHELL" ]] || export SHELL=$(command -v zsh)
 
 # Make sure that "AXZSH" variable is set and exported
-if [[ -z "$AXZSH" ]]; then
-       export AXZSH="$HOME/.axzsh"
-       if [[ -f "$HOME/.axzsh.debug" ]]; then
-               export AXZSH_DEBUG=1
-               echo "AXZSH=$AXZSH"
-               echo "AXZSH_DEBUG=$AXZSH_DEBUG"
-               echo "AXZSH_PLUGIN_D=$AXZSH_PLUGIN_D"
-       fi
+[[ -n "$AXZSH" ]] || export AXZSH="${ZDOTDIR:-$HOME}/.axzsh"
+
+# Check for "debug mode" ...
+if [[ -f "$AXZSH/debug" || -f "$HOME/.axzsh.debug" ]]; then
+       export AXZSH_DEBUG=1
+       export POWERLEVEL9K_INSTANT_PROMPT=quiet
+       echo "AXZSH=$AXZSH"
+       echo "AXZSH_DEBUG=$AXZSH_DEBUG"
+       echo "AXZSH_PLUGIN_D=$AXZSH_PLUGIN_D"
+       echo "AXZSH_ZLOGIN_READ=$AXZSH_ZLOGIN_READ"
+       echo "AXZSH_ZPROFILE_READ=$AXZSH_ZPROFILE_READ"
 fi
 
 if [[ "$script_type" = "zprofile" ]]; then
@@ -206,22 +257,11 @@ if [[ "$script_type" = "zprofile" ]]; then
        axzsh_handle_stage "$script_name" "ax-io"
 fi
 
-# Look for some 3rd-party integrations ...
-
-# --- Powerlevel10k ---
-# Read in Powerlevel10k configuration file, if not already read:
-[[ -z "$POWERLEVEL9K_CONFIG_FILE" && -r ~/.p10k.zsh ]] && source ~/.p10k.zsh
-# Enable instant prompt. Should stay close to the top of ~/.zshrc.
-# Initialization code that may require console input (password prompts,
-# [y/n] confirmations, etc.) must be executed before this, so all ax-zsh
-# plugings should do output in their "zprofile" stage!
-if [[ "$script_type" == "zprofile" ]]; then
-       p10k_instant_prompt="${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
-       [[ -r "$p10k_instant_prompt" ]] && source "$p10k_instant_prompt"
-fi
-
 axzsh_handle_stage "$script_name" "$script_type"
 
 # Clean up ...
 unfunction axzsh_handle_stage axzsh_load_plugin
 unset script_name script_type
+
+# Hints for external installers:
+# - iTerm2: DON'T install "iterm2_shell_integration"!
index 57c76c0b010dfba611f8b8bafacb3fa86ce183e0..8097e37dc059f5ec749615be5d28e0ea4782f1f6 100755 (executable)
@@ -1,32 +1,82 @@
 #!/usr/bin/env zsh
 #
 # AX-ZSH: Alex' Modular ZSH Configuration
-# Copyright (c) 2015-2017 Alexander Barton <alex@barton.de>
+# Copyright (c) 2015-2022 Alexander Barton <alex@barton.de>
 #
 
 source "$AXZSH/core/11_terminal/11_terminal.zshrc" || exit 1
 
-unset VERBOSE
+unset VERBOSE ONE_LINE
 
 while [[ $# -gt 0 ]]; do
        case "$1" in
+               "-1")
+                       ONE_LINE=1
+                       ;;
                "-v")
                        VERBOSE=1
                        ;;
                *)
-                       echo "Usage: ttyinfo [-v]" >&2
+                       echo "Usage: ttyinfo [-1] [-v]" >&2
                        exit 1
        esac
        shift
 done
 
-print -Pn -- "$fg[white]$FX[bold]$(hostname)$FX[no-bold] "
+print -Pn -- "$fg[white]$FX[bold]$SHORT_HOST$FX[no-bold] "
 print -Pn -- "$fg[yellow]$(tty)$FX[reset], "
 print -Pn -- "$fg[green]$FX[underline]${TERM:-?}$FX[reset] "
-print -Pn -- "(${COLUMNS:-?}x${LINES:-?}); "
-print -Pn -- "$fg[white]LANG=${LANG:-?}$FX[reset]"
+print -Pn -- "(${COLUMNS:-?}x${LINES:-?})"
+[[ -n "$TERM_PROGRAM" ]] && print -Pn -- "; $fg[green]$TERM_PROGRAM$FX[reset]"
+[[ -n "$$TERM_PROGRAM_VERSION" ]] && print -Pn -- " $TERM_PROGRAM_VERSION"
+print -Pn -- "$FX[reset]"
 echo
 
+[[ -n "$ONE_LINE" ]] && return 0
+
+typeset -i max=${COLUMNS:-80}
+typeset -i col=0
+for key (
+       LANG
+       LC_ALL
+       LC_ADDRESS
+       LC_COLLATE
+       LC_CTYPE
+       LC_IDENTIFICATION
+       LC_MEASUREMENT
+       LC_MESSAGES
+       LC_MONETARY
+       LC_NAME
+       LC_NUMERIC
+       LC_PAPER
+       LC_TELEPHONE
+       LC_TIME
+       -
+       COLORTERM
+       CLICOLOR
+       TERM_COLORS
+       -
+       DISPLAY
+); do
+       if [[ $key == "-" ]]; then
+               [[ $col -gt 0 ]] && echo
+               col=0
+               continue
+       fi
+
+       [[ "${(P)key-UNSET}" = "UNSET" ]] && continue
+       val=${(P)key}
+
+       col=$(( $col + ${#key} + ${#val} + 5 ))
+       if [[ $col -gt $max ]]; then
+               echo
+               col=$(( ${#key} + ${#val} + 5 ))
+       fi
+
+       print -Pn -- "$key=\"$fg[cyan]$val$FX[reset]\"; "
+done
+[[ $col -gt 0 ]] && echo
+
 [[ -z "$VERBOSE" ]] && return 0
 
 check_function_result() {
index c25fb442a00360177a40be854b758298fdbf22fd..943e4641bec19812fdb7a1ace1c7bb957aba4612 100755 (executable)
@@ -1,34 +1,44 @@
 #!/usr/bin/env zsh
 #
 # AX-ZSH: Alex' Modular ZSH Configuration
-# Copyright (c) 2015-2020 Alexander Barton <alex@barton.de>
+# Copyright (c) 2015-2023 Alexander Barton <alex@barton.de>
 #
 
-# Include "ax-common.sh", if available:
-for dir ("$HOME/lib" "$HOME/.ax" /usr/local /opt/ax /usr); do
-       [[ -z "$ax_common_sourced" ]] || break
-       ax_common="${dir}/lib/ax/ax-common.sh"
-       [[ -r "$ax_common" ]] && source "$ax_common"
-done
-if [[ -z "$ax_common_sourced" ]]; then
-       function ax_msg {
-               shift
-               echo "$@"
-       }
-       function ax_error {
-               ax_msg 2 "$@" >&2
-       }
-fi
-unset dir ax_common ax_common_sourced
+# Embedded ax-common compatibility functions ...
+function ax_msg {
+       case "$1" in
+               "0")    c="32"; ;;
+               "1")    c="33"; ;;
+               "2")    c="31"; ;;
+               "-")    c="1";  ;;
+               *)      c="0";  ;;
+       esac
+       shift
+       printf "\e[${c}m%s\e[0m\n" "$@"
+}
+function ax_error {
+       ax_msg 2 "$@" >&2
+}
 
 function Version {
        echo "ax-zsh -- Modular configuration system for the Z shell (ZSH)"
-       echo "Copyright (c) 2015-2019 Alexander Barton <alex@barton.de>."
+       echo "Copyright (c) 2015-2023 Alexander Barton <alex@barton.de>."
        echo "Licensed under the terms of the MIT license, see LICENSE.md for details."
        echo "Homepage: <https://github.com/alexbarton/ax-zsh>"
+       echo
+       echo "Installation prefix: $AXZSH"
+       echo -n "Version: "
        if [[ -d "$AXZSH/.git" && -n "$commands[git]" ]]; then
-               echo -n "Version: Git ID "
+               echo -n "Git Commit-ID "
                ( cd "$AXZSH" && git describe --always )
+       else
+               echo "unknown"
+       fi
+       echo -n "Active theme: "
+       if [[ -n "$AXZSH_THEME" ]]; then
+               echo "${AXZSH_THEME:A:t:r}"
+       else
+               echo "unknown"
        fi
        echo
        exit 0
@@ -48,6 +58,8 @@ function Usage {
        echo "    Disable plugin(s)."
        echo "  list-enabled"
        echo "    List enabled plugins."
+       echo "  plugin-help"
+       echo "    Show help text for a plugin (when provided by the plugin)."
        echo
        echo "  reset-plugins"
        echo "    Reset active plugins to the default set."
@@ -56,7 +68,7 @@ function Usage {
        echo "  check-plugins"
        echo "    Detect plugins which are \"useful\" on this system."
        echo
-       echo "  set-theme <name>|-"
+       echo "  set-theme {<name>|-}"
        echo "    Set active theme to <name>, or to the default."
        echo
        echo "  upgrade"
@@ -64,13 +76,25 @@ function Usage {
        echo "  update-caches"
        echo "    Force rebuild of all cache files."
        echo
+       echo "  help"
+       echo "    Show this help text."
+       echo "  version"
+       echo "    Show version and setup information."
+       echo
        exit 0
 }
 
 function UpdatePluginCache {
        [[ -r "$AXZSH/cache" ]] || return 0
 
-       [[ "$1" = "-v" ]] && ax_msg - "Updating plugin cache ..."
+       [[ "$1" = "-v" ]] && ax_msg - "Invalidating & updating caches ..."
+
+       if [[ -d "$ZSH_CACHE_DIR" ]]; then
+               [[ "$1" = "-v" ]] && echo "Removing ZSH cache folder ..."
+               rm -fr "$ZSH_CACHE_DIR"
+       fi
+
+       [[ "$1" = "-v" ]] && echo "Removing AX-ZSH cache files ..."
        rm -rf \
                $AXZSH/cache/ax-io.cache \
                $AXZSH/cache/zlogin.cache \
@@ -78,12 +102,15 @@ function UpdatePluginCache {
                $AXZSH/cache/zprofile.cache \
                $AXZSH/cache/zshrc.cache \
                || return 1
-       echo "Regenerating cache files ..."
-       zsh -ilc '' >/dev/null
+
+       echo "Regenerating AX-ZSH cache ..."
+       [[ -z "$AXZSH_DEBUG" ]] \
+               && AXZSH_PLUGIN_CHECK=1 zsh -ilc '' >/dev/null \
+               || AXZSH_PLUGIN_CHECK=1 zsh -ilc ''
 }
 
 function NormalizedPluginName {
-       if [[ "$1" =~ "^[[:alnum:]-]+/[[:alnum:]_-]+$" ]]; then
+       if [[ "$1" =~ "^@?[[:alnum:]-]+/[[:alnum:]_.-]+$" ]]; then
                echo "${1:gs/\//#}"
        elif [[ "$1" =~ "/" ]]; then
                echo "${1:t}"
@@ -97,6 +124,10 @@ function EnableAXZSH {
                ln -s "$AXZSH/ax.zsh" "$f" \
                        || ax_error "Failed to create symbolic link for \"$f\"!"
        done
+       if [[ -z "$AXZSH_FPATH" ]]; then
+               echo "AX-ZSH was enabled. Now you should restart your shell, for example like this:"
+               echo "$ exec -l \"\$SHELL\""
+       fi
 }
 
 function DisableAXZSH {
@@ -114,13 +145,27 @@ function DisableAXZSH {
 function EnablePlugin {
        local plugin=$(NormalizedPluginName "$1")
        local dir="$AXZSH/active_plugins"
+       local name="$plugin"
 
        if [[ -h "$dir/$plugin" ]]; then
                ax_msg 1 "Plugin \"$1\" already active!"
                return 1
        fi
 
-       if [[ "$1" =~ "^[[:alnum:]-]+/[[:alnum:]_-]+$" ]]; then
+       if [[ "$1" =~ "^@[[:alnum:]-]+/[[:alnum:]_.+-]+$" ]]; then
+               # GitHub plugin repository (like OhMyZsh)
+               local repo="${1##@}"
+               repo="${repo%/*}"
+               mkdir -p "$AXZSH/repos/@$repo"
+               if [[ ! -d "$AXZSH/repos/@$repo/plugins" ]]; then
+                       ax_msg - "Cloning \"$repo\" from GitHub ..."
+                       git clone --depth=1 "https://github.com/$repo/$repo.git" \
+                        "$AXZSH/repos/@$repo" \
+                               || ax_error "Failed to clone \"$repo\" repository!"
+               fi
+               plugin="@$repo/plugins/${1#*/}"
+               echo "Trying to enable \"$1\" ..."
+       elif [[ "$1" =~ "^[[:alnum:]-]+/[[:alnum:]_.-]+$" ]]; then
                # GitHub plugin
                mkdir -p "$AXZSH/repos"
                if [[ ! -e "$AXZSH/repos/$plugin" ]]; then
@@ -139,6 +184,9 @@ function EnablePlugin {
                        return 0
                fi
                echo "Trying to enable \"$1\" as plugin ..."
+       elif ! [[ "$1" =~ "^[[:alnum:]_.-]+$" ]]; then
+               ax_error "Invalid plugin name!"
+               return 1
        fi
 
        for dname (
@@ -155,12 +203,12 @@ function EnablePlugin {
                mkdir -p "$dir"
                if ! (
                        cd "$dir" || exit 9
-                       ln -s "$dname" "$PWD"
+                       ln -s "$dname" "$PWD/$name"
                ); then
                        ax_error "Failed to create link!"
                        return 1
                fi
-               ax_msg 0 "Plugin \"$plugin\" enabled."
+               ax_msg 0 "Plugin \"$1\" enabled."
                return 0
        done
 
@@ -204,6 +252,35 @@ function ListEnabledPlugins {
        return 0
 }
 
+function PluginHelp {
+       local plugin=$(NormalizedPluginName "$1")
+       local repo_plugin=$(echo "$plugin" | sed -e 's|#|/plugins/|')
+       local plugin_found=
+
+       for plugin_d (
+               "$plugin:A"
+               "$AXZSH/active_plugins/$plugin"
+               "$AXZSH/active_plugins/$repo_plugin"
+               "$AXZSH_PLUGIN_D/$plugin"
+               "$ZSH_CUSTOM/$plugin"
+               "$AXZSH/custom_plugins/$plugin"
+               "$AXZSH/repos/$plugin"
+               "$AXZSH/repos/$repo_plugin"
+               "$AXZSH/plugins/$plugin"
+               "$AXZSH/default_plugins/$plugin"
+               "$AXZSH/core/$plugin"
+       ); do
+               [[ -e "$plugin_d" ]] && plugin_found=1
+               [[ -r "$plugin_d/README.md" ]] || continue
+               less "$plugin_d/README.md"
+               return 0
+       done
+       [[ -n "$plugin_found" ]] \
+               && echo "Plugin \"$1\" found, but no help available!" >&2 \
+               || echo "Plugin \"$1\" not found!" >&2
+       return 1
+}
+
 function ResetPlugins {
        local dir="$AXZSH/active_plugins"
        local r1=0, r2=0
@@ -297,7 +374,12 @@ function UpgradeAXZSH {
        fi
 
        ax_msg - "Upgrading AX-ZSH in \"$AXZSH\" using git(1) ..."
-       ( cd "$AXZSH" && git pull --ff-only )
+       (
+               set -e
+               cd "$AXZSH"
+               git pull --ff-only || ax_error "Git pull failed!"
+               git log --pretty=format:"%C(yellow)%h %C(blue)%ar %C(green)%an %Creset%s" ORIG_HEAD..
+       )
 }
 
 function UpgradeForeignPlugins {
@@ -311,8 +393,10 @@ function UpgradeForeignPlugins {
                if [[ -d "$dir/.git" ]]; then
                        ax_msg - "Upgrading \"$name\" [git] ..."
                        (
+                               set -e
                                cd "$dir"
-                               git pull --ff-only || ax_error "Pull failed!"
+                               git pull --ff-only || ax_error "Git pull failed!"
+                               git log --pretty=format:"%C(yellow)%h %C(blue)%ar %C(green)%an %Creset%s" ORIG_HEAD..
                        )
                else
                        ax_error "Unknown repository type!"
@@ -324,25 +408,43 @@ function CheckPlugins {
        missing_plugins=()
        invalid_plugins=()
 
+       # Building cache file for all zshrc core files:
+       if ! T=$(mktemp); then
+               ax_error "Failed to create temporary file!"
+               return 1
+       fi
+       for p in $AXZSH/core/*/*.zshrc; do
+               [[ "$(basename "$p")" == "01_zprofile.zshrc" ]] && continue
+               printf "# BEGIN: %s\naxzsh_plugin_init()\n{\n" "$p" >>"$T"
+               cat "$p" >>"$T"
+               printf "}\naxzsh_plugin_init\n# END: %s\n\n" "$p" >>"$T"
+       done
+
        ax_msg - "Checking plugins ..."
-       for dir ($AXZSH/plugins/*(N)); do
+       for dir ($AXZSH/plugins/[a-z0-9]*(N)); do
                plugin=${dir:t}
 
                # Test if plugin is already enabled
-               [[ -e "$AXZSH/active_plugins/$plugin" ]] \
-                       && enabled=" (enabled)" \
-                       || unset enabled
+               if [[ -e "$AXZSH/active_plugins/$plugin" ]]; then
+                       printf ' \e[1;32m+\e[m "\e[1m%s\e[m" ... ' "${plugin}"
+                       enabled=1
+               else
+                       printf ' \e[1;31m-\e[m "%s" ... ' "${plugin}"
+                       unset enabled
+               fi
 
                # Test plugin ...
-               printf " - \"%s\"%s ... " "$plugin" "$enabled"
                new_plugin=""
-               for script ($AXZSH/plugins/$plugin/$plugin.{zshrc,zprofile}); do
+               for script ($AXZSH/plugins/$plugin/$plugin.{zshrc,zprofile,ax-io}); do
                        [[ -r "$script" ]] || continue
-                       AXZSH_PLUGIN_CHECK=1 zsh -i -c "source $script"; r=$?
-                       if [[ $r -eq 0 ]]; then
-                               new_plugin=$plugin
-                               break
-                       fi
+                       (
+                               AXZSH_PLUGIN_CHECK=1
+                               source "$T"
+                               axzsh_plugin_fnc() { source "$script" }
+                               axzsh_plugin_fnc
+                       ); r=$?
+                       [[ $r -eq 0 ]] && new_plugin=$plugin
+                       break
                done
                if [[ -n "$new_plugin" ]]; then
                        detected_plugins+=($new_plugin)
@@ -354,9 +456,10 @@ function CheckPlugins {
                        ax_msg 1 "optional."
                else
                        [[ -n "$enabled" ]] && invalid_plugins+=($plugin)
-                       ax_msg 2 "failed."
+                       ax_msg 2 "failed ($r)."
                fi
        done
+       rm -f "$T"
        echo
 
        result=0
@@ -423,6 +526,10 @@ case "$cmd" in
                [[ $# -eq 0 ]] || Usage
                ListEnabledPlugins
                ;;
+       "plugin-help")
+               [[ $# -eq 1 ]] || Usage
+               PluginHelp "$1"
+               ;;
        "reset-plugins")
                [[ $# -eq 0 ]] || Usage
                ResetPlugins
index 93a423d43e19b925460599d73cf115bf1c160be1..8e257cd46ca9159270c60145ff64b72b75fd9fc6 100644 (file)
@@ -1,38 +1,21 @@
 # AX-ZSH: Alex' Modular ZSH Configuration
-# 01_zprofile.zshrc: Make sure zpfofile files are read
+# 01_zprofile.zshrc: Make sure zprofile files are read
 
 [[ -z "$AXZSH_ZPROFILE_READ" ]] || return
 
-# No "zprofile" files have been read in already! So most probably this
-# ZSH instance hasn't been called from an ax-zsh enabled ZSH!
+# No "zprofile" (and "ax-io") stage files have been read in already, so looks
+# like this is a non-login shell instance but not a (direct) child of an AX-ZSH
+# enabled login shell! This can happen in graphical terminals not starting a
+# login shell, for example. So most probably some environment configuration is
+# missing and we have to make sure everything is set up properly by reading in
+# the "ax-io" and "zprofile" stages before continuing!
+[[ -n "$AXZSH_DEBUG" ]] && echo "» 01_zprofile.zshrc:"
 
 # Reset some environment variables, that could contain "garbage" ...
 unset PS1
 
-[[ -n "$AXZSH_DEBUG" ]] && echo "» 01_zprofile.zsh:"
-
-if [[ -r "$AXZSH/cache/zprofile.cache" ]]; then
-       # Cache file exists, use it!
-       [[ -n "$AXZSH_DEBUG" ]] \
-               && echo "   - Reading cache file \"$AXZSH/cache/zprofile.cache\" ..."
-       source "$AXZSH/cache/zprofile.cache"
-else
-       # No cache file, so read plugins manually. The "plugin_list" can be
-       # empty, when the "zshrc" stage has been read in using the cache file,
-       # but there is no cache file for the "zprofile" stage. In that case
-       # the "plugin_list" must be assembled right now (see "ax.zsh" file!):
-       if [[ -z "$plugin_list" ]]; then
-               typeset -U plugin_list
-               plugin_list=(
-                       "$AXZSH/core/"[0-5]*
-                       "$AXZSH/active_plugins/"*(N)
-                       "$AXZSH/core/"[6-9]*
-               )
-       fi
-       for plugin ($plugin_list); do
-               axzsh_load_plugin "$plugin" "zprofile"
-       done
-fi
+axzsh_handle_stage "01_zprofile.zshrc" "ax-io"
+axzsh_handle_stage "01_zprofile.zshrc" "zprofile"
 AXZSH_ZPROFILE_READ=2
 
-[[ -n "$AXZSH_DEBUG" ]] && echo "» 01_zprofile.zsh (end)"
+[[ -n "$AXZSH_DEBUG" ]] && echo "» 01_zprofile.zshrc (end)"
index 33dafb1975c15e2235ae06a024b07b77670242ae..ac5a1fc037ebfa904228c7c2ce2da462c902bad9 100644 (file)
@@ -97,7 +97,7 @@ function axzsh_terminal_title_precmd {
        if [[ "$TERM_PROGRAM" == "Apple_Terminal" && "$TERM" != "screen"* ]]; then
                axzsh_terminal_set_icon_title "$LOGNAME@$SHORT_HOST"
                # Update CWD in Terminal.app
-               local url=$(echo "file://$HOSTNAME$PWD" | sed -e 's| |%20|g')
+               local url=$(echo "file://$HOST$PWD" | sed -e 's| |%20|g')
                printf '\e]7;%s\a' "$url"
        else
                axzsh_terminal_set_icon_title "$LOGNAME@$SHORT_HOST:$PWD"
index 689b67421db3ee4ac0ea91f6e392905e6be7b20a..df30eb9af2c36b543e714419265a1c8f93820163 100644 (file)
@@ -13,7 +13,7 @@ fix_locale() {
        locale="$1:r"
        encoding="$1:e"
 
-       if [[ -z "$1" || "$locale" =~ '.*_.*' || ${#locale%%_*} -ne 2 ]]; then
+       if [[ -z "$1" || "$locale" =~ '_' || ${#locale%%_*} -ne 2 ]]; then
                echo "$1"
        else
                locale="${locale:0:2}_${locale:0:2:u}"
@@ -28,7 +28,7 @@ unfunction fix_locale
 # Validate the locale(7) settings in interactive shells and try to mimic the
 # tset(1) behaviour.
 while true; do
-       lc_messages=$(locale 2>/dev/null | fgrep LC_MESSAGES | cut -d'=' -f2)
+       lc_messages=$(locale 2>/dev/null | grep -F LC_MESSAGES | cut -d'=' -f2)
        [[ "$lc_messages" = '"C"' && "$LANG" != 'C' && "$LC_ALL" != 'C' ]] && lc_messages=$LANG
        lc_messages=$lc_messages:gs/\"//
        locale=$lc_messages:r
@@ -45,10 +45,10 @@ while true; do
                break
        fi
 
-       echo "ax-zsh: unknown/unsupported locale ${lc_messages:-unknown}" >&2
+       echo "ax-zsh: Unknown/unsupported locale \"${lc_messages:-unknown}\"!" >&2
        unset locale
        while [[ -z "$locale" ]]; do
-               if ! read "locale?Locale? "; then
+               if ! read -r "locale?Locale? "; then
                        echo >&2
                        break 2
                fi
diff --git a/core/20_home/20_home.ax-io b/core/20_home/20_home.ax-io
new file mode 100644 (file)
index 0000000..a07c123
--- /dev/null
@@ -0,0 +1,9 @@
+# AX-ZSH: Alex' Modular ZSH Configuration
+# 20_home.ax-io: Setup (local) home directory
+
+[[ -d "/usr/local/home" && ! -d "/usr/local/home/$LOGNAME" ]] \
+       && mkdir -m 700 "/usr/local/home/$LOGNAME" >/dev/null 2>&1
+
+[[ -w "/usr/local/home/$LOGNAME" ]] \
+       && export LOCAL_HOME="/usr/local/home/$LOGNAME" \
+       || export LOCAL_HOME="$HOME"
diff --git a/core/20_home/20_home.zprofile b/core/20_home/20_home.zprofile
deleted file mode 100644 (file)
index 4bad86a..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-# AX-ZSH: Alex' Modular ZSH Configuration
-# 20_home.zprofile: Setup (local) home directory
-
-[[ -d "/usr/local/home" && ! -d "/usr/local/home/$LOGNAME" ]] \
-       && mkdir -m 700 "/usr/local/home/$LOGNAME" >/dev/null 2>&1
-
-[[ -w "/usr/local/home/$LOGNAME" ]] \
-       && export LOCAL_HOME="/usr/local/home/$LOGNAME" \
-       || export LOCAL_HOME="$HOME"
diff --git a/core/30_env/30_env.ax-io b/core/30_env/30_env.ax-io
new file mode 100644 (file)
index 0000000..2a2c839
--- /dev/null
@@ -0,0 +1,76 @@
+# AX-ZSH: Alex' Modular ZSH Configuration
+# 30_env.ax-io: Setup environment
+
+# Setup time zone
+if [[ -z "$TZ" && -r "/etc/timezone" ]]; then
+       TZ=$(<"/etc/timezone") export TZ
+fi
+
+# Validate temporary directory
+if [[ -z "$TMPDIR" || "$TMPDIR" = "/" ]]; then
+       if [[ -n "$XDG_RUNTIME_DIR" && -w "$XDG_RUNTIME_DIR" ]]; then
+               # The "runtime directory" is set for this user, good, so use
+               # it silently as the "temporary directory", too:
+               TMPDIR="$XDG_RUNTIME_DIR"
+       else
+               # Try to find a sane "temporary directory", but warn the user
+               # that this is a best guess only!
+               TMPDIR="$(dirname $(mktemp -ut tmp.XXXXXXXXXX))/"
+               [[ -z "$TMPDIR" || "$TMPDIR" = "/" ]] && TMPDIR="/tmp"
+               user_tmpdir="$TMPDIR$UID"
+               mkdir -p "$user_tmpdir" >/dev/null 2>&1
+               if [[ -w "$user_tmpdir" ]]; then
+                       TMPDIR="$user_tmpdir/"
+                       chmod 0700 "$TMPDIR"
+               fi
+               echo "Note: \"TMPDIR\" was not set, using \"$TMPDIR\"." >&2
+               unset user_tmpdir
+       fi
+fi
+# Make sure TMPDIR ends in a slash (like on macOS by default): this makes its
+# usage a bit safer ...
+case "$TMPDIR" in
+       */) ;;
+       *)  TMPDIR="$TMPDIR/"
+esac
+if [[ ! -w "$TMPDIR" ]]; then
+       echo "Warning: Temporary directory \"$TMPDIR\" is not writable!" >&2
+fi
+export TMPDIR
+
+# TMPDIR is the only one required to be set, but make sure that TMP, TEMP
+# and TEMPDIR are set to the same sane path name when already present in the
+# environment:
+[[ -n "$TMP" ]] && export TMP="$TMPDIR"
+[[ -n "$TEMP" ]] && export TEMP="$TMPDIR"
+[[ -n "$TEMPDIR" ]] && export TEMPDIR="$TMPDIR"
+
+# Setup XDG cache directory
+if [[ -z "$XDG_CACHE_HOME" ]]; then
+       XDG_CACHE_HOME="$LOCAL_HOME/.cache"
+fi
+if [[ ! -d "$XDG_CACHE_HOME" ]]; then
+       mkdir -p "$XDG_CACHE_HOME"
+       chmod 0700 "$XDG_CACHE_HOME"
+fi
+export XDG_CACHE_HOME
+
+# Setup XDG runtime directory
+if [[ -z "$XDG_RUNTIME_DIR" ]]; then
+       XDG_RUNTIME_DIR="$TMPDIR/runtime-dir.$UID"
+fi
+if [[ ! -d "$XDG_RUNTIME_DIR" ]]; then
+       mkdir -p "$XDG_RUNTIME_DIR"
+       chmod 0700 "$XDG_RUNTIME_DIR"
+fi
+export XDG_RUNTIME_DIR
+
+# Setup ZSH cache directory
+if [[ -z "$ZSH_CACHE_DIR" ]]; then
+       ZSH_CACHE_DIR="$XDG_CACHE_HOME/zsh"
+fi
+if [[ ! -d "$ZSH_CACHE_DIR" ]]; then
+       mkdir -p "$ZSH_CACHE_DIR"
+       chmod 0700 "$ZSH_CACHE_DIR"
+fi
+export ZSH_CACHE_DIR
diff --git a/core/30_env/30_env.zprofile b/core/30_env/30_env.zprofile
deleted file mode 100644 (file)
index 781a9ec..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-# AX-ZSH: Alex' Modular ZSH Configuration
-# 30_env.zprofile: Setup environment
-
-# Setup time zone
-if [[ -z "$TZ" && -r "/etc/timezone" ]]; then
-       TZ=$(<"/etc/timezone") export TZ
-fi
-
-# Setup XDG cache directory
-if [[ -z "$XDG_CACHE_HOME" ]]; then
-       XDG_CACHE_HOME="$LOCAL_HOME/.cache"
-fi
-if [[ ! -d "$XDG_CACHE_HOME" ]]; then
-       mkdir -p "$XDG_CACHE_HOME"
-       chmod 0700 "$XDG_CACHE_HOME"
-fi
-export XDG_CACHE_HOME
-
-# Setup XDG runtime directory
-if [[ -z "$XDG_RUNTIME_DIR" ]]; then
-       XDG_RUNTIME_DIR="${TMPDIR:-/tmp/${UID}-runtime-dir}"
-fi
-if [[ ! -d "$XDG_RUNTIME_DIR" ]]; then
-       mkdir -p "$XDG_RUNTIME_DIR"
-       chmod 0700 "$XDG_RUNTIME_DIR"
-fi
-export XDG_RUNTIME_DIR
-
-# Setup ZSH cache directory
-if [[ -z "$ZSH_CACHE_DIR" ]]; then
-       ZSH_CACHE_DIR="$XDG_CACHE_HOME/zsh"
-fi
-if [[ ! -d "$ZSH_CACHE_DIR" ]]; then
-       mkdir -p "$ZSH_CACHE_DIR"
-       chmod 0700 "$ZSH_CACHE_DIR"
-fi
-export ZSH_CACHE_DIR
index b8ee8338f6a501a5dc5e11de2b1182f7b99fe69d..cac098a194cde4d1b5be0b02946a574da780ada8 100644 (file)
@@ -1,13 +1,14 @@
 # AX-ZSH: Alex' Modular ZSH Configuration
-# 30_env.zshrc: Setup environment
+# 30_env.ax-io: Setup environment
 
-# Setup TMPDIR. Try to reset TMPDIR (when it is not set but TMP is), which is
-# common in tools like screen(1) because Linux removes some varibes for
-# "setgit" tools (see <https://bugzilla.redhat.com/show_bug.cgi?id=129682#c1>).
-# And therefore this has to be checked here, because inside of screen probably
-# no login shell is started ...
-[[ -z "$TMPDIR" && -n "$TMP" ]] && TMPDIR="$TMP"
-
-# Make sure TMP and TMPDIR become exported when they are set:
-[[ -n "$TMP" ]] && export TMP
-[[ -n "$TMPDIR" ]] && export TMPDIR
+if [[
+       "$TMPDIR" = '/' ||
+       -z "$TMPDIR" ||
+       -z "$XDG_CACHE_HOME" ||
+       -z "$XDG_RUNTIME_DIR" ||
+       -z "$ZSH_CACHE_DIR"
+]]; then
+       # Looks like the environment wasn't set up/exported properly!
+       [[ -n "$AXZSH_DEBUG" ]] && echo 'Note: Fixing up the environment!'
+       . "$AXZSH/core/30_env/30_env.ax-io"
+fi
index 5b2dbd3faa15899af1295095b6f2cfd451f0bdf1..e2d0699af2daf9a7064f1d2325e259bae58a5fe9 100644 (file)
@@ -1,8 +1,8 @@
 # AX-ZSH: Alex' Modular ZSH Configuration
 # 30_hostname.zprofile: Initialize hostname settings
 
-# Setup "HOSTNAME" variable
-[[ -z "$HOSTNAME" ]] && HOSTNAME=$( hostname )
+# Setup legacy "HOSTNAME" variable (use "HOST"!)
+[[ -z "$HOSTNAME" ]] && HOSTNAME="$HOST"
 export HOSTNAME
 
 # Setup "SHORT_HOST" variable
diff --git a/core/30_path/30_path.zprofile b/core/30_path/30_path.zprofile
new file mode 100644 (file)
index 0000000..0dbd256
--- /dev/null
@@ -0,0 +1,60 @@
+# AX-ZSH: Alex' Modular ZSH Configuration
+# 30_path.zprofile: Setup PATH environment
+
+# Set default PATH
+if [[ -x /usr/libexec/path_helper ]]; then
+       eval "$(/usr/libexec/path_helper)"
+else
+       PATH="/usr/sbin:/usr/bin:/sbin:/bin"
+fi
+typeset -Ux PATH
+
+_axzsh_setup_path() {
+       # Prepend additional search paths
+       for d (
+               /Developer/usr/bin
+               /usr/ucb
+               /usr/pkg/bin
+               /usr/local/bin
+               /usr/local/sbin
+               /opt/*/bin(NOn)
+               /opt/*/sbin(NOn)
+               ~/.gem/ruby/*/bin(NOn)
+               ~/.go/bin
+               ~/.cargo/bin
+               ~/.local/bin
+               ~/bin
+               ~/sbin
+               ~/Applications
+       ); do
+               [[ -d "$d" ]] && path=("$d" $path)
+       done
+
+       # Append additional search paths
+       for d (
+               /usr/X11/bin
+               /usr/local/games
+               /usr/games
+       ); do
+               [[ -d "$d" ]] && path=($path "$d")
+       done
+}
+
+# Prepend and append search paths (in a special order!)
+_axzsh_setup_path
+
+# Set default MANPATH
+MANPATH="$(manpath -q)" 2>/dev/null
+if [[ $? -ne 0 ]]; then
+       for d (
+               ~/share/man
+               ~/man
+               /opt/*/share/man(NOn)
+               /opt/*/man(NOn)
+               /usr/share/man
+               /usr/local/share/man
+       ); do
+               [[ -d "$d" ]] && manpath=($manpath "$d")
+       done
+fi
+typeset -Ux MANPATH
diff --git a/core/40_axzsh/40_axzsh.zshrc b/core/40_axzsh/40_axzsh.zshrc
new file mode 100644 (file)
index 0000000..ea262e6
--- /dev/null
@@ -0,0 +1,24 @@
+# AX-ZSH: Alex' Modular ZSH Configuration
+# 50_axzsh.zshrc: Initialize AX-ZSH
+
+function axzshctl() {
+       AXZSH_THEME="$AXZSH_THEME" zsh "$AXZSH/bin/axzshctl" "$@" || return $?
+
+       if [[ "$1" = "disable" ]]; then
+               unset AXZSH AXZSH_FPATH AXZSH_ZLOGIN_READ AXZSH_ZPROFILE_READ
+       fi
+
+       case "$1" in
+               "disable"*|"enable"*|"reset"*|"set"*|"up"*)
+                       # Command which potentially "changed state".
+                       if [[ -o login ]]; then
+                               echo "Restarting login shell ..."
+                               exec -l "$SHELL"
+                       else
+                               echo "Restarting shell ..."
+                               exec "$SHELL"
+                       fi
+                       ;;
+       esac
+       return 0
+}
diff --git a/core/40_axzsh/functions/_axzsh b/core/40_axzsh/functions/_axzsh
new file mode 100644 (file)
index 0000000..a403579
--- /dev/null
@@ -0,0 +1,54 @@
+#compdef axzshctl
+
+_axzshctl() {
+       _arguments \
+               '1: :((
+                       enable\:"Enable AX-ZSH."
+                       disable\:"Disable AX-ZSH."
+                       enable-plugin\:"Enable plugin(s)."
+                       disable-plugin\:"Disable plugin(s)."
+                       list-enabled\:"List enabled plugin(s)."
+                       plugin-help\:"Show help text for a plugin."
+                       reset-plugins\:"Reset active plugins to the default set."
+                       enable-default-plugins\:"Enable all default plugins."
+                       check-plugins\:"Check \"useful\" plugins."
+                       set-theme\:"Set active theme."
+                       upgrade\:"Upgrade AX-ZSH installation (requires Git)."
+                       update-caches\:"Force rebuild of all cache files."
+                       version\:"Show version and setup information."
+                       help\:"Show help for the axzshctl command."
+               ))' \
+               '*: :->args'
+#
+       case "$state" in
+         'args')
+               case "$words[2]" in
+                 "enable-plugin"|"plugin-help")
+                       compadd "$@" -- \
+                               "$AXZSH"/plugins/*(/:t) \
+                               "$AXZSH"/custom_plugins/*(N/:t) \
+                               "$AXZSH"/repos/*(/:t:s/#/\\/)
+                       for r in "$AXZSH"/repos/@*(N/); do
+                               b=(echo $r(:t))
+                               compadd "$@" -- \
+                                       $(echo $r/plugins/*(N:t) | sed -E "s/(^| )/ $b\//g")
+                       done
+                       ;;
+                 "disable-plugin")
+                       compadd "$@" -- \
+                               "$AXZSH"/active_plugins/*(:t:s/#/\\/)
+                       ;;
+                 "set-theme")
+                       compadd "$@" -- "-" \
+                               "$AXZSH"/themes/*.axzshtheme(:r:t) \
+                               "$AXZSH"/custom_themes/*.axzshtheme(N:r:t) \
+                               "$AXZSH"/custom_themes/*.zsh-theme(N:r:t) \
+                               "$AXZSH"/repos/*/*.axzshtheme(N:r:t) \
+                               "$AXZSH"/repos/*/*.zsh-theme(N:r:t)
+                       ;;
+               esac
+               ;;
+       esac
+}
+
+_axzshctl "$@"
diff --git a/core/40_completion/40_completion.zshrc b/core/40_completion/40_completion.zshrc
new file mode 100644 (file)
index 0000000..c7a6a77
--- /dev/null
@@ -0,0 +1,72 @@
+# AX-ZSH: Alex' Modular ZSH Configuration
+# 50_completion.zshrc: Setup completion
+
+autoload -Uz compinit
+
+zstyle ':completion:*' completer _expand _complete _ignored _correct _approximate
+
+zstyle ':completion:*' accept-exact '*(N)'
+zstyle ':completion:*' list-colors ''
+zstyle ':completion:*' menu select
+zstyle ':completion:*' special-dirs true
+zstyle ':completion:*' group-name ''
+zstyle ':completion:*' squeeze-slashes true
+
+# Messages
+zstyle ':completion:*:corrections' format '%B%d%b (%e errors)'
+zstyle ':completion:*:descriptions' format '%B%d%b'
+zstyle ':completion:*:messages' format '%B%F{yellow}%d%f%b'
+zstyle ':completion:*:warnings' format '%B%F{red}No matches found!%f%b'
+
+# Use caching so that commands like apt and dpkg completions are useable
+zstyle ':completion:*' use-cache on
+zstyle ':completion:*' cache-path "$ZSH_CACHE_DIR"
+
+# Manual pages
+zstyle ':completion:*:manuals' separate-sections true
+zstyle ':completion:*:manuals.*' insert-sections true
+
+# Don't complete uninteresting users
+zstyle ':completion:*:*:*:users' ignored-patterns \
+       adm amanda amavis apache arpwatch at avahi avahi-autoipd backup \
+       beaglidx bin bind cacti canna clamav cockpit-ws cockpit-wsinstance \
+       colord daapd daemon dbus distcache dnsmasq dovecot dovenull fax \
+       fetchmail firebird ftp games gdm gkrellmd gnats gopher hacluster \
+       haldaemon halt hsqldb ident irc junkbust kdm ldap libuuid libvirt-qemu \
+       list logcheck lp mail mailman mailnull man messagebus mldonkey mysql \
+       nagios named netdata netdump news nfsnobody nobody nscd ntp nut nx \
+       obsrun oident openvpn operator pcap polkitd postfix postgres postgrey \
+       privoxy proxy pvm quagga radvd rpc rpcuser rpm rslsync rtkit rwhod \
+       sbuild scard shutdown squid sshd statd stunnel4 svn sync sys \
+       systemd-coredump systemd-journal-remote systemd-network systemd-resolve \
+       systemd-timesync telnetd telnetd-ssl tftp thelounge usbmux uucp uuidd \
+       vcsa www-data wwwrun xfs xrdp zabbix  \
+       '_*' '*$' 'debian-*' 'Debian-*'
+
+# Ignore completion functions
+zstyle ':completion:*:functions' ignored-patterns '_*'
+
+# Show ignore matches, if we really want this
+zstyle '*' single-ignored show
+
+# Save the location of the current completion dump file.
+if [[ -z "$ZSH_COMPDUMP" ]]; then
+       ZSH_COMPDUMP="$ZSH_CACHE_DIR/zcompdump-${SHORT_HOST}-${ZSH_VERSION}"
+fi
+
+# Try to add all folders possibly containing completion functions to the fpath
+# before calling compinit. See <https://github.com/ohmyzsh/ohmyzsh/issues/4614>
+# for a discussion of this topic, for example. It boils down to:
+# - We have to call compinit early,
+# - but plugins can add completions later, that won't be found ...
+# (GENCOMPL_FPATH is used by RobSis/zsh-completion-generator)
+[[ -n "$GENCOMPL_FPATH" ]] && fpath+=($GENCOMPL_FPATH)
+fpath+=("$AXZSH/active_plugins/"*/completions(N))
+fpath+=("$AXZSH/active_plugins/"*/src(N))
+
+# Initialize ZSH completion system
+if [[ "$ZSH_DISABLE_COMPFIX" = "true" ]]; then
+       compinit -u -d "$ZSH_COMPDUMP"
+else
+       compinit -d "$ZSH_COMPDUMP"
+fi
diff --git a/core/40_path/40_path.zprofile b/core/40_path/40_path.zprofile
deleted file mode 100644 (file)
index 407f3e8..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-# AX-ZSH: Alex' Modular ZSH Configuration
-# 40_path.zprofile: Setup PATH environment
-
-# Set default PATH
-if [[ -x /usr/libexec/path_helper ]]; then
-       eval "$(/usr/libexec/path_helper)"
-else
-       PATH="/usr/sbin:/usr/bin:/sbin:/bin"
-fi
-typeset -Ux PATH
-
-# Prepend additional search paths
-for d (
-       /Developer/usr/bin
-       /usr/ucb
-       /usr/pkg/bin
-       /usr/local/bin
-       /usr/local/sbin
-       /opt/*/bin(NOn)
-       /opt/*/sbin(NOn)
-       /home/linuxbrew/.linuxbrew/bin
-       /home/linuxbrew/.linuxbrew/sbin
-       ~/.linuxbrew/bin
-       ~/.linuxbrew/sbin
-       ~/.gem/ruby/*/bin(NOn)
-       ~/.local/bin
-       ~/bin
-       ~/sbin
-       ~/Applications
-); do
-       [ -d "$d" ] && path=("$d" $path)
-done
-
-# Append additional search paths
-for d (
-       /usr/X11/bin
-       /usr/local/games
-       /usr/games
-); do
-       [ -d "$d" ] && path=($path "$d")
-done
-
-# Set default MANPATH
-MANPATH="$(manpath -q)" 2>/dev/null
-if [[ $? -ne 0 ]]; then
-       for d (
-               ~/share/man
-               ~/man
-               ~/.linuxbrew/share/man
-               /home/linuxbrew/.linuxbrew/share/man
-               /opt/*/share/man(NOn)
-               /opt/*/man(NOn)
-               /usr/share/man
-               /usr/local/share/man
-       ); do
-               [ -d "$d" ] && manpath=($manpath "$d")
-       done
-fi
-typeset -Ux MANPATH
diff --git a/core/40_prompt/40_prompt.zshrc b/core/40_prompt/40_prompt.zshrc
new file mode 100644 (file)
index 0000000..ea252fd
--- /dev/null
@@ -0,0 +1,111 @@
+# AX-ZSH: Alex' Modular ZSH Configuration
+# 50_prompt.zshrc: Setup default prompts
+
+# Some dummy functions (used by some OhMyZsh themes, for example) ...
+git_prompt_info(){ true; }
+git_prompt_status(){ true; }
+rvm_prompt_info(){ true; }
+
+# Logname ("user name")
+
+ZSH_THEME_LOGNAME_PROMPT_PREFIX_SPACING=""
+if (( $UID == 0 )); then
+       ZSH_THEME_LOGNAME_PROMPT_PREFIX="%{$fg_no_bold[red]%}" \
+       ZSH_THEME_LOGNAME_PROMPT_SUFFIX="%{$reset_color%}"
+else
+       ZSH_THEME_LOGNAME_PROMPT_PREFIX=""
+       ZSH_THEME_LOGNAME_PROMPT_SUFFIX=""
+fi
+ZSH_THEME_LOGNAME_PROMPT_SUFFIX_SPACING="@"
+
+function axzsh_logname_prompt_root() {
+       (( $UID == 0 )) || return 1
+       return 0
+}
+
+function axzsh_logname_prompt_yn() {
+       local func
+       for func ($axzsh_logname_prompt_functions); do
+               $func || continue
+               echo "${ZSH_THEME_LOGNAME_PROMPT_PREFIX_SPACING}${ZSH_THEME_LOGNAME_PROMPT_PREFIX}${1:-$LOGNAME}${ZSH_THEME_LOGNAME_PROMPT_SUFFIX}${ZSH_THEME_LOGNAME_PROMPT_SUFFIX_SPACING}"
+               return
+       done
+}
+
+# Hostname
+
+ZSH_THEME_HOSTNAME_PROMPT_PREFIX_SPACING=""
+ZSH_THEME_HOSTNAME_PROMPT_PREFIX=""
+ZSH_THEME_HOSTNAME_PROMPT_SUFFIX=""
+ZSH_THEME_HOSTNAME_PROMPT_SUFFIX_SPACING=":"
+
+function axzsh_hostname_prompt_root() {
+       (( $UID == 0 )) || return 1
+       return 0
+}
+
+function axzsh_hostname_prompt_yn() {
+       local func
+       for func ($axzsh_hostname_prompt_functions); do
+               $func || continue
+               echo "${ZSH_THEME_HOSTNAME_PROMPT_PREFIX_SPACING}${ZSH_THEME_HOSTNAME_PROMPT_PREFIX}${1:-$SHORT_HOST}${ZSH_THEME_HOSTNAME_PROMPT_SUFFIX}${ZSH_THEME_HOSTNAME_PROMPT_SUFFIX_SPACING}"
+               return
+       done
+}
+
+axzsh_hostname_prompt_functions=()
+
+# VCS
+
+if axzsh_is_utf_terminal; then
+       clean="✔"; dirty="✘"; ahead="→"; behind="←"
+else
+       clean="+"; dirty="x"; ahead=">"; behind="<"
+fi
+
+ZSH_THEME_VCS_PROMPT_PREFIX_SPACING="("
+ZSH_THEME_VCS_PROMPT_PREFIX="%{$fg_no_bold[yellow]%}"
+ZSH_THEME_VCS_PROMPT_SUFFIX="%{$fg[default]%}"
+ZSH_THEME_VCS_PROMPT_SUFFIX_SPACING=")"
+
+ZSH_THEME_VCS_PROMPT_CLEAN=" %{$fg_no_bold[green]%}$clean%{$fg[default]%}"
+ZSH_THEME_VCS_PROMPT_DIRTY=" %{$fg_no_bold[red]%}$dirty%{$fg[default]%}"
+ZSH_THEME_VCS_PROMPT_AHEAD="%{$fg_no_bold[cyan]%}$ahead%{$fg[default]%}"
+ZSH_THEME_VCS_PROMPT_BEHIND="%{$fg_no_bold[blue]%}$behind%{$fg[default]%}"
+
+unset clean dirty ahead behind
+
+function axzsh_vcs_prompt() {
+       local func
+       local p
+       for func ($axzsh_vcs_prompt_functions); do
+               p=$( $func ) || continue
+               echo "${ZSH_THEME_VCS_PROMPT_PREFIX_SPACING}${p}${ZSH_THEME_VCS_PROMPT_SUFFIX_SPACING}"
+               return
+       done
+}
+
+axzsh_vcs_prompt_functions=()
+
+# Prompt
+
+ZSH_THEME_PROMPT="$"
+ZSH_THEME_PROMPT_ROOT="#"
+
+ZSH_THEME_PROMPT_PREFIX_SPACING=""
+ZSH_THEME_PROMPT_PREFIX=""
+ZSH_THEME_PROMPT_ROOT_PREFIX=""
+ZSH_THEME_PROMPT_SUFFIX=""
+ZSH_THEME_PROMPT_SUFFIX_SPACING=""
+
+function axzsh_prompt() {
+       local p
+       (( $UID == 0 )) \
+               && p="${ZSH_THEME_PROMPT_ROOT_PREFIX}${ZSH_THEME_PROMPT_ROOT}" \
+               || p="${ZSH_THEME_PROMPT_PREFIX}${ZSH_THEME_PROMPT}"
+       echo "${ZSH_THEME_PROMPT_PREFIX_SPACING}${p}${ZSH_THEME_PROMPT_SUFFIX}${ZSH_THEME_PROMPT_SUFFIX_SPACING}"
+}
+
+# Options and defaults
+
+setopt PROMPT_SUBST
diff --git a/core/50_axzsh/50_axzsh.zshrc b/core/50_axzsh/50_axzsh.zshrc
deleted file mode 100644 (file)
index be6f0b8..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-# AX-ZSH: Alex' Modular ZSH Configuration
-# 50_axzsh.zshrc: Initialize AX-ZSH
-
-function axzshctl() {
-       zsh "$AXZSH/bin/axzshctl" "$@" || return $?
-
-       case "$1" in
-               "disable"*|"enable"*|"reset"*|"set"*|"up"*)
-                       # Command which potentially "changed state".
-                       if [[ -o login ]]; then
-                               echo "Restarting login shell ..."
-                               exec -l "$SHELL"
-                       else
-                               echo "Restarting shell ..."
-                               exec "$SHELL"
-                       fi
-                       ;;
-       esac
-       return 0
-}
diff --git a/core/50_axzsh/functions/_axzsh b/core/50_axzsh/functions/_axzsh
deleted file mode 100644 (file)
index 3c3d0c5..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-#compdef axzshctl
-
-_axzshctl() {
-       _arguments \
-               '1: :((
-                       enable\:"Enable AX-ZSH."
-                       disable\:"Disable AX-ZSH."
-                       enable-plugin\:"Enable plugin(s)."
-                       disable-plugin\:"Disable plugin(s)."
-                       list-enabled\:"List enabled plugin(s)."
-                       reset-plugins\:"Reset active plugins to the default set."
-                       enable-default-plugins\:"Enable all default plugins."
-                       check-plugins\:"Check \"useful\" plugins."
-                       set-theme\:"Set active theme."
-                       upgrade\:"Upgrade AX-ZSH installation (requires Git)."
-                       update-caches\:"Force rebuild of all cache files."
-               ))' \
-               '*: :->args'
-#
-       case "$state" in
-         'args')
-               case "$words[2]" in
-                 "enable-plugin"|"disable-plugin")
-                       compadd "$@" -- \
-                               "$AXZSH"/plugins/*(/:t) \
-                               "$AXZSH"/custom_plugins/*(N/:t) \
-                               "$AXZSH"/repos/*(/:t:s/#/\\/)
-                       ;;
-                 "set-theme")
-                       compadd "$@" -- "-" \
-                               "$AXZSH"/themes/*.axzshtheme(:r:t) \
-                               "$AXZSH"/custom_themes/*.axzshtheme(N:r:t) \
-                               "$AXZSH"/repos/*/*.zsh-theme(N:r:t)
-                       ;;
-               esac
-               ;;
-       esac
-}
-
-_axzshctl "$@"
diff --git a/core/50_completion/50_completion.zshrc b/core/50_completion/50_completion.zshrc
deleted file mode 100644 (file)
index 53fe50b..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-# AX-ZSH: Alex' Modular ZSH Configuration
-# 50_completion.zshrc: Setup completion
-
-autoload -Uz compinit
-
-zstyle ':completion:*' completer _expand _complete _ignored _correct _approximate
-
-zstyle ':completion:*' accept-exact '*(N)'
-zstyle ':completion:*' list-colors ''
-zstyle ':completion:*' menu select
-zstyle ':completion:*' special-dirs true
-zstyle ':completion:*' group-name ''
-zstyle ':completion:*' squeeze-slashes true
-
-# Messages
-zstyle ':completion:*:corrections' format '%B%d%b (%e errors)'
-zstyle ':completion:*:descriptions' format '%B%d%b'
-zstyle ':completion:*:messages' format '%B%F{yellow}%d%f%b'
-zstyle ':completion:*:warnings' format '%B%F{red}No matches found!%f%b'
-
-# Use caching so that commands like apt and dpkg completions are useable
-zstyle ':completion:*' use-cache on
-zstyle ':completion:*' cache-path "$ZSH_CACHE_DIR"
-
-# Manual pages
-zstyle ':completion:*:manuals' separate-sections true
-zstyle ':completion:*:manuals.*' insert-sections true
-
-# Don't complete uninteresting users
-zstyle ':completion:*:*:*:users' ignored-patterns \
-       adm amanda amavis apache arpwatch at avahi avahi-autoipd backup \
-       beaglidx bin bind cacti canna clamav cockpit-ws cockpit-wsinstance \
-       colord daapd daemon dbus distcache dnsmasq dovecot dovenull fax \
-       fetchmail firebird ftp games gdm gkrellmd gnats gopher hacluster \
-       haldaemon halt hsqldb ident irc junkbust kdm ldap libuuid libvirt-qemu \
-       list logcheck lp mail mailman mailnull man messagebus mldonkey mysql \
-       nagios named netdata netdump news nfsnobody nobody nscd ntp nut nx \
-       obsrun oident openvpn operator pcap polkitd postfix postgres postgrey \
-       privoxy proxy pvm quagga radvd rpc rpcuser rpm rslsync rtkit rwhod \
-       sbuild scard shutdown squid sshd statd stunnel4 svn sync sys \
-       systemd-coredump systemd-journal-remote systemd-network systemd-resolve \
-       systemd-timesync telnetd telnetd-ssl tftp thelounge usbmux uucp uuidd \
-       vcsa www-data wwwrun xfs xrdp zabbix  \
-       '_*' '*$' 'debian-*' 'Debian-*'
-
-# Ignore completion functions
-zstyle ':completion:*:functions' ignored-patterns '_*'
-
-# Show ignore matches, if we really want this
-zstyle '*' single-ignored show
-
-# Save the location of the current completion dump file.
-if [[ -z "$ZSH_COMPDUMP" ]]; then
-       ZSH_COMPDUMP="$ZSH_CACHE_DIR/zcompdump-${SHORT_HOST}-${ZSH_VERSION}"
-fi
-
-# Initialize ZSH completion system
-compinit -d "$ZSH_COMPDUMP"
diff --git a/core/50_path/50_path.zprofile b/core/50_path/50_path.zprofile
new file mode 100644 (file)
index 0000000..55a39e4
--- /dev/null
@@ -0,0 +1,8 @@
+# # AX-ZSH: Alex' Modular ZSH Configuration
+# 50_path.zprofile: Fix PATH environment after plugins ran
+
+# Prepend and append search paths (in a special order!)
+_axzsh_setup_path
+unfunction _axzsh_setup_path
+
+typeset -Ux PATH MANPATH
diff --git a/core/50_prompt/50_prompt.zshrc b/core/50_prompt/50_prompt.zshrc
deleted file mode 100644 (file)
index 7aaf053..0000000
+++ /dev/null
@@ -1,113 +0,0 @@
-# AX-ZSH: Alex' Modular ZSH Configuration
-# 50_prompt.zshrc: Setup default prompts
-
-# Some dummy functions (used by some OhMyZsh themes, for example) ...
-git_prompt_info(){ true; }
-git_prompt_status(){ true; }
-rvm_prompt_info(){ true; }
-
-# Logname ("user name")
-
-ZSH_THEME_LOGNAME_PROMPT_PREFIX_SPACING=""
-if (( $UID == 0 )); then
-       ZSH_THEME_LOGNAME_PROMPT_PREFIX="%{$fg_no_bold[red]%}" \
-       ZSH_THEME_LOGNAME_PROMPT_SUFFIX="%{$reset_color%}"
-else
-       ZSH_THEME_LOGNAME_PROMPT_PREFIX=""
-       ZSH_THEME_LOGNAME_PROMPT_SUFFIX=""
-fi
-ZSH_THEME_LOGNAME_PROMPT_SUFFIX_SPACING="@"
-
-function ax_logname_prompt_root() {
-       (( $UID == 0 )) || return 1
-       return 0
-}
-
-function ax_logname_prompt_yn() {
-       local func
-       for func ($ax_logname_prompt_functions); do
-               $func || continue
-               echo "${ZSH_THEME_LOGNAME_PROMPT_PREFIX_SPACING}${ZSH_THEME_LOGNAME_PROMPT_PREFIX}${1:-$LOGNAME}${ZSH_THEME_LOGNAME_PROMPT_SUFFIX}${ZSH_THEME_LOGNAME_PROMPT_SUFFIX_SPACING}"
-               return
-       done
-}
-
-ax_logname_prompt_functions=(ax_logname_prompt_root)
-
-# Hostname
-
-ZSH_THEME_HOSTNAME_PROMPT_PREFIX_SPACING=""
-ZSH_THEME_HOSTNAME_PROMPT_PREFIX=""
-ZSH_THEME_HOSTNAME_PROMPT_SUFFIX=""
-ZSH_THEME_HOSTNAME_PROMPT_SUFFIX_SPACING=":"
-
-function ax_hostname_prompt_root() {
-       (( $UID == 0 )) || return 1
-       return 0
-}
-
-function ax_hostname_prompt_yn() {
-       local func
-       for func ($ax_hostname_prompt_functions); do
-               $func || continue
-               echo "${ZSH_THEME_HOSTNAME_PROMPT_PREFIX_SPACING}${ZSH_THEME_HOSTNAME_PROMPT_PREFIX}${1:-$SHORT_HOST}${ZSH_THEME_HOSTNAME_PROMPT_SUFFIX}${ZSH_THEME_HOSTNAME_PROMPT_SUFFIX_SPACING}"
-               return
-       done
-}
-
-ax_hostname_prompt_functions=()
-
-# VCS
-
-if axzsh_is_utf_terminal; then
-       clean="✔"; dirty="✘"; ahead="→"; behind="←"
-else
-       clean="+"; dirty="x"; ahead=">"; behind="<"
-fi
-
-ZSH_THEME_VCS_PROMPT_PREFIX_SPACING="("
-ZSH_THEME_VCS_PROMPT_PREFIX="%{$fg_no_bold[yellow]%}"
-ZSH_THEME_VCS_PROMPT_SUFFIX="%{$fg[default]%}"
-ZSH_THEME_VCS_PROMPT_SUFFIX_SPACING=")"
-
-ZSH_THEME_VCS_PROMPT_CLEAN=" %{$fg_no_bold[green]%}$clean%{$fg[default]%}"
-ZSH_THEME_VCS_PROMPT_DIRTY=" %{$fg_no_bold[red]%}$dirty%{$fg[default]%}"
-ZSH_THEME_VCS_PROMPT_AHEAD="%{$fg_no_bold[cyan]%}$ahead%{$fg[default]%}"
-ZSH_THEME_VCS_PROMPT_BEHIND="%{$fg_no_bold[blue]%}$behind%{$fg[default]%}"
-
-unset clean dirty ahead behind
-
-function ax_vcs_prompt() {
-       local func
-       local p
-       for func ($ax_vcs_prompt_functions); do
-               p=$( $func ) || continue
-               echo "${ZSH_THEME_VCS_PROMPT_PREFIX_SPACING}${p}${ZSH_THEME_VCS_PROMPT_SUFFIX_SPACING}"
-               return
-       done
-}
-
-ax_vcs_prompt_functions=()
-
-# Prompt
-
-ZSH_THEME_PROMPT="$"
-ZSH_THEME_PROMPT_ROOT="#"
-
-ZSH_THEME_PROMPT_PREFIX_SPACING=""
-ZSH_THEME_PROMPT_PREFIX=""
-ZSH_THEME_PROMPT_ROOT_PREFIX=""
-ZSH_THEME_PROMPT_SUFFIX=""
-ZSH_THEME_PROMPT_SUFFIX_SPACING=""
-
-function ax_prompt() {
-       local p
-       (( $UID == 0 )) \
-               && p="${ZSH_THEME_PROMPT_ROOT_PREFIX}${ZSH_THEME_PROMPT_ROOT}" \
-               || p="${ZSH_THEME_PROMPT_PREFIX}${ZSH_THEME_PROMPT}"
-       echo "${ZSH_THEME_PROMPT_PREFIX_SPACING}${p}${ZSH_THEME_PROMPT_SUFFIX}${ZSH_THEME_PROMPT_SUFFIX_SPACING}"
-}
-
-# Options and defaults
-
-setopt PROMPT_SUBST
diff --git a/core/80_local_config/80_local_config.ax-io b/core/80_local_config/80_local_config.ax-io
new file mode 100644 (file)
index 0000000..2d8989d
--- /dev/null
@@ -0,0 +1,18 @@
+# AX-ZSH: Alex' Modular ZSH Configuration
+# 80_local_config.ax-io: Read local configuration
+
+if [[ -r "$HOME/.zprofile.local" ]]; then
+       [[ -n "$AXZSH_DEBUG" ]] && echo "» $HOME/.zprofile.local:"
+       source "$HOME/.zprofile.local"
+       [[ -n "$AXZSH_DEBUG" ]] && echo "» $HOME/.zprofile.local (end)"
+fi
+
+if [[ -r "/var/lib/$HOST/zprofile" ]]; then
+       [[ -n "$AXZSH_DEBUG" ]] && echo "» /var/lib/$HOST/zprofile:"
+       source "/var/lib/$HOST/zprofile"
+       [[ -n "$AXZSH_DEBUG" ]] && echo "» /var/lib/$HOST/zprofile (end)"
+elif [[ -r "/var/lib/$HOST/profile" ]]; then
+       [[ -n "$AXZSH_DEBUG" ]] && echo "» /var/lib/$HOST/profile:"
+       source "/var/lib/$HOST/profile"
+       [[ -n "$AXZSH_DEBUG" ]] && echo "» /var/lib/$HOST/profile (end)"
+fi
diff --git a/core/80_local_config/80_local_config.zprofile b/core/80_local_config/80_local_config.zprofile
deleted file mode 100644 (file)
index e6a9430..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-# AX-ZSH: Alex' Modular ZSH Configuration
-# 80_local_config.zprofile: Read local configuration
-
-if [[ -r "$HOME/.zprofile.local" ]]; then
-       [[ -n "$AXZSH_DEBUG" ]] && echo "» $HOME/.zprofile.local:"
-       source "$HOME/.zprofile.local"
-       [[ -n "$AXZSH_DEBUG" ]] && echo "» $HOME/.zprofile.local (end)"
-fi
-
-if [[ -r "/var/lib/$HOST/zprofile" ]]; then
-       [[ -n "$AXZSH_DEBUG" ]] && echo "» /var/lib/$HOST/zprofile:"
-       source "/var/lib/$HOST/zprofile"
-       [[ -n "$AXZSH_DEBUG" ]] && echo "» /var/lib/$HOST/zprofile (end)"
-elif [[ -r "/var/lib/$HOST/profile" ]]; then
-       [[ -n "$AXZSH_DEBUG" ]] && echo "» /var/lib/$HOST/profile:"
-       source "/var/lib/$HOST/profile"
-       [[ -n "$AXZSH_DEBUG" ]] && echo "» /var/lib/$HOST/profile (end)"
-fi
index 764466b36220bb0eabf98ba96556027528fee984..1971cd07084c77694cd41abf4f324a471d4e2cf0 100644 (file)
@@ -2,24 +2,24 @@
 # 99_cleanup.zlogin: Don't pollute the namespace, remove variables/functions/...
 
 for func (
-       ax_hostname_prompt_root
-       ax_hostname_prompt_yn
-       ax_logname_prompt_root
-       ax_logname_prompt_yn
-       ax_prompt
+       axzsh_hostname_prompt_root
+       axzsh_hostname_prompt_yn
+       axzsh_logname_prompt_root
+       axzsh_logname_prompt_yn
+       axzsh_prompt
 ); do
        unfunction $func 2>/dev/null
 done
 
-for func ($ax_logname_prompt_functions); do
+for func ($axzsh_logname_prompt_functions); do
        unfunction $func 2>/dev/null
 done
-unset ax_logname_prompt_functions
+unset axzsh_logname_prompt_functions
 
-for func ($ax_hostname_prompt_functions); do
+for func ($axzsh_hostname_prompt_functions); do
        unfunction $func 2>/dev/null
 done
-unset ax_hostname_prompt_functions
+unset axzsh_hostname_prompt_functions
 
 # Try to map OhMyZsh theme Environment ...
 [[ -n "$ZSH_THEME_GIT_PROMPT_AHEAD" ]] \
index bdb106b2bde5a47f50df4a60026a305b0b641e24..0133012a6fb98e8b6b9c5674adb9cbf06d5fcdcd 100644 (file)
@@ -1,14 +1,15 @@
 # AX-ZSH: Alex' Modular ZSH Configuration
-# 99_zlogin.zshrc: Make sure zpfofile files are read
+# 99_zlogin.zshrc: Make sure zlogin files are read
 
 [[ "$AXZSH_ZPROFILE_READ" = "2" ]] || return
 
-# No "zlogin" files have been read in already! So most probably this
-# ZSH instance hasn't been called from an ax-zsh enabled ZSH!
+# AXZSH_ZPROFILE_READ is set to 2 when the "ax-io" and "zprofile" were caught
+# up because this is not a login shell and the environment was missing. In this
+# case the "zlogin" stage will be missing in the end as well and therefore we
+# run the "zlogin" stage manually, too.
+[[ -n "$AXZSH_DEBUG" ]] && echo "» 99_zlogin.zshrc:"
 
-[[ -n "$AXZSH_DEBUG" ]] && echo "» 99_zlogin.zsh:"
-for plugin ($plugin_list); do
-       axzsh_load_plugin "$plugin" "zlogin"
-done
+axzsh_handle_stage "99_zlogin.zshrc" "zlogin"
 AXZSH_ZLOGIN_READ=2
-[[ -n "$AXZSH_DEBUG" ]] && echo "» 99_zlogin.zsh (end)"
+
+[[ -n "$AXZSH_DEBUG" ]] && echo "» 99_zlogin.zshrc (end)"
diff --git a/default_plugins/bash_completion/bash_completion.zshrc b/default_plugins/bash_completion/bash_completion.zshrc
deleted file mode 100644 (file)
index dc0e350..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-# AX-ZSH: Alex' Modular ZSH Configuration
-# bash_completion.zshrc: Setup bash(1) completion
-
-# Define some "dummy functions"
-_init_completion() { return 0 }
-
-autoload -Uz bashcompinit || return 1
-bashcompinit
-
-for dir (
-       /etc/bash_completion.d
-       /usr/local/etc/bash_completion.d
-); do
-       # Read in all completion functions ...
-       for file ("$dir/"*(N)); do
-               # Ignore errors ...
-               source "$file" 2>/dev/null
-       done
-done
-unset dir
index 3878014ca0eaa2919c8ac7d026ef86a08e2f6253..242b0db06b85d73d88017eb66a307ec96d8da00c 100644 (file)
@@ -2,6 +2,7 @@
 # byebye.zlogout -- Say goodbye to interactive users
 
 [[ -o interactive ]] || return
+[[ -n "$AXZSH_PLUGIN_CHECK" ]] || return 92
 
 # Clear the console if it is a local terminal
 case `tty` in
index 0fe13b60c1608161ff23813675cffd9ad174643f..7ddb321bcd5b2b1accaec1edd242e451ea7e3681 100644 (file)
@@ -1,6 +1,15 @@
 # AX-ZSH: Alex' Modular ZSH Configuration
 # cheat: Setup https://cht.sh
 
+if (( $+commands[fzf] )); then
+       # See <https://twitter.com/igor_chubin/status/1343294742315020293>
+       function c() {
+               url="https://cht.sh"
+               term=$(curl -ks "$url/:list" | IFS=+ fzf --preview "curl -ks '$url/{}'" -q "$*") \
+                       && curl -ks "$url/${term}" | ${PAGER:-less}
+       }
+fi
+
 # Don't overwrite a real "cheat" command!
 (( $+commands[cheat] )) && return
 
index 49946d476729c992ac17fb54ed0e42b8cd930206..1c2bf378950630e0dea361343097c06b9ff1ab06 100644 (file)
@@ -1,13 +1,13 @@
 # AX-ZSH: Alex' Modular ZSH Configuration
 # history.zshrc: Setup ZSH history
 
-if [[ -z "$HISTFILE" ]]; then
-       # Save history file in cache directory, if not already present
-       # in $ZDOTDIR/$HOME:
-       [ -r "${ZDOTDIR:-$HOME}/.zsh_history" ] \
-               && HISTFILE="${ZDOTDIR:-$HOME}/.zsh_history" \
-               || HISTFILE="$ZSH_CACHE_DIR/history"
-fi
+function clear_history {
+       local HISTSIZE=0
+       cat /dev/null >"$HISTFILE"
+       fc -R
+}
+
+[[ -n "$HISTFILE" ]] || HISTFILE="${ZDOTDIR:-$HOME}/.zsh_history"
 
 HISTSIZE=10000
 SAVEHIST=10000
index 1c473e5a4d671709238319d8b5b99759041c2631..aa3d17c9226b1853e90c086ffbbdf49c78054e75 100644 (file)
@@ -4,6 +4,7 @@
 # Make sure that "less(1)" is installed
 (( $+commands[less] )) || return
 
+export PAGER="$commands[less]"
 export LESS="-FmRX"
 
 # Support colors in less
@@ -20,5 +21,5 @@ if (( $+commands[lesspipe] )); then
 elif (( $+commands[lesspipe.sh] )); then
        # Silence lesspipe(1), see <https://github.com/wofr06/lesspipe/issues/21>
        export LESSQUIET=1
-       eval "$(lesspipe.sh)"
+       eval "$(lesspipe.sh 2>/dev/null)"
 fi
index 1afc7f469116c1996f816127ca176add79dff17a..d275b06a3f00424e1016f407caf38066c0d851ab 100644 (file)
@@ -15,13 +15,13 @@ ssh-autoadd() {
        ssh-add
 }
 
-_ax_ssh_prompt() {
+_axzsh_ssh_prompt() {
        [[ -n "$SSH_CLIENT" ]] || return 1
        return 0
 }
 
-ax_logname_prompt_functions=($ax_logname_prompt_functions _ax_ssh_prompt)
-ax_hostname_prompt_functions=($ax_hostname_prompt_functions _ax_ssh_prompt)
+axzsh_logname_prompt_functions=($axzsh_logname_prompt_functions _axzsh_ssh_prompt)
+axzsh_hostname_prompt_functions=($axzsh_hostname_prompt_functions _axzsh_ssh_prompt)
 
 # Validate SSH_AUTH_SOCK: Inside of screen(1) sessions for example, the socket
 # file becomes invalid when the session has been disconnected.
@@ -42,8 +42,9 @@ fi
 
 # Save SSH environment when available:
 if [[ -n "$SSH_AUTH_SOCK" && -d "$XDG_RUNTIME_DIR" ]]; then
-       # Save current environment when no state exists or is invalid.
+       # Save current environment when no state exists or state file is invalid.
        if [[ -r "$XDG_RUNTIME_DIR/ssh-env.sh" ]]; then
+               # Check existing state file ...
                (
                        source "$XDG_RUNTIME_DIR/ssh-env.sh"
                        if [[ -z "$SSH_AUTH_SOCK" || ! -r "$SSH_AUTH_SOCK" ]]; then
index 74377d14ae96c875d6515d03adfa89f25d30bd74..51c8f1f1f43389060fb3bc0c84df582f86e1b522 100644 (file)
@@ -2,10 +2,12 @@
 # std_aliases: Setup standard aliases
 
 alias ll="ls -hl"
-alias l="ll -a"
+alias l="ls -ahl"
+alias la="ls -Ahl"
+alias lx="ls -A"
 
-alias lasth='last | head -n "$((LINES-1))"'
-alias lastf='last | grep -v "^$LOGNAME"'
+alias lasth='last -aw | head -n "$((LINES-1))"'
+alias lastf='last -aw | grep -v "^$LOGNAME"'
 
 alias d='dirs -v | head -10'
 alias 1='cd ~1 && pwd'
@@ -17,3 +19,23 @@ alias 6='cd ~6 && pwd'
 alias 7='cd ~7 && pwd'
 alias 8='cd ~8 && pwd'
 alias 9='cd ~9 && pwd'
+alias -- -='cd -'
+
+alias md='mkdir -p'
+alias rd=rmdir
+
+# Global aliases
+
+alias -g C="| cut -d' '"
+alias -g G="| grep -i"
+alias -g H="| head"
+alias -g L="| less"
+alias -g LL="2>&1 | less"
+alias -g NUL=">/dev/null 2>&1"
+alias -g T="| tail"
+alias -g WL="| wc -l"
+alias -g X="| xargs"
+
+# Suffix aliases
+
+alias -s {c,cfg,conf,css,h,html,ini,json,md,me,rc,txt,yml,yaml}="$EDITOR"
index 7321cf8e89bc1dbefccaf68a8456237f1ce6b0d3..74c26f1228ea3c7d02f52ebfb2a8ac6d6396e497 100644 (file)
@@ -3,4 +3,7 @@
 
 export CLICOLOR=${CLICOLOR:-1}
 export MANWIDTH=${MANWIDTH:-80}
-export REPORTTIME=${REPORTTIME:-5}
+
+if [[ "$TERM_PROGRAM" != "WarpTerminal" ]]; then
+       export REPORTTIME=${REPORTTIME:-5}
+fi
index fd3378a29a2196e7f877c3040ca7398c631d42fe..47ca9123062a867099222e7139de76db172cebd2 100644 (file)
@@ -1,8 +1,49 @@
 # AX-ZSH: Alex' Modular ZSH Configuration
 # std_functions: Setup standard ("common") functions
 
+function open_command() {
+       case $OSTYPE in
+               darwin*)
+                       open "$@" || return 1
+                       ;;
+               cygwin*)
+                       cygstart "$@" || return 1
+                       ;;
+               linux*)
+                       if [[ -n "$DISPLAY" ]]; then
+                               # X11
+                               nohup xdg-open "$@" &>/dev/null || return 1
+                       else
+                               xdg-open "$@" || return 1
+                       fi
+                       ;;
+               *)
+                       return 2
+       esac
+       return 0
+}
+
 function take() {
-       mkdir -p "$@" && cd "${@:$#}"
+       if [[ $# -eq 0 ]]; then
+               cd "$(mktemp -d)"
+               pwd
+       else
+               mkdir -p "$@" && cd "${@:$#}"
+       fi
+}
+
+function untake() {
+       pwd="${PWD}/"
+       subdir="${pwd##$TMPDIR}"
+       if [[ "${PWD%tmp.*}" = "${TMPDIR}" && -n "$subdir" ]]; then
+               tmp_d="${TMPDIR}${subdir%%/*}"
+               echo "$tmp_d"
+               cd
+               rm -fr "$@" "${tmp_d}"
+       else
+               echo 'Sorry, not a temporarily taken directory!' >&2
+               return 1
+       fi
 }
 
 function zsh_stats() {
index 782e4cf761c3892adcdb38a11b283ff92231af69..6d7b22a2490bda835f9d6e98ddfe5894d4973451 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 #
 # AX-ZSH: Alex' Modular ZSH Configuration
-# Copyright (c) 2015 Alexander Barton <alex@barton.de>
+# Copyright (c) 2015-2022 Alexander Barton <alex@barton.de>
 #
 
 # Include "ax-common.sh":
@@ -35,7 +35,7 @@ abort() {
 
 umask 027
 
-[ -n "$AXZSH" ] || AXZSH="$HOME/.axzsh"
+[ -n "$AXZSH" ] || AXZSH="${ZDOTDIR:-$HOME}/.axzsh"
 export AXZSH
 
 S=$(dirname "$0")
@@ -79,7 +79,12 @@ mkdir -p "$AXZSH/custom_themes" || abort
 
 ax_msg - "Linking ZSH startup files ..."
 
-for f in ~/.zlogin ~/.zlogout ~/.zprofile ~/.zshrc; do
+for f in \
+       ${ZDOTDIR:-$HOME}/.zlogin \
+       ${ZDOTDIR:-$HOME}/.zlogout \
+       ${ZDOTDIR:-$HOME}/.zprofile \
+       ${ZDOTDIR:-$HOME}/.zshrc \
+; do
        safe_rm "$f" || abort
        ln -sv "$AXZSH/ax.zsh" "$f" || abort
 done
@@ -90,6 +95,7 @@ if [ ! -d "$AXZSH/active_plugins" ]; then
                zsh "$AXZSH/bin/axzshctl" reset-plugins || abort
        else
                ax_msg 1 "Oops, \"zsh\" not found!?"
+               exit 1
        fi
 else
        ax_msg - "Plugin directory \"$AXZSH/active_plugins\" already exists. Ok."
diff --git a/plugins/00-newline/00-newline.ax-io b/plugins/00-newline/00-newline.ax-io
new file mode 100644 (file)
index 0000000..3d43d75
--- /dev/null
@@ -0,0 +1,10 @@
+# AX-ZSH: Alex' Modular ZSH Configuration
+# 00-newline.ax-io: Print an empty line ...
+
+# Don't run this plugin on "check-plugins"!
+[[ -z "$AXZSH_PLUGIN_CHECK" ]] || return 92
+
+# Don't output anything ~/.hushlogin exists ...
+[[ -r ~/.hushlogin ]] && return 0
+
+echo
diff --git a/plugins/00-newline/README.md b/plugins/00-newline/README.md
new file mode 100644 (file)
index 0000000..3fd5fa8
--- /dev/null
@@ -0,0 +1,8 @@
+## 00-newline
+
+This is a somewhat "silly" plugin, which is run at the very beginning of the
+initialization sequence and just prints a newline character.
+
+This can be handy when your terminal emulator or "login tools" print some
+messages, but you want the ouput of your plugins and the first shell prompt
+clearly separated.
diff --git a/plugins/autojump/README.md b/plugins/autojump/README.md
new file mode 100644 (file)
index 0000000..0af8e1d
--- /dev/null
@@ -0,0 +1,3 @@
+## autojump
+Initialize "autojump", "a cd command that learns", see
+https://github.com/wting/autojump.
diff --git a/plugins/autojump/autojump.zshrc b/plugins/autojump/autojump.zshrc
new file mode 100644 (file)
index 0000000..f5c9e0a
--- /dev/null
@@ -0,0 +1,16 @@
+# AX-ZSH: Alex' Modular ZSH Configuration
+# autojump.zshrc: Initialize "autojump"
+
+for script (
+       "$HOMEBREW_PREFIX/etc/profile.d/autojump.sh"
+       "/usr/local/etc/profile.d/autojump.sh"
+       "/usr/share/autojump/autojump.zsh"
+); do
+       if [[ -r "$script" ]]; then
+               source "$script"
+               unset script
+               return 0
+       fi
+done
+unset script
+return 1
diff --git a/plugins/bat/README.md b/plugins/bat/README.md
new file mode 100644 (file)
index 0000000..7a6e2c9
--- /dev/null
@@ -0,0 +1,4 @@
+## bat
+
+Find the bat(1) tool and create an alias to "bat" when installed with an other
+name (on Debian, it is installed as "batcat", for example).
diff --git a/plugins/bat/bat.zshrc b/plugins/bat/bat.zshrc
new file mode 100644 (file)
index 0000000..9432e2d
--- /dev/null
@@ -0,0 +1,12 @@
+# AX-ZSH: Alex' Modular ZSH Configuration
+# trash.zshrc: Setup trash(1)
+
+# Make sure that "bat(1)" is installed
+(( $+commands[bat] )) && return 0
+
+if (( $+commands[batcat] )); then
+       alias bat='batcat'
+       return 0
+fi
+
+return 1
diff --git a/plugins/browser_select/README.md b/plugins/browser_select/README.md
new file mode 100644 (file)
index 0000000..927eb6b
--- /dev/null
@@ -0,0 +1,18 @@
+## browser_select
+
+Search for the "best" WWW browser and setup environment (`$BROWSER`) accordingly.
+
+The plugin looks for the following WWW browsers and stops at the first one it finds:
+
+- open (on non-Linux platforms)
+- firefox (when DISPLAY is set)
+- chrome (when DISPLAY is set)
+- elinks
+- w3m
+- links2
+- links
+- lynx
+
+### Environment
+
+- `$BROWSER`: Command (including parameters) to run a WWW browser.
diff --git a/plugins/browser_select/browser_select.zprofile b/plugins/browser_select/browser_select.zprofile
new file mode 100644 (file)
index 0000000..fcc425e
--- /dev/null
@@ -0,0 +1,33 @@
+# AX-ZSH: Alex' Modular ZSH Configuration
+# browser_select.zprofile: Setup $BROWSER for the "best" available WWW browser
+
+# Don't run this plugin on "check-plugins"!
+[[ -z "$AXZSH_PLUGIN_CHECK" ]] || return 92
+
+if [[ -z "$BROWSER" ]]; then
+       if [[ "$OSTYPE" != "linux-gnu" ]]; then
+               # Check for open(1) on Non-Linux systems. On (Debian-) Linux, the open(1)
+               # command would recursively call $BROWSER (=itself) ...
+               open_browsers="open"
+       fi
+       if [[ -n "$DISPLAY" ]]; then
+               # X11 available, consider X11-based browsers, too!
+               x11_browsers="firefox chrome"
+       fi
+
+       # Note: We can't use xdg-open(1) here, as xdg-open itself tries to use
+       # $BROWSER, and this would result in an endless loop!
+       for browser (
+               $open_browsers
+               $x11_browsers
+               elinks w3m links2 links lynx
+       ); do
+               if [[ -n "$commands[$browser]" ]]; then
+                       BROWSER="$commands[$browser]"
+                       break
+               fi
+       done
+       unset browser open_browser x11_browsers
+fi
+
+[[ -n "$BROWSER" ]] && export BROWSER
diff --git a/plugins/calendar/README.md b/plugins/calendar/README.md
new file mode 100644 (file)
index 0000000..3979b85
--- /dev/null
@@ -0,0 +1,4 @@
+## calendar
+
+Show calendar(1) entries for the current day, but not more often than once
+every hour.
diff --git a/plugins/calendar/calendar.ax-io b/plugins/calendar/calendar.ax-io
new file mode 100644 (file)
index 0000000..56c65f7
--- /dev/null
@@ -0,0 +1,30 @@
+# AX-ZSH: Alex' Modular ZSH Configuration
+# calendar.ax-io: Show calendar(1) entries for the current day.
+
+# Make sure that "calendar(1)" is installed.
+(( $+commands[calendar] )) || return 1
+
+# Don't run this plugin on "check-plugins", but test if it would work!
+# It fails when no calendar files are available, for example, on macOS ...
+if [[ -n "$AXZSH_PLUGIN_CHECK" ]]; then
+       calendar >/dev/null 2>&1 || return 1
+       return 0
+fi
+
+# Don't show any info when ~/.hushlogin exists ...
+[[ -r ~/.hushlogin ]] && return 0
+
+# Check if calendar(1) infos have been shown during last 60 minutes, and if so,
+# don't show them now but return.
+[[ -z `find "$XDG_CACHE_HOME/axzsh_last_calendar" -mmin -60 2>/dev/null` ]] || return 0
+
+tmpfile=$(mktemp "$TMPDIR/calendar.XXXXXX") || return 1
+
+calendar -A0 >"$tmpfile"
+if [[ -s "$tmpfile" ]]; then
+       cat "$tmpfile"; echo
+fi
+rm -f "$tmpfile"
+
+# Wtite "stamp" file.
+[[ -w ~/ ]] && touch "$XDG_CACHE_HOME/axzsh_last_calendar"
index 982d9b8e7f83837b12e3241a9206c8604a9074a1..88a0115bd74a44ef025bce839ff81d7f3fd0f1e8 100644 (file)
@@ -1,18 +1,36 @@
 # AX-ZSH: Alex' Modular ZSH Configuration
 # editor_select.zprofile: Setup $EDITOR for the "best" available editor
 
+if [[ -n "$EDITOR" && ! -x "$EDITOR" && -z "$commands[$EDITOR]" ]]; then
+       # Oops, current $EDITOR seems to be invalid! Start over!
+       unset EDITOR
+fi
+
+if [[ -z "$EDITOR" ]]; then
+       # Check user preferences first!
+       if [[ -r ~/.selected_editor ]]; then
+               . ~/.selected_editor
+               if [[ -x "$SELECTED_EDITOR" || -n "$commands[$SELECTED_EDITOR]" ]]; then
+                       EDITOR="$SELECTED_EDITOR"
+               fi
+               unset SELECTED_EDITOR
+       fi
+fi
+
 if [[ -z "$EDITOR" ]]; then
+       # Auto-detect a "good" editor ...
        if [[ -n "$DISPLAY" ]]; then
                # X11 available, consider X11-based editors, too!
-               x11_editors="gvim"
+               x11_editors="mousepad gvim vim.motif"
        fi
 
        for editor (
+               sensible-editor editor
                code atom mate subl mvim
                $x11_editors
-               vim nano joe vi
+               vim.nox vim.basic micro joe mcedit nano vim vim.tiny nvi vi
        ); do
-               if [ -n "$commands[$editor]" ]; then
+               if [[ -n "$commands[$editor]" ]]; then
                        EDITOR="$commands[$editor]"
                        break
                fi
@@ -24,12 +42,9 @@ case "$EDITOR:t" in
        "code"|"atom"|"mate"|"subl")
                EDITOR="$EDITOR --wait"
                ;;
-       "mvim"|"gvim")
+       "mvim"|"gvim"|"vim.motif")
                EDITOR="$EDITOR --nofork"
                ;;
 esac
 
-if [[ -n "$EDITOR" ]]; then
-       export EDITOR
-       alias zshenv="$EDITOR ~/.zshenv"
-fi
+[[ -n "$EDITOR" ]] && export EDITOR
diff --git a/plugins/editor_select/editor_select.zshrc b/plugins/editor_select/editor_select.zshrc
new file mode 100644 (file)
index 0000000..0d20e10
--- /dev/null
@@ -0,0 +1,7 @@
+# AX-ZSH: Alex' Modular ZSH Configuration
+# editor_select.zshrc: Setup $EDITOR for the "best" available editor
+
+# Don't run this plugin on "check-plugins"!
+[[ -z "$AXZSH_PLUGIN_CHECK" ]] || return 92
+
+[[ -n "$EDITOR" ]] && alias zshenv="$EDITOR ~/.zshenv"
index be79b98306b626620272c4a1824ddb2792b56dbe..526b5bea360a915dbbc8c3bb9708f631f7c64cdb 100644 (file)
@@ -14,20 +14,26 @@ fi
 
 # Test for Debian-specific keybinding location ...
 if [[ -r /usr/share/doc/fzf/examples/key-bindings.zsh ]]; then
-       source /usr/share/zsh/vendor-completions/_fzf
+       if [[ -r /usr/share/doc/fzf/examples/completion.zsh ]]; then
+               source /usr/share/doc/fzf/examples/completion.zsh
+       elif [[ -r /usr/share/zsh/vendor-completions/_fzf ]]; then
+               source /usr/share/zsh/vendor-completions/_fzf
+       fi
        source /usr/share/doc/fzf/examples/key-bindings.zsh
        return 0
 fi
 
 # Search for and read in FZF ZSH integration files
 for dir (
+       "$HOMEBREW_PREFIX"/opt/fzf/shell
        /usr/local/lib/fzf/shell
        /usr/local/opt/fzf/shell
        /usr/local/share/examples/fzf/shell
        /opt/fzf/shell
+       /usr/share/fzf/shell
 ); do
        [[ -d "$dir" ]] || continue
-       source "$dir/completion.zsh"
+       [[ -r "$dir/completion.zsh" ]] && source "$dir/completion.zsh"
        source "$dir/key-bindings.zsh"
        return 0
 done
index 4d796ef48a5590d67a8111fbbc8df5452dbff3b1..3be5cbd709aa6ea9ffb28c0fa583f050bb7f1017 100644 (file)
@@ -57,11 +57,38 @@ git_prompt() {
 # OhMyZsh compatibility functions
 alias parse_git_dirty=git_parse_dirty
 
-ax_vcs_prompt_functions=($ax_vcs_prompt_functions git_prompt)
+axzsh_vcs_prompt_functions=($axzsh_vcs_prompt_functions git_prompt)
 
-alias ga="git add"
-alias gc="git commit"
-alias gd="git diff --patch-with-stat"
-alias gdc="git diff --patch-with-stat --cached"
-alias gst="git status --short --branch --untracked"
 alias fix="git diff --name-only | uniq | xargs $EDITOR"
+alias g="git"
+alias ga="git add"
+alias gapa="git add --patch"
+alias gc="git commit --verbose"
+alias gc!="git commit --verbose --amend"
+alias gca="git commit --verbose --all"
+alias gcam="git commit --verbose --all --message"
+alias gcmsg="git commit --verbose --message"
+alias gcn="git commit --verbose --no-edit"
+alias gcn!="git commit --verbose --no-edit --amend"
+alias gco="git checkout"
+alias gd="git diff"
+alias gdca="git diff --cached"
+alias gdcw="git diff --cached --word-diff"
+alias gdw="git diff --word-diff"
+alias gf="git fetch"
+alias gfa="git fetch --all --prune"
+alias gfo="git fetch origin"
+alias gl="git pull"
+alias glo="git log --oneline --decorate"
+alias gloo="git log --oneline --decorate ORIG_HEAD.."
+alias gp="git push"
+alias gr="git remote"
+alias grb="git rebase"
+alias grbi="git rebase --interactive"
+alias gsb="git status --short --branch"
+alias gsh="git show"
+alias gss="git status --short"
+alias gst="git status"
+alias gsta="git stash push"
+alias gstl="git stash list"
+alias gstp="git stash pop"
index 17d6dc5b8dbcd0a706f0e1276c1c1332a299137b..2b95624bd8e91d22746826ccc2567f8ab87844eb 100644 (file)
@@ -14,7 +14,7 @@ else
        (( $+commands[gpg] )) || return 1
 fi
 
-export GPG_TTY=$(tty)
+export GPG_TTY=$TTY
 
 if (( $+commands[gpg-connect-agent] )); then
        # Try to start/connect the agent ...
index 48430dfad7413833e21e5f4c0fab03b9c68c0d60..4bff6b5c970edfb67f7e40e6a67f57a3ed9b8bde 100644 (file)
@@ -4,4 +4,4 @@
 # Make sure that "googler(1)" are installed
 (( $+commands[googler] )) || return
 
-alias g="googler"
+alias g0="googler --show-browser-logs -n $((LINES/6))"
index 201b8dd6f5d1285b86bfe75c6b84be54383d2bc3..c64c961e5bdbd8a65e89ddd33d2974944f493212 100644 (file)
@@ -3,3 +3,13 @@
 Setup "Homebrew" ("The missing package manager for OS X", http://brew.sh):
 
 - Enable ZSH completions installed by Homebrew formulae.
+- Install a `brew` wrapper function.
+
+This wrapper function for the `brew`(1) command does the following:
+
+- Detect the location of the "real" brew(1) command.
+- Change user and group when the Homebrew installation is owned by a different
+  user (to preserve sane file permissions).
+- Set a relaxed umask(1) so that other users can use software installed by
+  Homebrew.
+- Call the "real" `brew`(1) command.
index 5885efdb57b3720f80f9e10c7a502db94924e984..9a3b14a48145fe9008314587292478e22f1117a8 100644 (file)
@@ -1,10 +1,30 @@
 # AX-ZSH: Alex' Modular ZSH Configuration
 # homebrew.zprofile -- Setup Homebrew Package Manager
 
-# Make sure that "brew(1)" is installed
-(( $+commands[brew] )) || return 1
+# Look for the "brew(1) command ...
+for brew_cmd (
+       /home/linuxbrew/.linuxbrew/bin/brew
+       /opt/homebrew/bin/brew
+       /usr/local/bin/brew
+); do
+       [[ -x "$brew_cmd" ]] && break
+done
+if [[ ! -x "$brew_cmd" ]]; then
+       unset brew_cmd
+       return 1
+fi
 
-[[ -d "/usr/local/share/zsh-completions" ]] \
-       && axzsh_fpath+=(/usr/local/share/zsh-completions)
+eval "$("$brew_cmd" shellenv)"
+
+for dir (
+       "$HOMEBREW_PREFIX/share/zsh-completions"
+       "$HOMEBREW_PREFIX/share/zsh/site-functions"
+); do
+       [[ -d "$dir" ]] && axzsh_fpath+=("$dir")
+done
+unset dir brew_cmd
+
+# Set some defaults, if not set already.
+[[ -z "$HOMEBREW_AUTO_UPDATE_SECS" ]] && HOMEBREW_AUTO_UPDATE_SECS=600
 
 return 0
index 52849bc6c9b2432dcfed7aed5d72088fb0c6613a..c91ed76f08a54c7974dbf8b7d063769d921decb1 100644 (file)
@@ -12,9 +12,9 @@
 
 # Check if reminders have been shown during last 60 minutes, and if so,
 # don't show them now but return.
-[[ -z `find ~/.last_reminder -mmin -60 2>/dev/null` ]] || return 0
+[[ -z `find "$XDG_CACHE_HOME/axzsh_last_reminder" -mmin -60 2>/dev/null` ]] || return 0
 
-tmpfile=$(mktemp ${TMPDIR:-/tmp}/icalbuddy.XXXXXX) || return 1
+tmpfile=$(mktemp "$TMPDIR/icalbuddy.XXXXXX") || return 1
 
 if [[ "$LANG" =~ "\.UTF" ]]; then
        bul="•"; bul_imp="!"; sep="»"
@@ -28,14 +28,14 @@ icalBuddy -f -n -b " $bul " -ab " $bul_imp " -ps "/ $sep /" \
        tasksDueBefore:today 2>/dev/null >>"$tmpfile"
 icalBuddy -f -n -b " $bul " -ab " $bul_imp " -ps "/ $sep /" \
        -nc -npn -iep "title,datetime" \
-       eventsToday+1 2>/dev/null  >>"$tmpfile"
+       eventsToday+1 2>/dev/null >>"$tmpfile"
 
 if [[ -s "$tmpfile" ]]; then
-       echo; cat "$tmpfile"; echo
+       cat "$tmpfile"; echo
 fi
 
 rm -f "$tmpfile"
 unset bul bul_imp sep tmpfile
 
 # Wtite "stamp" file.
-[[ -w ~/ ]] && touch ~/.last_reminder
+[[ -w ~/ ]] && touch "$XDG_CACHE_HOME/axzsh_last_reminder"
index 7373ca0f78707c4d2b3c8b50bca4f81ff4566e31..211e617a0372be5ea0ff059b3c87cfd8f1fafee5 100644 (file)
@@ -9,21 +9,39 @@ axzsh_is_modern_terminal || return 91
 [[ -z "$ITERM_SHELL_INTEGRATION_INSTALLED" ]] || return 91
 [[ "${ITERM_ENABLE_SHELL_INTEGRATION_WITH_TMUX-}$TERM" =~ "^screen" ]] && return 91
 
+# Add iTerm2 commands to PATH, when available.
+[[ -d ~/.iterm2 ]] && path+=(~/.iterm2)
+
 # Try to source user-local shell integration installed by iTerm2 itself,
 # and only fall back to the implementation here when not found.
 [[ -e "$HOME/.iterm2_shell_integration.zsh" ]] && source "$HOME/.iterm2_shell_integration.zsh"
+
+# ax-zsh specific iTerm2 functions
+iterm2_clear_captured_output() {
+       printf "\e]1337;ClearCapturedOutput\e\\"
+}
+
 [[ -z "$ITERM_SHELL_INTEGRATION_INSTALLED" ]] || return 0
 
 ITERM_SHELL_INTEGRATION_INSTALLED="Yes"
 ITERM2_SHOULD_DECORATE_PROMPT="1"
 
+if [[ -n "$TMUX" ]]; then
+       # Pass escape sequences through in tmux(1), see
+       # <https://gist.github.com/antifuchs/c8eca4bcb9d09a7bbbcd>.
+       TMUX_PREFIX='\ePtmux;\e'
+       TMUX_POSTFIX='\e\\'
+else
+       unset TMUX_PREFIX TMUX_POSTFIX
+fi
+
 # Indicates start of command output. Runs just before command executes.
 iterm2_before_cmd_executes() {
-       printf "\033]133;C;\007"
+       printf "${TMUX_PREFIX}\033]133;C;\007${TMUX_POSTFIX}"
 }
 
 iterm2_set_user_var() {
-       printf "\033]1337;SetUserVar=%s=%s\007" "$1" $(printf "%s" "$2" | base64 | tr -d '\n')
+       printf "${TMUX_PREFIX}\033]1337;SetUserVar=%s=%s\007${TMUX_POSTFIX}" "$1" $(printf "%s" "$2" | base64 | tr -d '\n')
 }
 
 # Users can write their own version of this method. It should call
@@ -31,33 +49,32 @@ iterm2_set_user_var() {
 # e.g., iterm2_set_user_var currentDirectory $PWD
 # Accessible in iTerm2 (in a badge now, elsewhere in the future) as
 # \(user.currentDirectory).
-whence -v iterm2_print_user_vars > /dev/null 2>&1
-if [ $? -ne 0 ]; then
+if ! whence iterm2_print_user_vars >/dev/null; then
        iterm2_print_user_vars() {
                :
        }
 fi
 
 iterm2_print_state_data() {
-       printf "\033]1337;RemoteHost=%s@%s\007" "$USER" "$iterm2_hostname"
-       printf "\033]1337;CurrentDir=%s\007" "$PWD"
+       printf "${TMUX_PREFIX}\033]1337;RemoteHost=%s@%s\007${TMUX_POSTFIX}" "$USER" "$HOST"
+       printf "${TMUX_PREFIX}\033]1337;CurrentDir=%s\007${TMUX_POSTFIX}" "$PWD"
        iterm2_print_user_vars
 }
 
 # Report return code of command; runs after command finishes but before prompt
 iterm2_after_cmd_executes() {
-       printf "\033]133;D;%s\007" "$STATUS"
+       printf "${TMUX_PREFIX}\033]133;D;%s\007${TMUX_POSTFIX}" "$STATUS"
        iterm2_print_state_data
 }
 
 # Mark start of prompt
 iterm2_prompt_mark() {
-       printf "\033]133;A\007"
+       printf "${TMUX_PREFIX}\033]133;A\007${TMUX_POSTFIX}"
 }
 
 # Mark end of prompt
 iterm2_prompt_end() {
-       printf "\033]133;B\007"
+       printf "${TMUX_PREFIX}\033]133;B\007${TMUX_POSTFIX}"
 }
 
 # There are three possible paths in life.
@@ -105,8 +122,8 @@ iterm2_decorate_prompt() {
        ITERM2_SHOULD_DECORATE_PROMPT=""
 
        # Add our escape sequences just before the prompt is shown.
-       # Use ITERM2_SQUELCH_MARK for people who can't mdoify PS1 directly, like powerlevel9k users.
-       # This is gross but I had a heck of a time writing a correct if statetment for zsh 5.0.2.
+       # Use ITERM2_SQUELCH_MARK for people who can't modify PS1 directly, like powerlevel9k users.
+       # This is gross but I had a heck of a time writing a correct if statement for zsh 5.0.2.
        local PREFIX=""
        if [[ $PS1 == *"$(iterm2_prompt_mark)"* ]]; then
                PREFIX=""
@@ -120,14 +137,14 @@ iterm2_decorate_prompt() {
 
 iterm2_precmd() {
        local STATUS="$?"
-       if [ -z "${ITERM2_SHOULD_DECORATE_PROMPT-}" ]; then
+       if [[ -z "${ITERM2_SHOULD_DECORATE_PROMPT-}" ]]; then
                # You pressed ^C while entering a command (iterm2_preexec did not run)
                iterm2_before_cmd_executes
        fi
 
        iterm2_after_cmd_executes "$STATUS"
 
-       if [ -n "$ITERM2_SHOULD_DECORATE_PROMPT" ]; then
+       if [[ -n "$ITERM2_SHOULD_DECORATE_PROMPT" ]]; then
                iterm2_decorate_prompt
        fi
 }
@@ -140,14 +157,11 @@ iterm2_preexec() {
        iterm2_before_cmd_executes
 }
 
-# If hostname -f is slow on your system, set iterm2_hostname prior to sourcing this script.
-[[ -z "$iterm2_hostname" ]] && iterm2_hostname=`hostname -f`
-
 precmd_functions+=(iterm2_precmd)
 preexec_functions+=(iterm2_preexec)
 
 iterm2_print_state_data
-printf "\033]1337;ShellIntegrationVersion=11;shell=zsh\007"
+printf "${TMUX_PREFIX}\033]1337;ShellIntegrationVersion=12;shell=zsh\007${TMUX_POSTFIX}"
 
 # Setup iTerm2 command aliases
 for cmd (~/.iterm2/*(N)); do
diff --git a/plugins/lsd/README.md b/plugins/lsd/README.md
new file mode 100644 (file)
index 0000000..6a95458
--- /dev/null
@@ -0,0 +1,8 @@
+## lsd
+
+Setup LSD (LSDeluxe), the next gen ls command:
+<https://github.com/Peltoche/lsd/>
+
+### Prerequisites
+
+- `lsd`(1)
diff --git a/plugins/lsd/lsd.zshrc b/plugins/lsd/lsd.zshrc
new file mode 100644 (file)
index 0000000..1bdfe6a
--- /dev/null
@@ -0,0 +1,7 @@
+# AX-ZSH: Alex' Modular ZSH Configuration
+# lsd.zshrc: Setup LSD (LSDeluxe), the next gen ls command.
+
+# Make sure that "lsd(1)" is installed
+(( $+commands[lsd] )) || return 1
+
+alias ls='lsd'
diff --git a/plugins/neofetch/README.md b/plugins/neofetch/README.md
new file mode 100644 (file)
index 0000000..5e0a7a7
--- /dev/null
@@ -0,0 +1,4 @@
+## neofetch
+
+Show fastfetch(1) or neofetch(1) system information, but not more often than
+once every hour. If both tools are installed, prefer fastfetch(1).
diff --git a/plugins/neofetch/neofetch.ax-io b/plugins/neofetch/neofetch.ax-io
new file mode 100644 (file)
index 0000000..7a37f6e
--- /dev/null
@@ -0,0 +1,26 @@
+# AX-ZSH: Alex' Modular ZSH Configuration
+# neofetch.ax-io: Show fastfetch(1) [preferred] or neofetch(1) system information.
+
+# Make sure that fastfetch(1) or neofetch(1) is installed.
+(( $+commands[fastfetch] )) || (( $+commands[neofetch] )) || return 1
+
+# Don't run this plugin on "check-plugins"!
+[[ -z "$AXZSH_PLUGIN_CHECK" ]] || return 0
+
+# Don't show any info when ~/.hushlogin exists ...
+[[ -r ~/.hushlogin ]] && return 0
+
+# Check if neofetch(1) infos have been shown during last 60 minutes, and if so,
+# don't show them now but return.
+[[ -z $(find "$XDG_CACHE_HOME/axzsh_last_neofetch" -mmin -60 2>/dev/null) ]] || return 0
+
+if (( $+commands[fastfetch] )); then
+       fastfetch
+elif (( $+commands[neofetch] )); then
+       neofetch
+else
+       return 0
+fi
+
+# Wtite "stamp" file.
+[[ -w ~/ ]] && touch "$XDG_CACHE_HOME/axzsh_last_neofetch"
index 05ee67628273a04fab7891347491d98a0c199c1f..519a4264ac1d087583da05979917ce3f1dcad102 100644 (file)
@@ -18,10 +18,10 @@ alias remindcal='remind -ccu+3 -m -w$COLUMNS,4,0 $HOME/.remind'
 
 # Check if reminders have been shown during last 60 minutes, and if so,
 # don't show them now but return.
-[[ -z `find ~/.last_reminder -mmin -60 2>/dev/null` ]] || return 0
+[[ -z `find "$XDG_CACHE_HOME/axzsh_last_reminder" -mmin -60 2>/dev/null` ]] || return 0
 
 # Show reminders now.
 remind -h -g -t5 ~/.remind && echo
 
 # Wtite "stamp" file.
-[[ -w ~/ ]] && touch ~/.last_reminder
+[[ -w ~/ ]] && touch "$XDG_CACHE_HOME/axzsh_last_reminder"
diff --git a/plugins/websearch/README.md b/plugins/websearch/README.md
new file mode 100644 (file)
index 0000000..cfc1f53
--- /dev/null
@@ -0,0 +1,16 @@
+## websearch
+
+Setup some functions and aliases to open various search engines (Google, Ecosia,
+DuckDuckGo, ...) from the command line.
+
+### Functions
+
+- `duckduckgo`: Open DuckDuckGo for the given search terms.
+- `ecosia`: Open Ecosia for the given search terms.
+- `google`: Open Google for the given search terms.
+
+### Aliases
+
+- `ddg`: `duckduckgo`
+- `eco`: `ecosia`
+- `g0`: `google`
diff --git a/plugins/websearch/websearch.zshrc b/plugins/websearch/websearch.zshrc
new file mode 100644 (file)
index 0000000..fb1b76b
--- /dev/null
@@ -0,0 +1,23 @@
+# AX-ZSH: Alex' Modular ZSH Configuration
+# google.zshrc: Setup functions for using Google in the command line
+
+# This is an optional plugin.
+[[ -z "$AXZSH_PLUGIN_CHECK" ]] || return 92
+
+function duckduckgo {
+       url="https://duckduckgo.com/?q=$@"
+       open_command "$url" || echo "DuckDuckGo: <$url>"
+}
+alias ddg='duckduckgo'
+
+function ecosia {
+       url="https://www.ecosia.org/search?q=$@"
+       open_command "$url" || echo "Ecosia: <$url>"
+}
+alias eco='ecosia'
+
+function google {
+       url="https://www.google.de/search?q=$@"
+       open_command "$url" || echo "Google: <$url>"
+}
+alias g0='google'
index 0a4eda4a6c285c8143f3ef2bd7fa9e0ddb91cb20..ddb67f0711ba1d17e336f4419c6a65d97fc85f08 100644 (file)
@@ -9,11 +9,11 @@ ZSH_THEME_PROMPT_ROOT_PREFIX="%{$fg_bold[red]%}"
 ZSH_THEME_PROMPT_SUFFIX="%b%{$reset_color%}"
 ZSH_THEME_PROMPT_SUFFIX_SPACING=" "
 
-ax_logname_prompt_functions=($ax_logname_prompt_functions ax_logname_prompt_root)
-ax_hostname_prompt_functions=($ax_hostname_prompt_functions ax_hostname_prompt_root)
+axzsh_logname_prompt_functions=($axzsh_logname_prompt_functions axzsh_logname_prompt_root)
+axzsh_hostname_prompt_functions=($axzsh_hostname_prompt_functions axzsh_hostname_prompt_root)
 
 # The primary prompt string, printed before a command is read.
-PS1="$(ax_logname_prompt_yn)$(ax_hostname_prompt_yn)%B%2~%b"'$(ax_vcs_prompt)'"$(ax_prompt)"
+PS1="$(axzsh_logname_prompt_yn)$(axzsh_hostname_prompt_yn)%B%2~%b"'$(axzsh_vcs_prompt)'"$(axzsh_prompt)"
 
 # Primary prompt on the right-hand side.
 axzsh_is_utf_terminal \
index 331a3221fd1aa953701a7bda2faf079e315382af..9333e0ecbf660fbcf0b92ab8f2d634e4b9bf383d 100644 (file)
@@ -31,8 +31,11 @@ else
        RPS1="%(?..%{$fg_no_bold[red]%}<%?>%{$reset_color%})"
 fi
 
+axzsh_logname_prompt_functions=($axzsh_logname_prompt_functions axzsh_logname_prompt_root)
+axzsh_hostname_prompt_functions=($axzsh_hostname_prompt_functions axzsh_hostname_prompt_root)
+
 # The primary prompt string, printed before a command is read.
-PS1="${system_emoji}${emoji_spacing} $(ax_logname_prompt_yn)$(ax_hostname_prompt_yn)%B%2~%b"'$(ax_vcs_prompt)'"$(ax_prompt)"
+PS1="${system_emoji}${emoji_spacing} $(axzsh_logname_prompt_yn)$(axzsh_hostname_prompt_yn)%B%2~%b"'$(axzsh_vcs_prompt)'"$(axzsh_prompt)"
 
 # Default execution trace prompt.
 PS4="$fg_no_bold[yellow]->$reset_color "
index b16c4975910ec0fc882af5de071f7ca28352c680..5f004fbbd04e5acdcdbf91422710bd0925a9de97 100644 (file)
@@ -3,4 +3,4 @@
 
 ZSH_THEME_PROMPT_SUFFIX_SPACING=" "
 
-PS1="%{$fg_bold[green]%}%n@%m%{$reset_color%}:%{$fg_bold[blue]%}%~%{$reset_color%}"'$(ax_vcs_prompt)'"$(ax_prompt)"
+PS1="%{$fg_bold[green]%}%n@%m%{$reset_color%}:%{$fg_bold[blue]%}%~%{$reset_color%}"'$(axzsh_vcs_prompt)'"$(axzsh_prompt)"
index c3612c35e8cd584e5a832a7a69aa29ed06184b34..f3beed4383089f9d8c232fb1ca5532f5517911ab 100644 (file)
@@ -2,7 +2,7 @@
 # ohmyzsh.axzshtheme: OhMyZSH "robbyrussell" theme
 
 ret_status="%(?:%{$fg_bold[green]%}➜ :%{$fg_bold[red]%}➜ %s)"
-PS1='${ret_status} %{$fg[cyan]%}%c%b $(ax_vcs_prompt)%b '
+PS1='${ret_status} %{$fg[cyan]%}%c%b $(axzsh_vcs_prompt)%b '
 
 ZSH_THEME_VCS_PROMPT_PREFIX_SPACING="%{$fg_bold[blue]%}vcs:("
 ZSH_THEME_VCS_PROMPT_PREFIX="%{$fg[red]%}"
diff --git a/themes/starship.axzshtheme b/themes/starship.axzshtheme
new file mode 100644 (file)
index 0000000..b3fcfce
--- /dev/null
@@ -0,0 +1,9 @@
+# AX-ZSH: Alex' Modular ZSH Configuration
+# starship.axzshtheme: Enable extnerl "Starship" Theme
+# see <https://starship.rs/>
+
+if (( $+commands[starship] )); then
+       eval "$(starship init zsh)"
+else
+       echo "Oops, starship(1) command not found, can't enable Starship prompt!" >&2
+fi