├── AUTHORS ├── plugins ├── vi-mode │ ├── README.md │ └── vi-mode.zshrc ├── zkbd │ ├── README.md │ ├── zkbd.ax-io │ └── zkbd.zshrc ├── command-not-found │ ├── README.md │ └── command-not-found.zshrc ├── travis │ ├── README.md │ └── travis.zshrc ├── pdfman │ ├── README.md │ └── pdfman.zshrc ├── bashcompletion │ ├── README.md │ └── bashcompletion.zshrc ├── python │ ├── README.md │ └── python.zprofile ├── autojump │ ├── README.md │ └── autojump.zshrc ├── calendar │ ├── README.md │ └── calendar.ax-io ├── docker-machine │ ├── README.md │ └── docker-machine.zprofile ├── buku │ ├── README.md │ └── buku.zshrc ├── icalbuddy │ ├── README.md │ └── icalbuddy.ax-io ├── ssh-pageant │ ├── README.md │ └── ssh-pageant.zshrc ├── ssh_autoadd │ ├── README.md │ └── ssh_autoadd.ax-io ├── mosh │ ├── README.md │ └── mosh.zshrc ├── zoxide │ ├── README.md │ └── zoxide.zshrc ├── googler │ ├── README.md │ └── googler.zshrc ├── thefuck │ ├── README.md │ └── thefuck.zshrc ├── zsh-navigation-tools │ ├── README.md │ ├── zsh-navigation-tools.zprofile │ └── zsh-navigation-tools.zshrc ├── lsd │ ├── README.md │ └── lsd.zshrc ├── zsh-autosuggestions │ ├── README.md │ └── zsh-autosuggestions.zshrc ├── zsh-syntax-highlighting │ ├── README.md │ └── zsh-syntax-highlighting.zshrc ├── bat │ ├── README.md │ └── bat.zshrc ├── go │ ├── README.md │ └── go.zprofile ├── spectrum │ ├── README.md │ └── spectrum.zshrc ├── virtualenvwrapper │ ├── README.md │ └── virtualenvwrapper.zshrc ├── hub │ ├── README.md │ └── hub.zshrc ├── neofetch │ ├── README.md │ └── neofetch.ax-io ├── cygwin │ ├── README.md │ └── cygwin.zprofile ├── colormake │ ├── README.md │ └── colormake.zshrc ├── nodejs │ ├── README.md │ └── nodejs.zprofile ├── trash │ ├── trash.zshrc │ └── README.md ├── gcc │ ├── README.md │ └── gcc.zprofile ├── iterm2 │ ├── README.md │ └── iterm2.zshrc ├── keychain │ ├── README.md │ ├── keychain.zprofile │ └── keychain.zshrc ├── remind │ ├── README.md │ └── remind.ax-io ├── yazi │ ├── README.md │ └── yazi.zshrc ├── hstr │ ├── hstr.zshrc │ └── README.md ├── fzy │ ├── README.md │ └── fzy.zshrc ├── mankier │ ├── README.md │ └── mankier.zshrc ├── editor_select │ ├── editor_select.zshrc │ ├── README.md │ └── editor_select.zprofile ├── ccache │ ├── README.md │ └── ccache.zprofile ├── 00-newline │ ├── README.md │ └── 00-newline.ax-io ├── virtualenv │ ├── README.md │ └── virtualenv.zshrc ├── gnupg │ ├── README.md │ └── gnupg.zshrc ├── powerline-shell │ ├── README.md │ └── powerline-shell.zshrc ├── websearch │ ├── README.md │ └── websearch.zshrc ├── jujutsu │ ├── README.md │ └── jujutsu.zshrc ├── browser_select │ ├── README.md │ └── browser_select.zprofile ├── ssh_secure │ ├── ssh_secure.zshrc │ └── README.md ├── README.md ├── homebrew │ ├── README.md │ └── homebrew.zprofile ├── fzf │ ├── README.md │ └── fzf.zshrc ├── git │ ├── README.md │ └── git.zshrc └── 99-attach-session │ └── 99-attach-session.ax-io ├── .gitignore ├── .mailmap ├── core ├── 05_fpath │ ├── 05_fpath.zprofile │ └── 05_fpath.zshrc ├── 01_zprofile │ ├── 01_zprofile.zprofile │ └── 01_zprofile.zshrc ├── 40_help │ └── 40_help.zshrc ├── 99_zlogin │ ├── 99_zlogin.zlogin │ └── 99_zlogin.zshrc ├── 99_cleanup │ ├── 99_cleanup.zshrc │ └── 99_cleanup.zlogin ├── 20_home │ └── 20_home.ax-io ├── 11_terminal │ ├── 11_terminal.ax-io │ └── 11_terminal.zshrc ├── 80_local_config │ ├── 80_local_config.zshrc │ ├── 80_local_config.zlogin │ ├── 80_local_config.zlogout │ └── 80_local_config.ax-io ├── 50_path │ └── 50_path.zprofile ├── 30_hostname │ └── 30_hostname.zprofile ├── 30_env │ ├── 30_env.zshrc │ └── 30_env.ax-io ├── 40_axzsh │ ├── 40_axzsh.zshrc │ └── functions │ │ └── _axzsh ├── 10_keyboard │ └── 10_keyboard.zshrc ├── 30_path │ └── 30_path.ax-io ├── 90_theme │ └── 90_theme.zshrc ├── 12_locale │ └── 12_locale.ax-io ├── 40_completion │ └── 40_completion.zshrc └── 40_prompt │ └── 40_prompt.zshrc ├── default_plugins ├── theme │ └── theme.zshrc ├── std_env │ ├── std_env.zprofile │ └── std_env.zshrc ├── ls │ ├── ls.zprofile │ └── ls.zshrc ├── ssh │ ├── ssh.zprofile │ └── ssh.zshrc ├── correction │ └── correction.zshrc ├── std_options │ └── std_options.zshrc ├── 10-hello │ └── 10-hello.ax-io ├── history │ └── history.zshrc ├── grep │ └── grep.zshrc ├── less │ └── less.zprofile ├── byebye │ └── byebye.zlogout ├── cheat │ └── cheat.zshrc ├── std_aliases │ └── std_aliases.zshrc └── std_functions │ └── std_functions.zshrc ├── themes ├── debian.axzshtheme ├── starship.axzshtheme ├── ohmyzsh.axzshtheme ├── ax.axzshtheme └── axemoji.axzshtheme ├── LICENSE.md ├── install.sh ├── bin ├── axttyinfo └── axzshctl ├── ax.zsh └── README.md /AUTHORS: -------------------------------------------------------------------------------- 1 | Alexander Barton 2 | -------------------------------------------------------------------------------- /plugins/vi-mode/README.md: -------------------------------------------------------------------------------- 1 | ## vi-mode 2 | 3 | Setup "VI mode" in ZSH. 4 | -------------------------------------------------------------------------------- /plugins/zkbd/README.md: -------------------------------------------------------------------------------- 1 | ## zkbd 2 | 3 | Initialize ZSH standard keybindings using its *zkbd* module. 4 | -------------------------------------------------------------------------------- /plugins/command-not-found/README.md: -------------------------------------------------------------------------------- 1 | ## command-not-found 2 | 3 | Enable the *command-not-found* package. 4 | -------------------------------------------------------------------------------- /plugins/travis/README.md: -------------------------------------------------------------------------------- 1 | ## travis 2 | 3 | Setup autocompletion for the *travis*(1), the CLI tool for Travis-CI. 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .tags 2 | active_plugins/ 3 | custom_plugins/ 4 | active_theme 5 | custom_themes/ 6 | cache/ 7 | repos/ 8 | debug 9 | -------------------------------------------------------------------------------- /plugins/pdfman/README.md: -------------------------------------------------------------------------------- 1 | ## pdfman 2 | 3 | ### Command Aliases 4 | 5 | - `man`: `pdfman` (when `pdfman` is available). 6 | -------------------------------------------------------------------------------- /plugins/bashcompletion/README.md: -------------------------------------------------------------------------------- 1 | ## bashcompletion 2 | 3 | Try to load available completion scripts for the bash(1) shell into ZSH. 4 | -------------------------------------------------------------------------------- /plugins/python/README.md: -------------------------------------------------------------------------------- 1 | ## python 2 | 3 | Setup Python environment. 4 | 5 | ### Environment 6 | 7 | - `$PIP_REQUIRE_VIRTUALENV` 8 | -------------------------------------------------------------------------------- /plugins/autojump/README.md: -------------------------------------------------------------------------------- 1 | ## autojump 2 | Initialize "autojump", "a cd command that learns", see 3 | https://github.com/wting/autojump. 4 | -------------------------------------------------------------------------------- /plugins/calendar/README.md: -------------------------------------------------------------------------------- 1 | ## calendar 2 | 3 | Show calendar(1) entries for the current day, but not more often than once 4 | every hour. 5 | -------------------------------------------------------------------------------- /.mailmap: -------------------------------------------------------------------------------- 1 | Alexander Barton 2 | Alexander Barton 3 | -------------------------------------------------------------------------------- /plugins/docker-machine/README.md: -------------------------------------------------------------------------------- 1 | ## docker-machine 2 | 3 | Setup the environment for the "local-default" configuration of 4 | *docker-machine*(1). 5 | -------------------------------------------------------------------------------- /plugins/buku/README.md: -------------------------------------------------------------------------------- 1 | ## buku 2 | 3 | Setup *buku*(1), a terminal-based bookmaks manager. 4 | 5 | ### Command Aliases 6 | 7 | - `b`: `buku --suggest` 8 | -------------------------------------------------------------------------------- /plugins/icalbuddy/README.md: -------------------------------------------------------------------------------- 1 | ## icalbuddy 2 | 3 | Show reminders using the icalBuddy(1) tool on shell startup, but not more often 4 | than once every hour. 5 | -------------------------------------------------------------------------------- /plugins/ssh-pageant/README.md: -------------------------------------------------------------------------------- 1 | ## ssh-pageant.zshrc 2 | 3 | Integrate *ssh-pageant*, an SSH agent for Cygwin/MSYS, that links to PuTTY's 4 | Pageant daemon. 5 | -------------------------------------------------------------------------------- /plugins/ssh_autoadd/README.md: -------------------------------------------------------------------------------- 1 | ## ssh_autoadd 2 | 3 | Automatically call "ssh-autoadd" for new shell sessions, making sure that SSH 4 | keys are available. 5 | -------------------------------------------------------------------------------- /plugins/mosh/README.md: -------------------------------------------------------------------------------- 1 | ## mosh 2 | 3 | Setup *mosh*(1), the "mobile shell with roaming and intelligent local echo": 4 | 5 | - Enable `ssh` completions for `mosh`. 6 | -------------------------------------------------------------------------------- /plugins/zoxide/README.md: -------------------------------------------------------------------------------- 1 | ## zoxide 2 | Initialize "zoxide", a "shell extension to navigate your filesystem faster". 3 | See . 4 | -------------------------------------------------------------------------------- /core/05_fpath/05_fpath.zprofile: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # 05_fpath.zprofile: Setup AX-ZSH "fpath" 3 | 4 | typeset -xTU AXZSH_FPATH axzsh_fpath 5 | -------------------------------------------------------------------------------- /plugins/googler/README.md: -------------------------------------------------------------------------------- 1 | ## googler 2 | 3 | Setup *googler*(1), a tool for using Google on the command line. 4 | 5 | ### Command Aliases 6 | 7 | - `g`: `googler` 8 | -------------------------------------------------------------------------------- /plugins/thefuck/README.md: -------------------------------------------------------------------------------- 1 | ## thefuck 2 | 3 | Setup thefuck(1) to "programmatically correct mistyped console commands". 4 | 5 | ### Command Aliases 6 | 7 | - `fuck` 8 | -------------------------------------------------------------------------------- /plugins/zsh-navigation-tools/README.md: -------------------------------------------------------------------------------- 1 | ## zsh-navigation-tools 2 | 3 | Initialize "Curses-based tools for ZSH", see 4 | https://github.com/psprint/zsh-navigation-tools. 5 | -------------------------------------------------------------------------------- /core/01_zprofile/01_zprofile.zprofile: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # 01_zprofile.zprofile: Initialize AX-ZSH profile settings 3 | 4 | AXZSH_ZPROFILE_READ=1 5 | -------------------------------------------------------------------------------- /core/40_help/40_help.zshrc: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # 40_help.zshrc: ZSH and AX-ZSH help 3 | 4 | unalias run-help 2>/dev/null 5 | autoload -Uz run-help 6 | -------------------------------------------------------------------------------- /plugins/lsd/README.md: -------------------------------------------------------------------------------- 1 | ## lsd 2 | 3 | Setup LSD (LSDeluxe), the next gen ls command: 4 | 5 | 6 | ### Prerequisites 7 | 8 | - `lsd`(1) 9 | -------------------------------------------------------------------------------- /plugins/zsh-autosuggestions/README.md: -------------------------------------------------------------------------------- 1 | ## zsh-autosuggestions 2 | 3 | Initialize "Fish-like autosuggestions for zsh", see 4 | https://github.com/zsh-users/zsh-autosuggestions. 5 | -------------------------------------------------------------------------------- /plugins/zsh-syntax-highlighting/README.md: -------------------------------------------------------------------------------- 1 | ## zsh-syntax-highlighting 2 | 3 | Initialize "ZSH Syntax Highlighting", see 4 | https://github.com/zsh-users/zsh-syntax-highlighting. 5 | -------------------------------------------------------------------------------- /plugins/bat/README.md: -------------------------------------------------------------------------------- 1 | ## bat 2 | 3 | Find the bat(1) tool and create an alias to "bat" when installed with an other 4 | name (on Debian, it is installed as "batcat", for example). 5 | -------------------------------------------------------------------------------- /plugins/go/README.md: -------------------------------------------------------------------------------- 1 | ## go 2 | 3 | Enable ZSH *Go* integration: 4 | 5 | 1. Setup GOPATH and PATH. 6 | 7 | ### Environment 8 | 9 | - `$GOPATH`: Go "workspace" directory. 10 | -------------------------------------------------------------------------------- /plugins/spectrum/README.md: -------------------------------------------------------------------------------- 1 | ## spectrum 2 | 3 | Define helper functions showing the available "color spectrum". 4 | 5 | ### Functions 6 | 7 | - `spectrum_ls` 8 | - `spectrum_bls` 9 | -------------------------------------------------------------------------------- /plugins/virtualenvwrapper/README.md: -------------------------------------------------------------------------------- 1 | ## virtualenvwrapper 2 | 3 | Look for and setup the Python *virtualenvwrapper*. 4 | 5 | ### Environment 6 | 7 | - `$PROJECT_HOME` 8 | - `$WORKON_HOME` 9 | -------------------------------------------------------------------------------- /plugins/hub/README.md: -------------------------------------------------------------------------------- 1 | ## hub 2 | 3 | Setup *hub*(1), a wrapper script integrating GitHub related functions in Git. 4 | 5 | ### Command Aliases 6 | 7 | - `git`: `hub` (enable the wrapper script) 8 | -------------------------------------------------------------------------------- /plugins/neofetch/README.md: -------------------------------------------------------------------------------- 1 | ## neofetch 2 | 3 | Show fastfetch(1) or neofetch(1) system information, but not more often than 4 | once every hour. If both tools are installed, prefer fastfetch(1). 5 | -------------------------------------------------------------------------------- /core/99_zlogin/99_zlogin.zlogin: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # 99_zlogin.zlogin: Mark AX-ZSH zprofile/zlogin as read 3 | 4 | export AXZSH_ZPROFILE_READ=1 5 | export AXZSH_ZLOGIN_READ=1 6 | -------------------------------------------------------------------------------- /plugins/cygwin/README.md: -------------------------------------------------------------------------------- 1 | ## cygwin 2 | 3 | Setup *Cygwin* (https://cygwin.com/) specific configuration. 4 | 5 | ### Environment 6 | 7 | - `$PATH`: Append standard directories of Windows to search path. 8 | -------------------------------------------------------------------------------- /plugins/colormake/README.md: -------------------------------------------------------------------------------- 1 | ## colormake 2 | 3 | Setup *colormake*(1), a wrapper script to colorize *make*(1) output. 4 | 5 | ### Command Aliases 6 | 7 | - `make`: `colormake` (enable the wrapper script) 8 | -------------------------------------------------------------------------------- /plugins/nodejs/README.md: -------------------------------------------------------------------------------- 1 | ## nodejs 2 | 3 | Enable ZSH *NodeJS* integration: 4 | 5 | 1. Create user-local NPM package directory ~/.npm-packages 6 | 2. Setup PATH and MANPATH to include NodeJS search paths 7 | -------------------------------------------------------------------------------- /plugins/buku/buku.zshrc: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # buku.zshrc: Setup buku(1) 3 | 4 | # Make sure that "buku(1)" is installed 5 | (( $+commands[buku] )) || return 6 | 7 | alias b='buku --suggest' 8 | -------------------------------------------------------------------------------- /plugins/trash/trash.zshrc: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # trash.zshrc: Setup trash(1) 3 | 4 | # Make sure that "trash(1)" is installed 5 | (( $+commands[trash] )) || return 6 | 7 | alias rm='trash -F' 8 | -------------------------------------------------------------------------------- /plugins/gcc/README.md: -------------------------------------------------------------------------------- 1 | ## go 2 | 3 | Enable ZSH *GCC* integration: 4 | 5 | 1. Setup colored compiler output. 6 | 7 | ### Environment 8 | 9 | - `$GCC_COLORS`: Enable colored compiler output, especially errors & warnings. 10 | -------------------------------------------------------------------------------- /plugins/iterm2/README.md: -------------------------------------------------------------------------------- 1 | ## iterm2 2 | 3 | *iTerm2* (Terminal application for OS X) Shell Integration, see 4 | for details. 5 | 6 | ### Prerequisites 7 | 8 | - iTerm 2, version 2.9 (or newer). 9 | -------------------------------------------------------------------------------- /plugins/keychain/README.md: -------------------------------------------------------------------------------- 1 | ## keychain 2 | 3 | Initialize *keychain*(1), "re-use ssh-agent and/or gpg-agent between logins". 4 | 5 | Check which agents are available (`ssh-agent` and/or `gpg-agent`), and call 6 | `keychain` accordingly. 7 | -------------------------------------------------------------------------------- /plugins/remind/README.md: -------------------------------------------------------------------------------- 1 | ## remind 2 | 3 | Show reminders using the remind(1) tool on shell startup, but not more often 4 | than once every hour. 5 | 6 | ### Command Aliases 7 | 8 | - `remindcal`: show a TUI calender for the upcoming weeks. 9 | -------------------------------------------------------------------------------- /default_plugins/theme/theme.zshrc: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # theme.zshrc: Setup AX-ZSH theme 3 | 4 | [[ -r "$AXZSH/active_theme" ]] \ 5 | && AXZSH_THEME="$AXZSH/active_theme" \ 6 | || AXZSH_THEME="$AXZSH/themes/ax.axzshtheme" 7 | -------------------------------------------------------------------------------- /plugins/pdfman/pdfman.zshrc: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # pdfman.zshrc: Setup PDFman 3 | 4 | # Make sure that "pdfman" script is installed 5 | (( $+commands[pdfman] )) || return 6 | 7 | alias man='pdfman' 8 | compdef pdfman=man 9 | -------------------------------------------------------------------------------- /plugins/hub/hub.zshrc: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # hub.zshrc: Setup hub(1) 3 | 4 | # Make sure that "git(1)" and "hub(1)" are installed 5 | (( $+commands[git] )) || return 6 | (( $+commands[hub] )) || return 7 | 8 | alias git="hub" 9 | -------------------------------------------------------------------------------- /plugins/mosh/mosh.zshrc: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # mosh.zshrc: Setup mosh(1) 3 | 4 | # Make sure that "mosh(1)" is installed 5 | (( $+commands[mosh] )) || return 6 | 7 | # Use the SSH completions for mosh, too 8 | compdef mosh=ssh 9 | -------------------------------------------------------------------------------- /plugins/yazi/README.md: -------------------------------------------------------------------------------- 1 | ## yazi 2 | 3 | Setup *yazi*(1), a terminal file manager written in Rust. 4 | 5 | ### Command Aliases 6 | 7 | - `yy`: Call `yazi` with the current working directory and automatically `cd` 8 | to its current directory on exit. 9 | -------------------------------------------------------------------------------- /plugins/googler/googler.zshrc: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # googler.zshrc: Setup googler(1) 3 | 4 | # Make sure that "googler(1)" are installed 5 | (( $+commands[googler] )) || return 6 | 7 | alias g0="googler --show-browser-logs -n $((LINES/6))" 8 | -------------------------------------------------------------------------------- /plugins/thefuck/thefuck.zshrc: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # thefuck.zshrc: Programatically correct mistyped console commands 3 | 4 | # Make sure that "thefuck(1)" is installed 5 | (( $+commands[thefuck] )) || return 6 | 7 | eval "$(thefuck --alias)" 8 | -------------------------------------------------------------------------------- /default_plugins/std_env/std_env.zprofile: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # std_env: Setup standard environment variables 3 | 4 | export MANWIDTH=${MANWIDTH:-80} 5 | 6 | if [[ "$TERM_PROGRAM" != "WarpTerminal" ]]; then 7 | export REPORTTIME=${REPORTTIME:-5} 8 | fi 9 | -------------------------------------------------------------------------------- /plugins/hstr/hstr.zshrc: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # hstr.zshrc: Setup hstr 3 | 4 | axzsh_is_modern_terminal || return 91 5 | 6 | # Make sure that "hstr(1)" is installed 7 | (( $+commands[hstr] )) || return 1 8 | 9 | eval "$(hstr --show-configuration)" 10 | -------------------------------------------------------------------------------- /themes/debian.axzshtheme: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # debian.axzshtheme: Debian theme 3 | 4 | ZSH_THEME_PROMPT_SUFFIX_SPACING=" " 5 | 6 | PS1="%{$fg_bold[green]%}%n@%m%{$reset_color%}:%{$fg_bold[blue]%}%~%{$reset_color%}"'$(axzsh_vcs_prompt)'"$(axzsh_prompt)" 7 | -------------------------------------------------------------------------------- /plugins/command-not-found/command-not-found.zshrc: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # colormake.zshrc: Setup colormake(1) 3 | 4 | # Make sure that "command-not-found" is available ... 5 | [[ -r /etc/zsh_command_not_found ]] || return 6 | 7 | source /etc/zsh_command_not_found 8 | -------------------------------------------------------------------------------- /plugins/fzy/README.md: -------------------------------------------------------------------------------- 1 | ## fzy 2 | 3 | Integrate *fzy*, "a simple, fast fuzzy finder for the terminal", into ZSH. 4 | 5 | ### Usage 6 | 7 | Integrate *fzy*(1) into ZSH. 8 | 9 | ### Key Bindings 10 | 11 | - `CTRL-R`: Paste the selected command from history into the command line. 12 | -------------------------------------------------------------------------------- /plugins/lsd/lsd.zshrc: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # lsd.zshrc: Setup LSD (LSDeluxe), the next gen ls command. 3 | 4 | axzsh_is_modern_terminal || return 91 5 | 6 | # Make sure that "lsd(1)" is installed 7 | (( $+commands[lsd] )) || return 1 8 | 9 | alias ls='lsd' 10 | -------------------------------------------------------------------------------- /plugins/colormake/colormake.zshrc: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # colormake.zshrc: Setup colormake(1) 3 | 4 | # Make sure that "make(1)" and "colormake(1)" are installed 5 | (( $+commands[make] )) || return 6 | (( $+commands[colormake] )) || return 7 | 8 | alias make="colormake" 9 | -------------------------------------------------------------------------------- /plugins/mankier/README.md: -------------------------------------------------------------------------------- 1 | ## mankier 2 | 3 | Setup some functions to use *ManKier*, a online manual page service: 4 | 5 | 6 | ### Prerequisites 7 | 8 | - `curl`(1) 9 | 10 | ### Functions 11 | 12 | - `explain`: Explain a command using ManKier's online API. 13 | -------------------------------------------------------------------------------- /core/99_cleanup/99_cleanup.zshrc: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # 99_cleanup.zshrc: Don't pollute the namespace, remove variables/functions/... 3 | 4 | [[ -o login ]] && return 5 | [[ "$AXZSH_ZPROFILE_READ" = "2" ]] && return 6 | 7 | source "$AXZSH/core/99_cleanup/99_cleanup.zlogin" 8 | -------------------------------------------------------------------------------- /plugins/trash/README.md: -------------------------------------------------------------------------------- 1 | ## trash 2 | 3 | Setup *trash*(1), a tool moving files and folders to the "trash" of macOS. 4 | 5 | ### Command Aliases 6 | 7 | - `rm`: `trash -F` - map *rm*(1) to *trash*(1) and use the Finder to move files 8 | to the trash, so that you can use Finder's "put back" feature. 9 | -------------------------------------------------------------------------------- /plugins/editor_select/editor_select.zshrc: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # editor_select.zshrc: Setup $EDITOR for the "best" available editor 3 | 4 | # Don't run this plugin on "check-plugins"! 5 | [[ -z "$AXZSH_PLUGIN_CHECK" ]] || return 92 6 | 7 | [[ -n "$EDITOR" ]] && alias zshenv="$EDITOR ~/.zshenv" 8 | -------------------------------------------------------------------------------- /plugins/gcc/gcc.zprofile: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # gcc.zprofile: Setup GNU Compiler Collection (GCC) environment. 3 | 4 | # Make sure that "go(1)" is installed 5 | (( $+commands[gcc] )) || return 6 | 7 | GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01' 8 | export GCC_COLORS 9 | -------------------------------------------------------------------------------- /plugins/ccache/README.md: -------------------------------------------------------------------------------- 1 | ## ccache 2 | 3 | Setup *ccache(1)*, "a fast C/C++ compiler cache": 4 | 5 | 1. Configure the cache directory to `$XDG_CACHE_HOME/ccache`, 6 | 2. Search for *ccache* wrapper scripts and setup `$PATH`. 7 | 8 | ### Environment 9 | 10 | - `$PATH`: Prepend include directory containing *ccache* wrapper scripts. 11 | -------------------------------------------------------------------------------- /plugins/ssh-pageant/ssh-pageant.zshrc: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # ssh-pageant.zshrc: Setup ssh-pageant 3 | 4 | # Make sure that "ssh-pageant(1)" is installed. 5 | (( $+commands[ssh-pageant] )) || return 6 | 7 | # Start up agent, reuse existing socket. 8 | eval $(/usr/bin/ssh-pageant -q -r -a /var/run/pageant-$LOGNAME.sock) 9 | -------------------------------------------------------------------------------- /themes/starship.axzshtheme: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # starship.axzshtheme: Enable extnerl "Starship" Theme 3 | # see 4 | 5 | if (( $+commands[starship] )); then 6 | eval "$(starship init zsh)" 7 | else 8 | echo "Oops, starship(1) command not found, can't enable Starship prompt!" >&2 9 | fi 10 | -------------------------------------------------------------------------------- /plugins/zoxide/zoxide.zshrc: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # zoxide.zshrc: Initialize "zoxide" 3 | 4 | # Make sure that "zoxide" is installed 5 | (( $+commands[zoxide] )) || return 1 6 | 7 | # Do not run in check mode, return success immediately. 8 | [[ -z "$AXZSH_PLUGIN_CHECK" ]] || return 0 9 | 10 | eval "$(zoxide init zsh)" 11 | -------------------------------------------------------------------------------- /plugins/bat/bat.zshrc: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # bat.zshrc: Setup bat(1) 3 | 4 | # Make sure that "bat(1)" is installed or "batcat(1)" is available: 5 | if ! (( $+commands[bat] )); then 6 | (( $+commands[batcat] )) || return 1 7 | alias bat='batcat' 8 | fi 9 | 10 | # Use bat(1) as cat(1): 11 | alias cat='bat' 12 | 13 | return 0 14 | -------------------------------------------------------------------------------- /plugins/travis/travis.zshrc: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # travis.zshrc: Setup autocompletion for travis(1). 3 | 4 | # Make sure that "travis(1)" is installed 5 | (( $+commands[travis] )) || return 6 | 7 | # Does the user-local completion file exist? 8 | [[ -r "$HOME/.travis/travis.sh" ]] && source "$HOME/.travis/travis.sh" 9 | return 0 10 | -------------------------------------------------------------------------------- /plugins/python/python.zprofile: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # python: Initialize Python environment 3 | 4 | # Make sure that python(1) or python3(1) is installed 5 | (( $+commands[python] )) || (( $+commands[python3] )) || return 6 | 7 | # pip: require a virtual environment, don't install in the global scope! 8 | export PIP_REQUIRE_VIRTUALENV="true" 9 | -------------------------------------------------------------------------------- /plugins/zkbd/zkbd.ax-io: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # zkbd.ax-io: Initialize ZKBD Keybindings 3 | 4 | [[ -z "$AXZSH_PLUGIN_CHECK" ]] || return 92 5 | 6 | [[ -r ${ZDOTDIR:-$HOME}/.zkbd/$TERM-${${DISPLAY:t}:-$VENDOR-$OSTYPE} ]] && return 0 7 | 8 | # ZKBD is not yet initialized for this terminal type; do it now! 9 | autoload -Uz zkbd 10 | zkbd 11 | -------------------------------------------------------------------------------- /plugins/00-newline/README.md: -------------------------------------------------------------------------------- 1 | ## 00-newline 2 | 3 | This is a somewhat "silly" plugin, which is run at the very beginning of the 4 | initialization sequence and just prints a newline character. 5 | 6 | This can be handy when your terminal emulator or "login tools" print some 7 | messages, but you want the ouput of your plugins and the first shell prompt 8 | clearly separated. 9 | -------------------------------------------------------------------------------- /core/20_home/20_home.ax-io: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # 20_home.ax-io: Setup (local) home directory 3 | 4 | [[ -d "/usr/local/home" && ! -d "/usr/local/home/$LOGNAME" ]] \ 5 | && mkdir -m 700 "/usr/local/home/$LOGNAME" >/dev/null 2>&1 6 | 7 | [[ -w "/usr/local/home/$LOGNAME" ]] \ 8 | && export LOCAL_HOME="/usr/local/home/$LOGNAME" \ 9 | || export LOCAL_HOME="$HOME" 10 | -------------------------------------------------------------------------------- /plugins/virtualenv/README.md: -------------------------------------------------------------------------------- 1 | ## virtualenv 2 | 3 | Define the `activate` function to read in (and therefore to "activate") a 4 | (Python) *virtual environment*, like provided by the "venv" Python module -- but 5 | this module is language agnostic, and can activate all environments providing an 6 | `activate` shell fragment in a known location. 7 | 8 | ### Aliases 9 | 10 | - `activate` 11 | -------------------------------------------------------------------------------- /default_plugins/ls/ls.zprofile: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # ls.zshrc: Setup ls(1) 3 | 4 | if [[ -r ~/.local/share/lscolors.sh ]]; then 5 | # Read lscolors.sh, which should set LS_COLORS; 6 | # see . 7 | source ~/.local/share/lscolors.sh 8 | elif (( $+commands[dircolors] )); then 9 | # Use dircolors(1): 10 | eval $(dircolors) 11 | fi 12 | -------------------------------------------------------------------------------- /default_plugins/ssh/ssh.zprofile: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # ssh.zprofile: Setup (Open-) SSH 3 | 4 | # Make sure that "ssh(1)" is installed 5 | (( $+commands[ssh] )) || return 6 | 7 | unset ssh_cmd 8 | (( $+commands[ssh-q] )) && ssh_cmd="ssh-q" 9 | (( $+commands[ssh-wrapper] )) && ssh_cmd="ssh-wrapper" 10 | if [[ -n "$ssh_cmd" ]]; then 11 | export GIT_SSH="$ssh_cmd" 12 | fi 13 | unset ssh_cmd 14 | -------------------------------------------------------------------------------- /plugins/zsh-navigation-tools/zsh-navigation-tools.zprofile: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # zsh-navigation-tools.zprofile: Initialize "ZSH Navigation Tools" 3 | 4 | for dir ( 5 | "/usr/share/zsh-navigation-tools" 6 | "/usr/local/share/zsh-navigation-tools" 7 | ); do 8 | if [[ -d "$dir" ]]; then 9 | fpath+=($dir) 10 | unset dir 11 | return 0 12 | fi 13 | done 14 | unset dir 15 | return 1 16 | -------------------------------------------------------------------------------- /plugins/docker-machine/docker-machine.zprofile: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # docker.zprofile: Setup "docker" with "docker-machine" 3 | 4 | # Make sure that "docker-machine" is installed 5 | (( $+commands[docker-machine] )) || return 6 | 7 | # Setup environment 8 | if ! eval "$(docker-machine env default 2>/dev/null)"; then 9 | # Clean environment on error 10 | eval "$(docker-machine env -u)" 11 | fi 12 | -------------------------------------------------------------------------------- /plugins/keychain/keychain.zprofile: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # keychain.zprofile: Setup keychain(1) 3 | 4 | # Initialize keychain(1) as soon as possible ("profile") stage, but run it 5 | # in all sessions, in non-login shells, too. So call the "zshrc" script here 6 | # and set a flag that keychain(1) has been initialized already. 7 | source "$AXZSH"/plugins/keychain/keychain.zshrc && axzsh_keychain_was_run=1 8 | -------------------------------------------------------------------------------- /plugins/autojump/autojump.zshrc: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # autojump.zshrc: Initialize "autojump" 3 | 4 | for script ( 5 | "$HOMEBREW_PREFIX/etc/profile.d/autojump.sh" 6 | "/usr/local/etc/profile.d/autojump.sh" 7 | "/usr/share/autojump/autojump.zsh" 8 | ); do 9 | if [[ -r "$script" ]]; then 10 | source "$script" 11 | unset script 12 | return 0 13 | fi 14 | done 15 | unset script 16 | return 1 17 | -------------------------------------------------------------------------------- /plugins/cygwin/cygwin.zprofile: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # cygwin.zprofile: Setup CCache environment 3 | 4 | [[ -d /cygdrive ]] || return 5 | 6 | # Search for directories and apprepend it to "PATH" 7 | for dir ( 8 | /cygdrive/c/Windows 9 | /cygdrive/c/Windows/System32 10 | /cygdrive/c/Windows/System32/WindowsPowerShell/v1.0 11 | ); do 12 | [[ -d "$dir" ]] && PATH="$PATH:$dir" 13 | done 14 | unset dir 15 | -------------------------------------------------------------------------------- /plugins/yazi/yazi.zshrc: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # yazi.zshrc: Setup Yazi file manager 3 | 4 | # Make sure that "yazi(1)" is installed 5 | (( $+commands[yazi] )) || return 6 | 7 | function yy() { 8 | local tmp="$(mktemp -t "yazi-cwd.XXXXXX")" 9 | yazi "$@" --cwd-file="$tmp" 10 | if cwd="$(cat -- "$tmp")" && [[ -n "$cwd" && "$cwd" != "$PWD" ]]; then 11 | cd -- "$cwd" 12 | fi 13 | rm -f -- "$tmp" 14 | } 15 | -------------------------------------------------------------------------------- /plugins/gnupg/README.md: -------------------------------------------------------------------------------- 1 | ## gnupg 2 | 3 | Setup *GnuPG* using *gpg*(1) or *gpg2*(1) command and try to setup a *GnuPG 4 | agent* as well, either by reusing an already running agent process or by 5 | starting a new one. 6 | 7 | - `gpg2`: use the same completions than for `gpg`. 8 | - When `gpg` isn't installed but `gpg2` is, alias it to `gpg`, too. 9 | 10 | ### Command Aliases 11 | 12 | - `gpg`: When `gpg2` is available but `gpg` isn't. 13 | -------------------------------------------------------------------------------- /plugins/powerline-shell/README.md: -------------------------------------------------------------------------------- 1 | ## powerline-shell 2 | 3 | "powerline-shell" (see https://github.com/milkbikis/powerline-shell) 4 | integration for ZSH. 5 | 6 | ### Configuration 7 | 8 | - `POWERLINE_SHELL` ($HOME/powerline-shell.py; $HOME/.powerline-shell.py) 9 | - `POWERLINE_SHELL_MODE` (compatible) 10 | - `POWERLINE_SHELL_CWD_MODE` (fancy) 11 | - `POWERLINE_SHELL_CWD_DEPTH` (4) 12 | 13 | See `powerline-shell.py --help` for details. 14 | -------------------------------------------------------------------------------- /plugins/fzy/fzy.zshrc: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # fzy.zshrc: Setup Git 3 | 4 | axzsh_is_modern_terminal || return 91 5 | 6 | # Make sure that "fzy(1)" is installed 7 | (( $+commands[fzy] )) || return 1 8 | 9 | function history-fzy() { 10 | BUFFER=$(fc -lnr 0 | fzy -l $((LINES/2)) -q "$LBUFFER") 11 | CURSOR=$#BUFFER 12 | zle reset-prompt 13 | } 14 | 15 | zle -N history-fzy 16 | bindkey '^r' history-fzy 17 | 18 | return 0 19 | -------------------------------------------------------------------------------- /plugins/websearch/README.md: -------------------------------------------------------------------------------- 1 | ## websearch 2 | 3 | Setup some functions and aliases to open various search engines (Google, Ecosia, 4 | DuckDuckGo, ...) from the command line. 5 | 6 | ### Functions 7 | 8 | - `duckduckgo`: Open DuckDuckGo for the given search terms. 9 | - `ecosia`: Open Ecosia for the given search terms. 10 | - `google`: Open Google for the given search terms. 11 | 12 | ### Aliases 13 | 14 | - `ddg`: `duckduckgo` 15 | - `eco`: `ecosia` 16 | - `g0`: `google` 17 | -------------------------------------------------------------------------------- /plugins/zsh-navigation-tools/zsh-navigation-tools.zshrc: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # zsh-navigation-tools.zshrc: Initialize "ZSH Navigation Tools" 3 | 4 | for script ( 5 | "/usr/share/zsh-navigation-tools/zsh-navigation-tools.plugin.zsh" 6 | "/usr/local/share/zsh-navigation-tools/zsh-navigation-tools.plugin.zsh" 7 | ); do 8 | if [[ -r "$script" ]]; then 9 | source "$script" 10 | unset script 11 | return 0 12 | fi 13 | done 14 | unset script 15 | return 1 16 | -------------------------------------------------------------------------------- /plugins/jujutsu/README.md: -------------------------------------------------------------------------------- 1 | ## jujutsu 2 | 3 | Enable ZSH *Jujutsu* integration: 4 | 5 | 1. Enhance shell prompt inside *Jujutsu* trees. 6 | 2. Define some aliases. 7 | 8 | ### Command Aliases 9 | 10 | - `jd`: `jj diff` 11 | - `jdesc`: `jj desc` 12 | - `je`: `jj edit` 13 | - `jf`: `jj git fetch` 14 | - `jfa`: `jj git fetch --all-remotes` 15 | - `jlo`: `jj log` 16 | - `jp`: `jj git push` 17 | - `jr`: `jj git remote` 18 | - `jrb`: `jj rebase` 19 | - `jsh`: `jj show` 20 | - `jst`: `jj status` 21 | -------------------------------------------------------------------------------- /plugins/bashcompletion/bashcompletion.zshrc: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # bashcompletion.zsh: load bash(1) completion scripts into ZSH. 3 | 4 | scripts=(/etc/bash_completion.d/*(N)) 5 | 6 | # Check if bash completion script are available 7 | if [[ -z "$scripts" ]]; then 8 | unset scripts 9 | return 1 10 | fi 11 | 12 | autoload -U bashcompinit 13 | bashcompinit 14 | 15 | for script ($scripts); do 16 | source "$script" 17 | done 18 | unset script scripts 19 | 20 | return 0 21 | -------------------------------------------------------------------------------- /default_plugins/correction/correction.zshrc: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # correction.zshrc: Setup correction 3 | 4 | setopt correct_all 5 | 6 | # Ignore completion functions starting with an "_", never offer them as a 7 | # correction! 8 | CORRECT_IGNORE='_*' 9 | 10 | # Ignore dot files, don't offer them as a correction. 11 | CORRECT_IGNORE_FILE='.*' 12 | 13 | SPROMPT="$ZSH_NAME: Correct \"$fg[yellow]%R$reset_color\" to \"$fg[green]%r$reset_color\" [$fg_bold[white]nyae$reset_color]? " 14 | 15 | -------------------------------------------------------------------------------- /plugins/browser_select/README.md: -------------------------------------------------------------------------------- 1 | ## browser_select 2 | 3 | Search for the "best" WWW browser and setup environment (`$BROWSER`) accordingly. 4 | 5 | The plugin looks for the following WWW browsers and stops at the first one it finds: 6 | 7 | - open (on non-Linux platforms) 8 | - firefox (when DISPLAY is set) 9 | - chrome (when DISPLAY is set) 10 | - elinks 11 | - w3m 12 | - links2 13 | - links 14 | - lynx 15 | 16 | ### Environment 17 | 18 | - `$BROWSER`: Command (including parameters) to run a WWW browser. 19 | -------------------------------------------------------------------------------- /core/11_terminal/11_terminal.ax-io: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # 11_terminal.ax-io: Initialize terminal settings 3 | 4 | # Use tset(1) to validate TERM when stdin as a tty. Explicitly set SHELL to 5 | # /bin/sh to force tset to output sh-compliant commands even when SHELL was not 6 | # set correctly or for an other shell. 7 | [[ -t 0 ]] && eval `SHELL=/bin/sh tset -Is -m "dec-vt52:vt52"` 8 | 9 | # Save the initial TERM value: 10 | [[ -n "$TERM" && -z "$TERM_INITIAL" ]] && export TERM_INITIAL="$TERM" 11 | -------------------------------------------------------------------------------- /default_plugins/std_env/std_env.zshrc: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # std_env: Setup standard environment variables 3 | 4 | # Note: colors aren't available in the "zprofile" stage, so we have to set 5 | # these variables here (and therefore exporting makes no sense) ... 6 | TIMEFMT="%J - $fg[green]%U$reset_color user; $fg[red]%S$reset_color system; $fg_bold[white]%*E$reset_color total ($fg[yellow]%P$reset_color cpu)." 7 | WATCHFMT="$fg_bold[white]%n$reset_color has $fg_bold[white]%a$reset_color from %M (%l)." 8 | -------------------------------------------------------------------------------- /plugins/zsh-autosuggestions/zsh-autosuggestions.zshrc: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # zsh-autosuggestions.zshrc: Initialize "Fish-like autosuggestions for zsh" 3 | 4 | axzsh_is_dumb_terminal && return 91 5 | 6 | for script ( 7 | "/usr/share/zsh-autosuggestions/zsh-autosuggestions.zsh" 8 | "/usr/local/share/zsh-autosuggestions/zsh-autosuggestions.zsh" 9 | ); do 10 | if [[ -r "$script" ]]; then 11 | source "$script" 12 | unset script 13 | return 0 14 | fi 15 | done 16 | unset script 17 | return 1 18 | -------------------------------------------------------------------------------- /plugins/editor_select/README.md: -------------------------------------------------------------------------------- 1 | ## editor_select 2 | 3 | Search for the "best" editor and setup environment (`$EDITOR`) accordingly. 4 | 5 | The plugin looks for the following editors and stops at the first one it finds: 6 | 7 | - atom 8 | - mate 9 | - subl 10 | - vim 11 | - nano 12 | - joe 13 | - vi 14 | 15 | ### Command Aliases 16 | 17 | - `zshenv`: Edit `~/.zshenv` using `$EDITOR` 18 | (only available if an editor was found). 19 | 20 | ### Environment 21 | 22 | - `$EDITOR`: Command (including parameters) to run an text editor. 23 | -------------------------------------------------------------------------------- /plugins/ssh_secure/ssh_secure.zshrc: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # ssh_secure.zshrc: Make SSH operations more secure 3 | 4 | # Make sure that "ssh(1)" is installed 5 | (( $+commands[ssh] )) || return 6 | 7 | # This plugin is optional. 8 | [[ -z "$AXZSH_PLUGIN_CHECK" ]] || return 92 9 | 10 | # Enforce "strict host key checking" 11 | alias sshnew='ssh -o "StrictHostKeyChecking no"' 12 | alias sshtmp='ssh -o "StrictHostKeyChecking no" -o "UserKnownHostsFile /dev/null"' 13 | 14 | compdef sshnew=ssh 15 | compdef sshtmp=ssh 16 | -------------------------------------------------------------------------------- /default_plugins/std_options/std_options.zshrc: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # std_options.zshrc: Setup standard ZSH options 3 | 4 | # Change directories by just entering their names 5 | setopt auto_cd 6 | 7 | # Automatically push directories to the directory stack 8 | setopt autopushd 9 | setopt pushdignoredups 10 | 11 | # Recognize comments in interactive mode, too 12 | setopt interactivecomments 13 | 14 | # Display PID when suspending processes as well 15 | setopt longlistjobs 16 | 17 | # Watch for logins of everyone but me 18 | watch=(notme) 19 | -------------------------------------------------------------------------------- /core/80_local_config/80_local_config.zshrc: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # 80_local_config.zshrc: Read local configuration 3 | 4 | if [[ -r "$HOME/.zshrc.local" ]]; then 5 | [[ -n "$AXZSH_DEBUG" ]] && echo "» $HOME/.zshrc.local:" 6 | source "$HOME/.zshrc.local" 7 | [[ -n "$AXZSH_DEBUG" ]] && echo "» $HOME/.zshrc.local (end)" 8 | fi 9 | 10 | if [[ -r "/var/lib/$HOST/zshrc" ]]; then 11 | [[ -n "$AXZSH_DEBUG" ]] && echo "» /var/lib/$HOST/zshrc:" 12 | source "/var/lib/$HOST/zshrc" 13 | [[ -n "$AXZSH_DEBUG" ]] && echo "» /var/lib/$HOST/zshrc (end)" 14 | fi 15 | -------------------------------------------------------------------------------- /plugins/hstr/README.md: -------------------------------------------------------------------------------- 1 | ## hstr 2 | 3 | Integrate *hstr*, a "bash and zsh shell history suggest box", into ZSH. 4 | 5 | ### Usage 6 | 7 | This plugin uses the "hstr --show-configuration" itself to enable *hstr* 8 | functionality in ZSH. 9 | at the time of this writing, April 22 2020 using *fzf* 2.2.0, this is 10 | 11 | 1. set "histignorespace" shell option, 12 | 2. add "hh" alias, 13 | 3. add Keybindings. 14 | 15 | ### Command Aliases 16 | 17 | - `hh`: `hstr` 18 | 19 | ### Key Bindings 20 | 21 | - `CTRL-R`: Paste the selected command from history into the command line. 22 | -------------------------------------------------------------------------------- /plugins/README.md: -------------------------------------------------------------------------------- 1 | AX-ZSH: Alex' Modular ZSH Configuration - Plugin Documentation 2 | ============================================================== 3 | 4 | Plugin Exit Codes 5 | ----------------- 6 | 7 | - 0: OK 8 | - 1: Error 9 | - 91: Ignore 10 | - 92: Optional 11 | 12 | 13 | Detecting "Plugin Check" Run 14 | ---------------------------- 15 | 16 | When `axzshctl check-plugins` is doing a _plugin check_ run, the enviromnet 17 | variable `AXZSH_PLUGIN_CHECK` is "non-zero"; this can be tested like this: 18 | 19 | ``` 20 | [[ -z "$AXZSH_PLUGIN_CHECK" ]] || return 92 21 | ``` 22 | -------------------------------------------------------------------------------- /core/80_local_config/80_local_config.zlogin: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # 80_local_config.zlogin: Read local configuration 3 | 4 | if [[ -r "$HOME/.zlogin.local" ]]; then 5 | [[ -n "$AXZSH_DEBUG" ]] && echo "» $HOME/.zlogin.local:" 6 | source "$HOME/.zlogin.local" 7 | [[ -n "$AXZSH_DEBUG" ]] && echo "» $HOME/.zlogin.local (end)" 8 | fi 9 | 10 | if [[ -r "/var/lib/$HOST/zlogin" ]]; then 11 | [[ -n "$AXZSH_DEBUG" ]] && echo "» /var/lib/$HOST/zlogin:" 12 | source "/var/lib/$HOST/zlogin" 13 | [[ -n "$AXZSH_DEBUG" ]] && echo "» /var/lib/$HOST/zlogin (end)" 14 | fi 15 | -------------------------------------------------------------------------------- /core/80_local_config/80_local_config.zlogout: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # 80_local_config.zlogout: Read local configuration 3 | 4 | if [[ -r "$HOME/.zlogout.local" ]]; then 5 | [[ -n "$AXZSH_DEBUG" ]] && echo "» $HOME/.zlogout.local:" 6 | source "$HOME/.zlogout.local" 7 | [[ -n "$AXZSH_DEBUG" ]] && echo "» $HOME/.zlogout.local (end)" 8 | fi 9 | 10 | if [[ -r "/var/lib/$HOST/zlogout" ]]; then 11 | [[ -n "$AXZSH_DEBUG" ]] && echo "» /var/lib/$HOST/zlogout:" 12 | source "/var/lib/$HOST/zlogout" 13 | [[ -n "$AXZSH_DEBUG" ]] && echo "» /var/lib/$HOST/zlogout (end)" 14 | fi 15 | -------------------------------------------------------------------------------- /plugins/00-newline/00-newline.ax-io: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # 00-newline.ax-io: Print an empty line ... 3 | 4 | # Don't run this plugin on "check-plugins"! 5 | [[ -z "$AXZSH_PLUGIN_CHECK" ]] || return 92 6 | 7 | # Check prerequisites ... 8 | [[ -o interactive ]] || return 91 9 | [[ -z "$STY" ]] || return 91 10 | [[ -z "$TMUX" ]] || return 91 11 | 12 | # Don't output anything ~/.hushlogin exists ... 13 | [[ -r ~/.hushlogin ]] && return 0 14 | 15 | # Don't add a newline in graphical environments: 16 | [[ -n "$DISPLAY" || -n "$WAYLAND_DISPLAY" ]] && return 0 17 | 18 | echo 19 | -------------------------------------------------------------------------------- /default_plugins/10-hello/10-hello.ax-io: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # 10-hello.ax-io: Greet the user in the (new) environment 3 | 4 | # Don't run this plugin on "check-plugins"! 5 | [[ -z "$AXZSH_PLUGIN_CHECK" ]] || return 0 6 | 7 | # Don't show any info when ~/.hushlogin exists ... 8 | [[ -r ~/.hushlogin ]] && return 0 9 | 10 | # Check for a container environment: 11 | if [[ -e /run/.containerenv ]]; then 12 | # Try to get some infos about the environment ... 13 | unset name 14 | . /run/.containerenv 2>/dev/null 15 | echo "You entered the ${name:-container} environment." 16 | fi 17 | -------------------------------------------------------------------------------- /core/50_path/50_path.zprofile: -------------------------------------------------------------------------------- 1 | # # AX-ZSH: Alex' Modular ZSH Configuration 2 | # 50_path.zprofile: Fix PATH environment after plugins ran 3 | 4 | # Prepend and append search paths (in a special order!) 5 | _axzsh_setup_path 6 | unfunction _axzsh_setup_path 7 | typeset -Ux PATH 8 | 9 | # Set default MANPATH 10 | MANPATH="$(manpath -q)" 2>/dev/null 11 | if [[ $? -ne 0 ]]; then 12 | for d ( 13 | ~/share/man 14 | ~/man 15 | /opt/*/share/man(NOn) 16 | /opt/*/man(NOn) 17 | /usr/share/man 18 | /usr/local/share/man 19 | ); do 20 | [[ -d "$d" ]] && manpath+=("$d") 21 | done 22 | fi 23 | typeset -Ux MANPATH 24 | -------------------------------------------------------------------------------- /plugins/gnupg/gnupg.zshrc: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # gnupg.zshrc: Setup GnuPG 3 | 4 | if (( $+commands[gpg2] )); then 5 | # Use the gpg completions for gpg2, too 6 | compdef gpg2=gpg 7 | 8 | if ! (( $+commands[gpg])); then 9 | # gpg2 is available, but no gpg: alias it! 10 | alias gpg="gpg2" 11 | fi 12 | else 13 | # Make sure that "gpg(1)" is available. 14 | (( $+commands[gpg] )) || return 1 15 | fi 16 | 17 | export GPG_TTY=$TTY 18 | 19 | if (( $+commands[gpg-connect-agent] )); then 20 | # Try to start/connect the agent ... 21 | ( gpg-connect-agent /bye >/dev/null 2>&1 ) 22 | fi 23 | -------------------------------------------------------------------------------- /core/30_hostname/30_hostname.zprofile: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # 30_hostname.zprofile: Initialize hostname settings 3 | 4 | # Setup legacy "HOSTNAME" variable (use "HOST"!) 5 | [[ -z "$HOSTNAME" ]] && HOSTNAME="$HOST" 6 | export HOSTNAME 7 | 8 | # Setup "SHORT_HOST" variable 9 | if (( $+commands[scutil] )); then 10 | SHORT_HOST=$(scutil --get ComputerName 2>/dev/null) 11 | elif (( $+commands[hostnamectl] )); then 12 | SHORT_HOST=$(hostnamectl --pretty 2>/dev/null) 13 | [[ "$SHORT_HOST" =~ : ]] && unset SHORT_HOST 14 | fi 15 | [[ -z "$SHORT_HOST" ]] && SHORT_HOST=${HOST/.*/} 16 | export SHORT_HOST 17 | -------------------------------------------------------------------------------- /plugins/go/go.zprofile: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # go.zprofile: Setup Go environment. 3 | 4 | # Make sure that "go(1)" is installed 5 | (( $+commands[go] )) || return 6 | 7 | # Try to detect existing GOPATH directory ... 8 | if [[ -z "$GOPATH" ]]; then 9 | for gopath in $HOME/.go $HOME/go; do 10 | if [[ -d "$gopath" ]]; then 11 | GOPATH="$gopath" 12 | break 13 | fi 14 | done 15 | unset gopath 16 | fi 17 | 18 | # Make sure a GOPATH directory exists: 19 | if [[ -z "$GOPATH" ]]; then 20 | GOPATH="$HOME/.go" 21 | mkdir -p "$GOPATH" 22 | fi 23 | 24 | path+=("$GOPATH/bin") 25 | export GOPATH 26 | -------------------------------------------------------------------------------- /plugins/ccache/ccache.zprofile: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # ccache.zprofile: Setup CCache environment 3 | 4 | # Make sure that "ccache(1)" is installed 5 | (( $+commands[ccache] )) || return 6 | 7 | # Setup cache location 8 | export CCACHE_DIR="$XDG_CACHE_HOME/ccache" 9 | 10 | # Search for directory with wrapper commands and prepend it to "PATH" 11 | for dir ( 12 | /usr/local/opt/ccache/libexec 13 | /usr/local/lib/ccache 14 | /opt/ccache/libexec 15 | /usr/libexec/ccache 16 | /usr/lib/ccache 17 | ); do 18 | if [[ -d "$dir" ]]; then 19 | PATH="$dir:$PATH" 20 | break 21 | fi 22 | done 23 | unset dir 24 | -------------------------------------------------------------------------------- /plugins/homebrew/README.md: -------------------------------------------------------------------------------- 1 | ## homebrew 2 | 3 | Setup "Homebrew" ("The missing package manager for OS X", http://brew.sh): 4 | 5 | - Enable ZSH completions installed by Homebrew formulae. 6 | - Install a `brew` wrapper function. 7 | 8 | This wrapper function for the `brew`(1) command does the following: 9 | 10 | - Detect the location of the "real" brew(1) command. 11 | - Change user and group when the Homebrew installation is owned by a different 12 | user (to preserve sane file permissions). 13 | - Set a relaxed umask(1) so that other users can use software installed by 14 | Homebrew. 15 | - Call the "real" `brew`(1) command. 16 | -------------------------------------------------------------------------------- /plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zshrc: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # zsh-syntax-highlighting.zshrc: Initialize "ZSH Syntax Highlighting" 3 | 4 | axzsh_is_dumb_terminal && return 91 5 | 6 | for script ( 7 | "/usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" 8 | "/usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" 9 | ); do 10 | if [[ -r "$script" ]]; then 11 | [[ -n "$ZSH_HIGHLIGHT_HIGHLIGHTERS" ]] \ 12 | && ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets) 13 | source "$script" 14 | unset script 15 | return 0 16 | fi 17 | done 18 | unset script 19 | return 1 20 | -------------------------------------------------------------------------------- /default_plugins/ls/ls.zshrc: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # ls.zshrc: Setup ls(1) 3 | 4 | # Check which ls-alike command to use 5 | if (( $+commands[gls] )); then 6 | cmd="gls" # GNU ls (on NetBSD, for example) 7 | elif (( $+commands[colorls] )); then 8 | cmd="colorls" # OpenBSD 9 | else 10 | cmd="ls" 11 | fi 12 | 13 | if $cmd --color -d . >/dev/null 2>&1; then 14 | alias ls="$cmd -F --color=tty" 15 | elif $cmd -G -d . >/dev/null 2>&1; then 16 | alias ls="$cmd -FG" 17 | fi 18 | 19 | # Use LS_COLORS for completion too, when available 20 | if [[ -n "$LS_COLORS" ]]; then 21 | zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS} 22 | fi 23 | -------------------------------------------------------------------------------- /core/99_zlogin/99_zlogin.zshrc: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # 99_zlogin.zshrc: Make sure zlogin files are read 3 | 4 | [[ "$AXZSH_ZPROFILE_READ" = "2" ]] || return 5 | 6 | # AXZSH_ZPROFILE_READ is set to 2 when the "ax-io" and "zprofile" were caught 7 | # up because this is not a login shell and the environment was missing. In this 8 | # case the "zlogin" stage will be missing in the end as well and therefore we 9 | # run the "zlogin" stage manually, too. 10 | [[ -n "$AXZSH_DEBUG" ]] && echo "» 99_zlogin.zshrc:" 11 | 12 | axzsh_handle_stage "99_zlogin.zshrc" "zlogin" 13 | AXZSH_ZLOGIN_READ=2 14 | 15 | [[ -n "$AXZSH_DEBUG" ]] && echo "» 99_zlogin.zshrc (end)" 16 | -------------------------------------------------------------------------------- /plugins/keychain/keychain.zshrc: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # keychain.zshrc: Setup keychain(1) 3 | 4 | # Test if keychain(1) has already been initialized, for example in the 5 | # "profile" stage. 6 | if [[ -n "$axzsh_keychain_was_run" ]]; then 7 | unset axzsh_keychain_was_run 8 | return 9 | fi 10 | 11 | # Make sure that "keychain(1)" is installed 12 | (( $+commands[keychain] )) || return 13 | 14 | function axzsh_keychain_update() { 15 | eval `keychain --eval --inherit any-once "$@"` 16 | } 17 | 18 | [[ "$type" == "zshrc" ]] \ 19 | && axzsh_keychain_update --quiet --quick \ 20 | || axzsh_keychain_update --quiet 21 | 22 | unset axzsh_keychain_was_run 23 | -------------------------------------------------------------------------------- /core/30_env/30_env.zshrc: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # 30_env.zshrc: Setup environment 3 | 4 | if [[ 5 | "$TMPDIR" = '/' || 6 | -z "$TMPDIR" || 7 | -z "$XDG_CACHE_HOME" || 8 | -z "$XDG_RUNTIME_DIR" || 9 | -z "$ZSH_CACHE_DIR" 10 | ]]; then 11 | # Looks like the environment wasn't set up/exported properly! 12 | [[ -n "$AXZSH_DEBUG" ]] && echo 'Note: Fixing up the environment!' 13 | . "$AXZSH/core/30_env/30_env.ax-io" 14 | fi 15 | 16 | function axzsh_update_session() { 17 | state="${ZSH_CACHE_DIR}/axzsh_session_state" 18 | if [[ -r "$state" ]]; then 19 | . "$state" 20 | else 21 | echo "No state file found: \"$state\"!" >&2 22 | return 1 23 | fi 24 | } 25 | -------------------------------------------------------------------------------- /core/40_axzsh/40_axzsh.zshrc: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # 50_axzsh.zshrc: Initialize AX-ZSH 3 | 4 | function axzshctl() { 5 | AXZSH_THEME="$AXZSH_THEME" zsh "$AXZSH/bin/axzshctl" "$@" || return $? 6 | 7 | if [[ "$1" = "disable" ]]; then 8 | unset AXZSH AXZSH_FPATH AXZSH_ZLOGIN_READ AXZSH_ZPROFILE_READ 9 | fi 10 | 11 | case "$1" in 12 | "disable"*|"enable"*|"reset"*|"set"*|"up"*) 13 | # Command which potentially "changed state". 14 | if [[ -o login ]]; then 15 | echo "Restarting login shell ..." 16 | exec -l "$SHELL" 17 | else 18 | echo "Restarting shell ..." 19 | exec "$SHELL" 20 | fi 21 | ;; 22 | esac 23 | return 0 24 | } 25 | -------------------------------------------------------------------------------- /core/10_keyboard/10_keyboard.zshrc: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # 10_keyboard.zshrc: Initialize keyboard settings 3 | 4 | bindkey -e 5 | 6 | bindkey "^[[3~" delete-char 7 | bindkey "^[3;5~" delete-char 8 | bindkey "\e[3~" delete-char 9 | 10 | # Allow editing of the current command line in $EDITOR 11 | autoload -Uz edit-command-line 12 | zle -N edit-command-line 13 | bindkey '\C-x\C-e' edit-command-line 14 | 15 | # Move to where the arguments belong. 16 | after-first-word() { 17 | zle beginning-of-line 18 | zle forward-word 19 | } 20 | zle -N after-first-word 21 | bindkey "\C-x1" after-first-word 22 | 23 | # Push back current line. 24 | bindkey '\C-x\C-p' push-line 25 | -------------------------------------------------------------------------------- /plugins/websearch/websearch.zshrc: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # google.zshrc: Setup functions for using Google in the command line 3 | 4 | # This is an optional plugin. 5 | [[ -z "$AXZSH_PLUGIN_CHECK" ]] || return 92 6 | 7 | function duckduckgo { 8 | url="https://duckduckgo.com/?q=$@" 9 | open_command "$url" || echo "DuckDuckGo: <$url>" 10 | } 11 | alias ddg='duckduckgo' 12 | 13 | function ecosia { 14 | url="https://www.ecosia.org/search?q=$@" 15 | open_command "$url" || echo "Ecosia: <$url>" 16 | } 17 | alias eco='ecosia' 18 | 19 | function google { 20 | url="https://www.google.de/search?q=$@" 21 | open_command "$url" || echo "Google: <$url>" 22 | } 23 | alias g0='google' 24 | -------------------------------------------------------------------------------- /plugins/nodejs/nodejs.zprofile: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # nodejs.zprofile: Setup Nodejs (and NPM) environment. 3 | 4 | # Make sure that NodeJS is installed 5 | (( $+commands[node] )) || return 6 | 7 | npm_packages="${HOME}/.npm-packages" 8 | 9 | if [[ -z "$AXZSH_PLUGIN_CHECK" && ! -d "$npm_packages" ]]; then 10 | # Create the user-local NPM package directory (when not running then 11 | # "plugin check" right now) and the directory doesn't exist yet: 12 | mkdir -p "$npm_packages" 13 | fi 14 | 15 | # Append nodejs paths to binary and manual search paths. 16 | export PATH="$PATH:$npm_packages/bin" 17 | export MANPATH="$MANPATH:$npm_packages/share/man" 18 | 19 | unset npm_packages 20 | -------------------------------------------------------------------------------- /themes/ohmyzsh.axzshtheme: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # ohmyzsh.axzshtheme: OhMyZSH "robbyrussell" theme 3 | 4 | ret_status="%(?:%{$fg_bold[green]%}➜ :%{$fg_bold[red]%}➜ %s)" 5 | PS1='${ret_status} %{$fg[cyan]%}%c%b $(axzsh_vcs_prompt)%b ' 6 | 7 | ZSH_THEME_VCS_PROMPT_PREFIX_SPACING="%{$fg_bold[blue]%}vcs:(" 8 | ZSH_THEME_VCS_PROMPT_PREFIX="%{$fg[red]%}" 9 | ZSH_THEME_VCS_PROMPT_SUFFIX="" 10 | ZSH_THEME_VCS_PROMPT_SUFFIX_SPACING="" 11 | 12 | ZSH_THEME_VCS_PROMPT_CLEAN="%{$fg[blue]%})%{$reset_color%}" 13 | ZSH_THEME_VCS_PROMPT_DIRTY="%{$fg[blue]%}) %{$fg[yellow]%}✗%{$reset_color%}" 14 | 15 | # No VCS ahed and behind markers 16 | ZSH_THEME_VCS_PROMPT_AHEAD="" 17 | ZSH_THEME_VCS_PROMPT_BEHIND="" 18 | -------------------------------------------------------------------------------- /plugins/fzf/README.md: -------------------------------------------------------------------------------- 1 | ## fzf 2 | 3 | Integrate *fzf*, "a command-line fuzzy finder", into ZSH. 4 | 5 | ### Usage 6 | 7 | This plugin uses the ZSH configuration files of *fzf*(1) itself to enable 8 | *fzf* functionality in ZSH; 9 | at the time of this writing, September 26 2015 using *fzf* 0.10.5, this is 10 | 11 | 1. Fuzzy completion for in the command line, triggered by `**`+``, see 12 | https://github.com/junegunn/fzf#fuzzy-completion-for-bash-and-zsh for 13 | details. 14 | 2. Add Keybindings. 15 | 16 | ### Key Bindings 17 | 18 | - `CTRL-T`: Paste the selected file path(s) into the command line. 19 | - `ALT-C`: `cd` into the selected directory. 20 | - `CTRL-R`: Paste the selected command from history into the command line. 21 | -------------------------------------------------------------------------------- /default_plugins/history/history.zshrc: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # history.zshrc: Setup ZSH history 3 | 4 | function clear_history { 5 | local HISTSIZE=0 6 | cat /dev/null >"$HISTFILE" 7 | fc -R 8 | } 9 | 10 | [[ -n "$HISTFILE" ]] || HISTFILE="${ZDOTDIR:-$HOME}/.zsh_history" 11 | 12 | HISTSIZE=10000 13 | SAVEHIST=$HISTSIZE 14 | 15 | setopt append_history 16 | setopt extended_history 17 | setopt hist_expire_dups_first 18 | setopt hist_find_no_dups 19 | setopt hist_ignore_all_dups 20 | setopt hist_ignore_dups 21 | setopt hist_ignore_space 22 | setopt hist_save_no_dups 23 | setopt hist_verify 24 | setopt inc_append_history 25 | setopt share_history 26 | 27 | alias history='fc -il 1' 28 | 29 | bindkey '^p' history-search-backward 30 | bindkey '^n' history-search-forward 31 | -------------------------------------------------------------------------------- /plugins/mankier/mankier.zshrc: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # mankier.zshrc: Setup ManKier online manual page service. 3 | 4 | [[ -z "$AXZSH_PLUGIN_CHECK" ]] || return 92 5 | 6 | # curl(1) is required to access the online API 7 | (( $+commands[curl] )) || return 8 | 9 | explain () { 10 | # Explain a shell command. See: 11 | # 12 | 13 | local api_url="https://www.mankier.com/api/v2" 14 | 15 | if [[ "$#" -eq 0 ]]; then 16 | while read 'cmd?Explain: '; do 17 | [[ -n "$cmd" ]] || break 18 | curl -Gs "$api_url/explain/?cols=$(tput cols)" --data-urlencode q="$cmd" | less 19 | done 20 | echo "Bye!" 21 | else 22 | curl -Gs "$api_url/explain/?cols=$(tput cols)" --data-urlencode q="$*" | less 23 | fi 24 | } 25 | -------------------------------------------------------------------------------- /core/80_local_config/80_local_config.ax-io: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # 80_local_config.ax-io: Read local configuration 3 | 4 | if [[ -r "$HOME/.zprofile.local" ]]; then 5 | [[ -n "$AXZSH_DEBUG" ]] && echo "» $HOME/.zprofile.local:" 6 | source "$HOME/.zprofile.local" 7 | [[ -n "$AXZSH_DEBUG" ]] && echo "» $HOME/.zprofile.local (end)" 8 | fi 9 | 10 | if [[ -r "/var/lib/$HOST/zprofile" ]]; then 11 | [[ -n "$AXZSH_DEBUG" ]] && echo "» /var/lib/$HOST/zprofile:" 12 | source "/var/lib/$HOST/zprofile" 13 | [[ -n "$AXZSH_DEBUG" ]] && echo "» /var/lib/$HOST/zprofile (end)" 14 | elif [[ -r "/var/lib/$HOST/profile" ]]; then 15 | [[ -n "$AXZSH_DEBUG" ]] && echo "» /var/lib/$HOST/profile:" 16 | source "/var/lib/$HOST/profile" 17 | [[ -n "$AXZSH_DEBUG" ]] && echo "» /var/lib/$HOST/profile (end)" 18 | fi 19 | -------------------------------------------------------------------------------- /default_plugins/grep/grep.zshrc: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # grep.zshrc: Setup grep 3 | 4 | # Make sure that "grep(1)" is installed 5 | (( $+commands[grep] )) || return 6 | 7 | grep-flag-available() { 8 | echo | grep "$1" "" >/dev/null 2>&1 9 | } 10 | 11 | grep_options="" 12 | vcs_folders="{.bzr,.cvs,.git,.hg,.svn}" 13 | 14 | # Color 15 | if grep-flag-available "--color=auto"; then 16 | grep_options+=" --color=auto" 17 | fi 18 | 19 | # Exclude VCS folders 20 | if grep-flag-available "--exclude-dir=.csv"; then 21 | grep_options+=" --exclude-dir=$vcs_folders" 22 | elif grep-flag-available "--exclude=.csv"; then 23 | grep_options+=" --exclude=$vcs_folders" 24 | fi 25 | 26 | [[ -n "$options" ]] && alias grep="grep${grep_options}" 27 | 28 | unfunction grep-flag-available 29 | unset grep_options 30 | unset vcs_folders 31 | -------------------------------------------------------------------------------- /default_plugins/less/less.zprofile: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # less.zprofile: Setup less 3 | 4 | # Make sure that "less(1)" is installed 5 | (( $+commands[less] )) || return 6 | 7 | export PAGER="${PAGER:-$commands[less]}" 8 | export LESS="${LESS:--FMRSX}" 9 | 10 | # Support colors in less 11 | export LESS_TERMCAP_mb=$'\E[01;31m' 12 | export LESS_TERMCAP_md=$'\E[01;31m' 13 | export LESS_TERMCAP_me=$'\E[0m' 14 | export LESS_TERMCAP_se=$'\E[0m' 15 | export LESS_TERMCAP_so=$'\E[01;44;33m' 16 | export LESS_TERMCAP_ue=$'\E[0m' 17 | export LESS_TERMCAP_us=$'\E[01;32m' 18 | 19 | if (( $+commands[lesspipe] )); then 20 | eval "$(lesspipe)" 21 | elif (( $+commands[lesspipe.sh] )); then 22 | # Silence lesspipe(1), see 23 | export LESSQUIET=1 24 | eval "$(lesspipe.sh 2>/dev/null)" 25 | fi 26 | -------------------------------------------------------------------------------- /core/05_fpath/05_fpath.zshrc: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # 05_fpath.zshrc: Setup AX-ZSH "fpath" 3 | 4 | typeset -xTU AXZSH_FPATH axzsh_fpath 2>/dev/null 5 | 6 | # Search for additional ZSH function paths: lower priority than plugins 7 | for dir ( 8 | /usr/local/share/zsh/site-functions(N) 9 | /usr/share/zsh/site-functions(N) 10 | ); do 11 | [[ -d "$dir" ]] && axzsh_fpath=($axzsh_fpath "$dir") 12 | done 13 | 14 | # Add current "fpath" to axzsh_fpath 15 | axzsh_fpath=($axzsh_fpath $fpath) 16 | 17 | # Search for additional ZSH function paths: higher priority than plugins 18 | for dir ( 19 | $HOME/.config/zsh/functions(N) 20 | $HOME/.zsh/functions(N) 21 | ); do 22 | [[ -d "$dir" ]] && axzsh_fpath=("$dir" $axzsh_fpath) 23 | done 24 | 25 | # Set ZSH "fpath" from axzsh_fpath (which is exported to subshells) 26 | fpath=($axzsh_fpath) 27 | -------------------------------------------------------------------------------- /plugins/virtualenvwrapper/virtualenvwrapper.zshrc: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # virtualenvwrapper: Initialize Python "virtualenvwrapper" 3 | 4 | for script ( 5 | /usr/local/bin/virtualenvwrapper_lazy.sh 6 | /usr/local/bin/virtualenvwrapper.sh 7 | /usr/bin/virtualenvwrapper.sh 8 | /etc/bash_completion.d/virtualenvwrapper 9 | ); do 10 | if [[ -r "$script" ]]; then 11 | # Found virtualenvwrapper 12 | [[ -z "$PROJECT_HOME" && -r "$LOCAL_HOME/Develop" ]] \ 13 | && PROJECT_HOME="$LOCAL_HOME/Develop" 14 | [[ -z "$PROJECT_HOME" && -r "$HOME/Develop" ]] \ 15 | && PROJECT_HOME="$HOME/Develop" 16 | [[ -z "$WORKON_HOME" ]] \ 17 | && WORKON_HOME="$XDG_CACHE_HOME/virtualenvs" 18 | 19 | source "$script" 20 | unset script 21 | break 22 | fi 23 | done 24 | unset script 25 | [[ -n "$VIRTUALENVWRAPPER_SCRIPT" ]] || return 1 26 | -------------------------------------------------------------------------------- /plugins/neofetch/neofetch.ax-io: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # neofetch.ax-io: Show fastfetch(1) [preferred] or neofetch(1) system information. 3 | 4 | # Make sure that fastfetch(1) or neofetch(1) is installed. 5 | (( $+commands[fastfetch] )) || (( $+commands[neofetch] )) || return 1 6 | 7 | # Don't run this plugin on "check-plugins"! 8 | [[ -z "$AXZSH_PLUGIN_CHECK" ]] || return 0 9 | 10 | # Don't show any info when ~/.hushlogin exists ... 11 | [[ -r ~/.hushlogin ]] && return 0 12 | 13 | # Check if neofetch(1) infos have been shown during last 60 minutes, and if so, 14 | # don't show them now but return. 15 | [[ -z $(find "$XDG_CACHE_HOME/axzsh_last_neofetch" -mmin -60 2>/dev/null) ]] || return 0 16 | 17 | if (( $+commands[fastfetch] )); then 18 | fastfetch 19 | elif (( $+commands[neofetch] )); then 20 | neofetch 21 | else 22 | return 0 23 | fi 24 | 25 | # Wtite "stamp" file. 26 | [[ -w "$XDG_CACHE_HOME" ]] && touch "$XDG_CACHE_HOME/axzsh_last_neofetch" 27 | -------------------------------------------------------------------------------- /default_plugins/byebye/byebye.zlogout: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # byebye.zlogout -- Say goodbye to interactive users 3 | 4 | [[ -o interactive ]] || return 5 | [[ -z "$AXZSH_PLUGIN_CHECK" ]] || return 92 6 | 7 | # Check for a container environment: 8 | if [[ -e /run/.containerenv ]]; then 9 | # Try to get some infos about the environment ... 10 | unset name 11 | . /run/.containerenv 2>/dev/null 12 | 13 | # Don't show any info when ~/.hushlogin exists ... 14 | [[ -r ~/.hushlogin ]] && return 0 15 | 16 | echo "You left the ${name:-container} environment." 17 | return 0 18 | fi 19 | 20 | # Clear the console if it is a local terminal 21 | case `tty` in 22 | /dev/tty[0-9]*|/dev/ttyS[0-9]*) 23 | [[ -x /usr/bin/clear_console ]] \ 24 | && /usr/bin/clear_console --quiet \ 25 | || clear 26 | ;; 27 | *) 28 | # Don't show any info when ~/.hushlogin exists ... 29 | [[ -r ~/.hushlogin ]] && return 0 30 | 31 | echo "Bye, bye, $LOGNAME!" 32 | echo 33 | esac 34 | -------------------------------------------------------------------------------- /plugins/remind/remind.ax-io: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # remind.zshrc: Show reminders of remind(1). 3 | 4 | # Make sure that "remind(1)" is installed. 5 | (( $+commands[remind] )) || return 1 6 | 7 | # Don't run this plugin on "check-plugins"! 8 | [[ -z "$AXZSH_PLUGIN_CHECK" ]] || return 0 9 | 10 | # Some handy alias. 11 | alias remindcal='remind -ccu+3 -m -w$COLUMNS,4,0 $HOME/.remind' 12 | alias reminders='remind -h -g -t5 ~/.remind && echo' 13 | 14 | # Don't show reminders when ~/.hushlogin exists ... 15 | [[ -r ~/.hushlogin ]] && return 0 16 | 17 | # Is there a file with reminders? 18 | [[ -r ~/.remind ]] || return 0 19 | 20 | # Check if reminders have been shown during last 60 minutes, and if so, 21 | # don't show them now but return. 22 | [[ -z `find "$XDG_CACHE_HOME/axzsh_last_reminder" -mmin -60 2>/dev/null` ]] || return 0 23 | 24 | eval $(alias reminders|cut -d"'" -f2) 25 | 26 | # Write "stamp" file. 27 | [[ -w "$XDG_CACHE_HOME" ]] && touch "$XDG_CACHE_HOME/axzsh_last_reminder" 28 | -------------------------------------------------------------------------------- /core/01_zprofile/01_zprofile.zshrc: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # 01_zprofile.zshrc: Make sure zprofile files are read 3 | 4 | [[ -z "$AXZSH_ZPROFILE_READ" ]] || return 5 | 6 | # No "zprofile" (and "ax-io") stage files have been read in already, so looks 7 | # like this is a non-login shell instance but not a (direct) child of an AX-ZSH 8 | # enabled login shell! This can happen in graphical terminals not starting a 9 | # login shell, for example. So most probably some environment configuration is 10 | # missing and we have to make sure everything is set up properly by reading in 11 | # the "ax-io" and "zprofile" stages before continuing! 12 | [[ -n "$AXZSH_DEBUG" ]] && echo "» 01_zprofile.zshrc:" 13 | 14 | # Reset some environment variables, that could contain "garbage" ... 15 | unset PS1 16 | 17 | axzsh_handle_stage "01_zprofile.zshrc" "ax-io" 18 | axzsh_handle_stage "01_zprofile.zshrc" "zprofile" 19 | AXZSH_ZPROFILE_READ=2 20 | 21 | [[ -n "$AXZSH_DEBUG" ]] && echo "» 01_zprofile.zshrc (end)" 22 | -------------------------------------------------------------------------------- /plugins/powerline-shell/powerline-shell.zshrc: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # powerline-shell.zshrc: "powerline-shell" integration. 3 | 4 | axzsh_is_modern_terminal || return 91 5 | 6 | if [[ -z "$POWERLINE_SHELL" ]]; then 7 | for p ( 8 | "$HOME/powerline-shell.py" 9 | "$HOME/.powerline-shell.py" 10 | ); do 11 | [[ -r "$p" ]] || continue 12 | POWERLINE_SHELL="$p" 13 | break 14 | done 15 | unset p 16 | fi 17 | 18 | [[ -r "$POWERLINE_SHELL" ]] || return 1 19 | 20 | function powerline_precmd() { 21 | PS1="$( 22 | $POWERLINE_SHELL \ 23 | --shell zsh \ 24 | --mode ${POWERLINE_SHELL_MODE:-"compatible"} \ 25 | --colorize-hostname \ 26 | --cwd-mode ${POWERLINE_SHELL_CWD_MODE:-"fancy"} \ 27 | --cwd-max-depth ${POWERLINE_SHELL_CWD_DEPTH:-4} \ 28 | $? 2>/dev/null 29 | )" 30 | } 31 | 32 | # Make sure "powerline_precmd" isn't installed already 33 | for s in "${precmd_functions[@]}"; do 34 | [[ "$s" = "powerline_precmd" ]] && return 35 | done 36 | 37 | precmd_functions+=(powerline_precmd) 38 | -------------------------------------------------------------------------------- /plugins/virtualenv/virtualenv.zshrc: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # virtualenv: Activate an "virtual environment" 3 | 4 | # This plugin is optional. 5 | [[ -z "$AXZSH_PLUGIN_CHECK" ]] || return 92 6 | 7 | function activate() { 8 | local d r 9 | 10 | # Make sure no "virtual environment" is already active! 11 | if [[ -n "$VIRTUAL_ENV" ]]; then 12 | echo "Oops, looks like a virtual environment is already active!" >&2 13 | return 1 14 | fi 15 | 16 | if [[ -r Pipfile ]]; then 17 | pipenv run "$SHELL"; r=$? 18 | return $r 19 | fi 20 | for d ( 21 | ./bin 22 | ./env/bin 23 | ./venv/bin 24 | ./.venv/bin 25 | ); do 26 | script="$d/activate" 27 | test -r "$script" || continue 28 | 29 | # Read in activation script fragment ... 30 | source "$script" && return 0 31 | 32 | echo "Failed to read script \"$script\"!" >&2 33 | return 1 34 | done 35 | 36 | echo "No virtual environment found!" >&2 37 | return 1 38 | } 39 | 40 | if [[ -n "$PIPENV_ACTIVE" ]]; then 41 | alias deactivate=exit 42 | fi 43 | -------------------------------------------------------------------------------- /default_plugins/cheat/cheat.zshrc: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # cheat: Setup https://cht.sh 3 | 4 | if (( $+commands[fzf] )) && (( $+commands[curl] )); then 5 | # See 6 | function c() { 7 | url="https://cht.sh" 8 | term=$(curl -ks "$url/:list" | IFS=+ fzf --preview "curl -ks '$url/{}'" -q "$*") \ 9 | && curl -ks "$url/${term}" | ${PAGER:-less} 10 | } 11 | fi 12 | 13 | # Don't overwrite a real "cheat" command! 14 | (( $+commands[cheat] )) && return 15 | 16 | function cheat() { 17 | if (( $+commands[cht.sh] )); then 18 | if [[ $# -eq 0 ]]; then 19 | cht.sh --shell 20 | else 21 | cht.sh "$@" | ${PAGER:-less} 22 | fi 23 | return $? 24 | fi 25 | 26 | url="https://cht.sh/$@?style=monokai" 27 | 28 | if (( $+commands[curl] )); then 29 | curl -s "$url" | ${PAGER:-less} 30 | elif (( $+commands[wget] )); then 31 | wget -qO - "$url" | ${PAGER:-less} 32 | else 33 | echo "Neither cht.sh(1), curl(1) nor wget(1) found!" >&2 34 | return 1 35 | fi 36 | } 37 | -------------------------------------------------------------------------------- /themes/ax.axzshtheme: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # ax.axzshtheme: Default AX-ZSH Theme 3 | 4 | ZSH_THEME_TTY_PROMPT_PREFIX="%{$fg_no_bold[cyan]%}" 5 | ZSH_THEME_TTY_PROMPT_SUFFIX="%{$reset_color%}" 6 | 7 | ZSH_THEME_VCS_PROMPT_PREFIX_SPACING="(" 8 | 9 | ZSH_THEME_PROMPT_PREFIX_SPACING=" " 10 | ZSH_THEME_PROMPT_PREFIX="%{$fg_bold[green]%}" 11 | ZSH_THEME_PROMPT_ROOT_PREFIX="%{$fg_bold[red]%}" 12 | ZSH_THEME_PROMPT_SUFFIX="%b%{$reset_color%}" 13 | ZSH_THEME_PROMPT_SUFFIX_SPACING=" " 14 | 15 | axzsh_logname_prompt_functions=($axzsh_logname_prompt_functions axzsh_logname_prompt_root) 16 | axzsh_hostname_prompt_functions=($axzsh_hostname_prompt_functions axzsh_hostname_prompt_root) 17 | 18 | # The primary prompt string, printed before a command is read. 19 | PS1="$(axzsh_tty_prompt_yn)$(axzsh_logname_prompt_yn)$(axzsh_hostname_prompt_yn)%B%2~%b"'$(axzsh_vcs_prompt)'"$(axzsh_prompt)" 20 | 21 | # Primary prompt on the right-hand side. 22 | axzsh_is_utf_terminal \ 23 | && RPS1="%(?..%{$fg_no_bold[red]%}%? ↵%{$reset_color%})" \ 24 | || RPS1="%(?..%{$fg_no_bold[red]%}<%?>%{$reset_color%})" 25 | 26 | -------------------------------------------------------------------------------- /plugins/calendar/calendar.ax-io: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # calendar.ax-io: Show calendar(1) entries for the current day. 3 | 4 | # Make sure that "calendar(1)" is installed. 5 | (( $+commands[calendar] )) || return 1 6 | 7 | # Don't run this plugin on "check-plugins", but test if it would work! 8 | # It fails when no calendar files are available, for example, on macOS ... 9 | if [[ -n "$AXZSH_PLUGIN_CHECK" ]]; then 10 | calendar >/dev/null 2>&1 || return 1 11 | return 0 12 | fi 13 | 14 | # Don't show any info when ~/.hushlogin exists ... 15 | [[ -r ~/.hushlogin ]] && return 0 16 | 17 | # Check if calendar(1) infos have been shown during last 60 minutes, and if so, 18 | # don't show them now but return. 19 | [[ -z `find "$XDG_CACHE_HOME/axzsh_last_calendar" -mmin -60 2>/dev/null` ]] || return 0 20 | 21 | tmpfile=$(mktemp "$TMPDIR/calendar.XXXXXX") || return 1 22 | 23 | calendar -A0 >"$tmpfile" 24 | if [[ -s "$tmpfile" ]]; then 25 | cat "$tmpfile"; echo 26 | fi 27 | rm -f "$tmpfile" 28 | 29 | # Wtite "stamp" file. 30 | [[ -w "$XDG_CACHE_HOME" ]] && touch "$XDG_CACHE_HOME/axzsh_last_calendar" 31 | -------------------------------------------------------------------------------- /plugins/browser_select/browser_select.zprofile: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # browser_select.zprofile: Setup $BROWSER for the "best" available WWW browser 3 | 4 | # Don't run this plugin on "check-plugins"! 5 | [[ -z "$AXZSH_PLUGIN_CHECK" ]] || return 92 6 | 7 | if [[ -z "$BROWSER" ]]; then 8 | if [[ "$OSTYPE" != "linux-gnu" ]]; then 9 | # Check for open(1) on Non-Linux systems. On (Debian-) Linux, the open(1) 10 | # command would recursively call $BROWSER (=itself) ... 11 | open_browsers="open" 12 | fi 13 | if [[ -n "$DISPLAY" ]]; then 14 | # X11 available, consider X11-based browsers, too! 15 | x11_browsers=(firefox chrome) 16 | fi 17 | 18 | # Note: We can't use xdg-open(1) here, as xdg-open itself tries to use 19 | # $BROWSER, and this would result in an endless loop! 20 | for browser ( 21 | $open_browsers 22 | $x11_browsers 23 | elinks w3m links2 links lynx 24 | ); do 25 | if [[ -n "$commands[$browser]" ]]; then 26 | BROWSER="$commands[$browser]" 27 | break 28 | fi 29 | done 30 | unset browser open_browser x11_browsers 31 | fi 32 | 33 | [[ -n "$BROWSER" ]] && export BROWSER 34 | -------------------------------------------------------------------------------- /default_plugins/std_aliases/std_aliases.zshrc: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # std_aliases: Setup standard aliases 3 | 4 | alias ll="ls -hl" 5 | alias l="ls -ahl" 6 | alias la="ls -Ahl" 7 | alias lx="ls -A" 8 | 9 | alias lasth='last -aw | head -n "$((LINES-1))"' 10 | alias lastf='last -aw | grep -v "^$LOGNAME"' 11 | 12 | alias d='dirs -v | head -10' 13 | alias 1='cd ~1 && pwd' 14 | alias 2='cd ~2 && pwd' 15 | alias 3='cd ~3 && pwd' 16 | alias 4='cd ~4 && pwd' 17 | alias 5='cd ~5 && pwd' 18 | alias 6='cd ~6 && pwd' 19 | alias 7='cd ~7 && pwd' 20 | alias 8='cd ~8 && pwd' 21 | alias 9='cd ~9 && pwd' 22 | alias -- -='cd -' 23 | 24 | alias md='mkdir -p' 25 | alias rd=rmdir 26 | 27 | # Global aliases 28 | 29 | alias -g C="| cut -d' '" 30 | alias -g G="| grep -i" 31 | alias -g H="| head" 32 | alias -g L="| less" 33 | alias -g LL="2>&1 | less" 34 | alias -g NUL=">/dev/null 2>&1" 35 | alias -g 1NUL="1>/dev/null" 36 | alias -g 2NUL="2>/dev/null" 37 | alias -g T="| tail" 38 | alias -g WL="| wc -l" 39 | alias -g X="| xargs" 40 | 41 | # Suffix aliases 42 | 43 | alias -s {c,cfg,conf,css,h,html,ini,json,md,me,rc,txt,yml,yaml}="$EDITOR" 44 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License 2 | =============== 3 | 4 | - Copyright (c) 2015-2025 Alexander Barton 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /core/30_path/30_path.ax-io: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # 30_path.ax-io: Setup PATH environment 3 | 4 | # Set default PATH 5 | if [[ -x /usr/libexec/path_helper ]]; then 6 | eval "$(/usr/libexec/path_helper)" 7 | else 8 | path=() 9 | [[ $UID -eq 0 ]] && path+=(/usr/sbin) 10 | path+=(/usr/bin) 11 | [[ ! -h /sbin && $UID -eq 0 ]] && path+=(/sbin) 12 | [[ ! -h /bin ]] && path+=(/bin) 13 | fi 14 | typeset -Ux PATH 15 | 16 | _axzsh_setup_path() { 17 | # Prepend additional search paths 18 | for d ( 19 | /Developer/usr/bin 20 | /usr/ucb 21 | /usr/pkg/bin 22 | /usr/local/bin 23 | /usr/local/sbin 24 | /opt/*/bin(NOn) 25 | /opt/*/sbin(NOn) 26 | /home/linuxbrew/.linuxbrew/bin 27 | ~/.gem/ruby/*/bin(NOn) 28 | ~/.go/bin 29 | ~/.cargo/bin 30 | ~/.local/bin 31 | ~/bin 32 | ~/sbin 33 | ~/Applications 34 | ); do 35 | [[ "$d" = */sbin && $UID -ne 0 ]] && continue 36 | [[ -d "$d" ]] && path=("$d" $path) 37 | done 38 | 39 | # Append additional search paths 40 | for d ( 41 | /usr/X11/bin 42 | /usr/local/games 43 | /usr/games 44 | ); do 45 | [[ -d "$d" ]] && path=($path "$d") 46 | done 47 | } 48 | 49 | # Prepend and append search paths (in a special order!) 50 | _axzsh_setup_path 51 | -------------------------------------------------------------------------------- /plugins/spectrum/spectrum.zshrc: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # spectrum.zshrc: Helper functions showing the available "color spectrum". 3 | 4 | # This plugin is optional. 5 | [[ -z "$AXZSH_PLUGIN_CHECK" ]] || return 92 6 | 7 | ZSH_SPECTRUM_TEXT=${ZSH_SPECTRUM_TEXT:-The quick brown fox jumps over the lazy dog} 8 | 9 | # Show all 256 foreground colors with color number 10 | function spectrum_ls() { 11 | test "$TERM_COLORS" -gt 0 || return 1 12 | for code in {000..$((TERM_COLORS-1))}; do 13 | print -P -- "$code: $FG[$code]$ZSH_SPECTRUM_TEXT$FX[reset]" 14 | done 15 | } 16 | 17 | # Show all 256 background colors with color number 18 | function spectrum_bls() { 19 | test "$TERM_COLORS" -gt 0 || return 1 20 | for code in {000..$((TERM_COLORS-1))}; do 21 | print -P -- "$code: $BG[$code]$ZSH_SPECTRUM_TEXT$FX[reset]" 22 | done 23 | } 24 | 25 | # NOTE for FG, BG and FX arrays, and spectrum_ls() and spectrum_bls() functions: 26 | # Based on a script to make using 256 colors in zsh less painful, written by 27 | # P.C. Shyamshankar . 28 | # Copied from OhMyZsh https://github.com/robbyrussell/oh-my-zsh/blob/master/lib/spectrum.zsh 29 | # which was copied from https://github.com/sykora/etc/blob/master/zsh/functions/spectrum/ :-) 30 | -------------------------------------------------------------------------------- /plugins/ssh_secure/README.md: -------------------------------------------------------------------------------- 1 | ## ssh_secure 2 | 3 | Make `ssh`(1) more secure by adding command aliases. 4 | 5 | ### Usage 6 | 7 | Make sure to enable *"strict hostkey checking"* for `ssh`, add something like 8 | the following to you `~/.ssh/config` file to make `ssh` more secure by default: 9 | 10 | # Trusted test network with changing hosts 11 | Host *.example.net 12 | StrictHostKeyChecking no 13 | UserKnownHostsFile /dev/null 14 | 15 | # Be more secure by default! 16 | Host * 17 | CheckHostIP yes 18 | StrictHostKeyChecking yes 19 | 20 | Now you can use the following commands (see aliases below): 21 | 22 | - `ssh`: establish a new SSH connection to *known* hosts. 23 | - `sshtmp`: establish a *temporary* SSH connection to an *unknown* host. 24 | - `sshnew`: establish a SSH connection to an *unknown* host and add it to 25 | the "known hosts" list. 26 | 27 | 28 | ### Command Aliases 29 | 30 | - `sshnew`: Don't use "strict host key checking", which allows adding new and 31 | unknown hosts. 32 | - `sshtmp`: Don't use "strict host key checking" and don't use the "known 33 | hosts" list at all, which allows to temporarily `ssh` to an unknown host 34 | without the need to alter the *UserKnownHostsFile* at all. 35 | -------------------------------------------------------------------------------- /default_plugins/std_functions/std_functions.zshrc: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # std_functions: Setup standard ("common") functions 3 | 4 | function open_command() { 5 | case $OSTYPE in 6 | darwin*) 7 | open "$@" || return 1 8 | ;; 9 | cygwin*) 10 | cygstart "$@" || return 1 11 | ;; 12 | linux*) 13 | if [[ -n "$DISPLAY" ]]; then 14 | # X11 15 | nohup xdg-open "$@" &>/dev/null || return 1 16 | else 17 | xdg-open "$@" || return 1 18 | fi 19 | ;; 20 | *) 21 | return 2 22 | esac 23 | return 0 24 | } 25 | 26 | function take() { 27 | if [[ $# -eq 0 ]]; then 28 | cd "$(mktemp -d "${TMPDIR}/tmp.XXXXXXXX")" || return 1 29 | pwd 30 | else 31 | mkdir -p "$@" && cd "${@:$#}" || return 1 32 | fi 33 | } 34 | 35 | function untake() { 36 | subdir="${PWD##$TMPDIR}" 37 | if [[ "${PWD%tmp.*}" = "${TMPDIR}" && -n "$subdir" ]]; then 38 | tmp_d="${TMPDIR}${subdir%%/*}" 39 | echo "$tmp_d" 40 | cd || return 1 41 | rm -fr "$@" "${tmp_d}" 42 | else 43 | echo 'Sorry, not a temporarily taken directory!' >&2 44 | return 1 45 | fi 46 | } 47 | 48 | function zsh_stats() { 49 | fc -l 1 \ 50 | | awk '{CMD[$2]++;count++;}END { for (a in CMD)print CMD[a] " " CMD[a]/count*100 "% " a;}' \ 51 | | grep -v "./" | column -c3 -s " " -t | sort -nr | nl -w 3 -s ": " | head -n20 52 | } 53 | -------------------------------------------------------------------------------- /plugins/fzf/fzf.zshrc: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # fzf.zshrc: Setup Git 3 | 4 | axzsh_is_dumb_terminal && return 91 5 | 6 | # Test for local fzf installation ... 7 | if [[ -r ~/.fzf.zsh ]]; then 8 | source ~/.fzf.zsh 9 | return 0 10 | fi 11 | 12 | # Make sure that "fzf(1)" is installed 13 | (( $+commands[fzf] )) || return 1 14 | 15 | alias -g F="| fzf" 16 | 17 | # Test for Debian-specific keybinding location ... 18 | if [[ -r /usr/share/doc/fzf/examples/key-bindings.zsh ]]; then 19 | if [[ -r /usr/share/doc/fzf/examples/completion.zsh ]]; then 20 | source /usr/share/doc/fzf/examples/completion.zsh 21 | elif [[ -r /usr/share/zsh/vendor-completions/_fzf ]]; then 22 | source /usr/share/zsh/vendor-completions/_fzf 23 | fi 24 | source /usr/share/doc/fzf/examples/key-bindings.zsh 25 | return 0 26 | fi 27 | 28 | # Search for and read in FZF ZSH integration files 29 | for dir ( 30 | "$HOMEBREW_PREFIX"/opt/fzf/shell 31 | /usr/local/lib/fzf/shell 32 | /usr/local/opt/fzf/shell 33 | /usr/local/share/examples/fzf/shell 34 | /opt/fzf/shell 35 | /usr/share/fzf 36 | /usr/share/fzf/shell 37 | /usr/pkg/share/fzf/shell 38 | ); do 39 | [[ -r "$dir/key-bindings.zsh" ]] || continue 40 | [[ -r "$dir/completion.zsh" ]] && source "$dir/completion.zsh" 41 | source "$dir/key-bindings.zsh" 42 | return 0 43 | done 44 | return 1 45 | -------------------------------------------------------------------------------- /plugins/git/README.md: -------------------------------------------------------------------------------- 1 | ## git 2 | 3 | Enable ZSH *Git* integration: 4 | 5 | 1. Enhance shell prompt inside *Git* trees. 6 | 2. Define some aliases. 7 | 8 | ### Command Aliases 9 | 10 | - `fix`: `git diff --name-only | uniq | xargs $EDITOR` 11 | - `g`: `git` 12 | - `ga`: `git add` 13 | - `gapa`: `git add --patch` 14 | - `gc`: `git commit --verbose` 15 | - `gc!`: `git commit --verbose --amend` 16 | - `gca`: `git commit --verbose --all` 17 | - `gcam`: `git commit --verbose --all --message` 18 | - `gcmsg`: `git commit --verbose --message` 19 | - `gcn`: `git commit --verbose --no-edit` 20 | - `gcn!`: `git commit --verbose --no-edit --amend` 21 | - `gco`: `git checkout` 22 | - `gd`: `git diff` 23 | - `gdca`: `git diff --cached` 24 | - `gdcw`: `git diff --cached --word-diff` 25 | - `gdw`: `git diff --word-diff` 26 | - `gf`: `git fetch` 27 | - `gfa`: `git fetch --all --prune` 28 | - `gfo`: `git fetch origin` 29 | - `gl`: `git pull` 30 | - `glo`: `git log --oneline --decorate` 31 | - `gloo`: `git log --oneline --decorate ORIG_HEAD..` 32 | - `gp`: `git push` 33 | - `gr`: `git remote` 34 | - `grb`: `git rebase` 35 | - `grbi`: `git rebase --interactive` 36 | - `gsb`: `git status --short --branch` 37 | - `gsh`: `git show` 38 | - `gss`: `git status --short` 39 | - `gst`: `git status` 40 | - `gsta`: `git stash push` 41 | - `gstl`: `git stash list` 42 | - `gstp`: `git stash pop` 43 | -------------------------------------------------------------------------------- /core/99_cleanup/99_cleanup.zlogin: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # 99_cleanup.zlogin: Don't pollute the namespace, remove variables/functions/... 3 | 4 | for func ( 5 | axzsh_hostname_prompt_root 6 | axzsh_hostname_prompt_yn 7 | axzsh_logname_prompt_root 8 | axzsh_logname_prompt_yn 9 | axzsh_prompt 10 | ); do 11 | unfunction $func 2>/dev/null 12 | done 13 | 14 | for func ($axzsh_logname_prompt_functions); do 15 | unfunction $func 2>/dev/null 16 | done 17 | unset axzsh_logname_prompt_functions 18 | 19 | for func ($axzsh_hostname_prompt_functions); do 20 | unfunction $func 2>/dev/null 21 | done 22 | unset axzsh_hostname_prompt_functions 23 | 24 | # Try to map OhMyZsh theme Environment ... 25 | [[ -n "$ZSH_THEME_GIT_PROMPT_AHEAD" ]] \ 26 | && ZSH_THEME_VCS_PROMPT_AHEAD="$ZSH_THEME_GIT_PROMPT_AHEAD" 27 | [[ -n "$ZSH_THEME_GIT_PROMPT_CLEAN" ]] \ 28 | && ZSH_THEME_VCS_PROMPT_CLEAN="$ZSH_THEME_GIT_PROMPT_CLEAN" 29 | [[ -n "$ZSH_THEME_GIT_PROMPT_DIRTY" ]] \ 30 | && ZSH_THEME_VCS_PROMPT_DIRTY="$ZSH_THEME_GIT_PROMPT_DIRTY" 31 | [[ -n "$ZSH_THEME_GIT_PROMPT_PREFIX" ]] \ 32 | && ZSH_THEME_VCS_PROMPT_PREFIX="$ZSH_THEME_GIT_PROMPT_PREFIX" 33 | [[ -n "$ZSH_THEME_GIT_PROMPT_SUFFIX" ]] \ 34 | && ZSH_THEME_VCS_PROMPT_SUFFIX="$ZSH_THEME_GIT_PROMPT_SUFFIX" 35 | [[ -n "$ZSH_THEME_GIT_PROMPT_UNMERGED" ]] \ 36 | && ZSH_THEME_VCS_PROMPT_BEHIND="$ZSH_THEME_GIT_PROMPT_UNMERGED" 37 | -------------------------------------------------------------------------------- /plugins/editor_select/editor_select.zprofile: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # editor_select.zprofile: Setup $EDITOR for the "best" available editor 3 | 4 | if [[ -n "$EDITOR" && ! -x "$EDITOR" && -z "$commands[$EDITOR]" ]]; then 5 | # Oops, current $EDITOR seems to be invalid! Start over! 6 | unset EDITOR 7 | fi 8 | 9 | # Check user preferences first! 10 | if [[ -r ~/.selected_editor ]]; then 11 | . ~/.selected_editor 12 | if [[ -x "$SELECTED_EDITOR" || -n "$commands[$SELECTED_EDITOR]" ]]; then 13 | EDITOR="$SELECTED_EDITOR" 14 | fi 15 | unset SELECTED_EDITOR 16 | fi 17 | 18 | if [[ -z "$EDITOR" ]]; then 19 | # Auto-detect a "good" editor ... 20 | if [[ -n "$DISPLAY" ]]; then 21 | # X11 available, consider X11-based editors, too! 22 | x11_editors="mousepad gvim vim.motif" 23 | fi 24 | 25 | for editor ( 26 | sensible-editor editor 27 | code atom mate subl mvim 28 | $x11_editors 29 | vim.nox vim.basic micro joe mcedit nano vim vim.tiny nvi vi 30 | ); do 31 | if [[ -n "$commands[$editor]" ]]; then 32 | EDITOR="$commands[$editor]" 33 | break 34 | fi 35 | done 36 | unset editor x11_editors 37 | fi 38 | 39 | case "$EDITOR:t" in 40 | "code"|"atom"|"mate"|"subl") 41 | EDITOR="$EDITOR --wait" 42 | ;; 43 | "mvim"|"gvim"|"vim.motif") 44 | EDITOR="$EDITOR --nofork" 45 | ;; 46 | esac 47 | 48 | [[ -n "$EDITOR" ]] && export EDITOR 49 | -------------------------------------------------------------------------------- /plugins/ssh_autoadd/ssh_autoadd.ax-io: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # ssh_autoadd.zshrc: Make sure that SSH keys are available 3 | 4 | # Make sure that "ssh(1)" is installed. 5 | (( $+commands[ssh] )) || return 1 6 | 7 | # This plugin is optional. 8 | [[ -z "$AXZSH_PLUGIN_CHECK" ]] || return 92 9 | 10 | # Make sure that an SSH agent is available (but ignore failure): 11 | [[ -n "$SSH_AUTH_SOCK" ]] || return 0 12 | 13 | # Check if the agent already has keys, and return if this is already the case 14 | # and nothing is to to. 15 | ssh-add -l >/dev/null 2>&1 && return 0 16 | 17 | # Apple macOS: 18 | # Try to add keys with passwords stored in the macOS "keychain" ... 19 | 20 | if [[ "$OSTYPE" =~ '^darwin' ]]; then 21 | # Try to load SSH keys using passwords stored in the "keychain", but 22 | # ignore all errors. And return if at least one identity was added: 23 | LC_ALL=C APPLE_SSH_ADD_BEHAVIOR=macos ssh-add -A 2>&1 \ 24 | | grep -Fq 'Identity added: ' && return 0 25 | fi 26 | 27 | # Generic: 28 | # Try to load keys ... 29 | 30 | # Make sure we have a terminal connected, DISPLAY is set or SSH_ASKPASS is set: 31 | [[ -t 1 || -n "$DISPLAY" || -n "$SSH_ASKPASS" ]] || return 0 32 | 33 | # Note: we can't use the "ssh-autoadd" function here, because this script runs 34 | # in the AX-IO stage and that function was not sourced yet! 35 | echo "A SSH agent is available but has no identities!" 36 | ssh-add 37 | echo 38 | -------------------------------------------------------------------------------- /plugins/icalbuddy/icalbuddy.ax-io: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # icalbuddy.zshrc: Show reminders using icalBuddy(1). 3 | 4 | # Make sure that "icalBuddy(1)" is installed. 5 | (( $+commands[icalBuddy] )) || return 1 6 | 7 | # Don't run this plugin on "check-plugins"! 8 | [[ -z "$AXZSH_PLUGIN_CHECK" ]] || return 0 9 | 10 | function reminders() { 11 | tmpfile=$(mktemp "$TMPDIR/icalbuddy.XXXXXX") || return 1 12 | 13 | if [[ "$LANG" =~ "\.UTF" ]]; then 14 | bul="•"; bul_imp="!"; sep="»" 15 | else 16 | bul="*"; bul_imp="!"; sep=">" 17 | fi 18 | 19 | # Show reminders now. 20 | icalBuddy -f -n -b " $bul " -ab " $bul_imp " -ps "/ $sep /" \ 21 | -nc -npn -iep "title,due" -stda \ 22 | tasksDueBefore:tomorrow 2>/dev/null >>"$tmpfile" 23 | icalBuddy -f -n -b " $bul " -ab " $bul_imp " -ps "/ $sep /" \ 24 | -nc -npn -iep "title,datetime" \ 25 | eventsToday+1 2>/dev/null >>"$tmpfile" 26 | 27 | if [[ -s "$tmpfile" ]]; then 28 | cat "$tmpfile"; echo 29 | fi 30 | 31 | rm -f "$tmpfile" 32 | unset bul bul_imp sep tmpfile 33 | } 34 | 35 | # Don't show reminders when ~/.hushlogin exists ... 36 | [[ -r ~/.hushlogin ]] && return 0 37 | 38 | # Check if reminders have been shown during last 60 minutes, and if so, 39 | # don't show them now but return. 40 | [[ -z `find "$XDG_CACHE_HOME/axzsh_last_reminder" -mmin -60 2>/dev/null` ]] || return 0 41 | 42 | reminders 43 | 44 | # Write "stamp" file. 45 | [[ -w "$XDG_CACHE_HOME" ]] && touch "$XDG_CACHE_HOME/axzsh_last_reminder" 46 | -------------------------------------------------------------------------------- /plugins/zkbd/zkbd.zshrc: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # zkbd.zshrc: Initialize ZKBD Keybindings 3 | 4 | [[ -z "$AXZSH_PLUGIN_CHECK" ]] || return 92 5 | 6 | autoload -Uz zkbd 7 | 8 | # Try to load in existing settings: 9 | if [[ -r ${ZDOTDIR:-$HOME}/.zkbd/$TERM-${${DISPLAY:t}:-$VENDOR-$OSTYPE} ]]; then 10 | . ${ZDOTDIR:-$HOME}/.zkbd/$TERM-${${DISPLAY:t}:-$VENDOR-$OSTYPE} 11 | fi 12 | 13 | [[ -n "${key[Backspace]}" ]] && bindkey "${key[Backspace]}" backward-delete-char 14 | [[ -n "${key[Delete]}" ]] && bindkey "${key[Delete]}" delete-char 15 | [[ -n "${key[Insert]}" ]] && bindkey "${key[Insert]}" overwrite-mode 16 | 17 | [[ -n "${key[Home]}" ]] && bindkey "${key[Home]}" beginning-of-line 18 | [[ -n "${key[End]}" ]] && bindkey "${key[End]}" end-of-line 19 | 20 | [[ -n "${key[PageUp]}" ]] && bindkey "${key[PageUp]}" up-line-or-history 21 | [[ -n "${key[PageDown]}" ]] && bindkey "${key[PageDown]}" down-line-or-history 22 | 23 | [[ -n "${key[Up]}" ]] && bindkey "${key[Up]}" up-line-or-search 24 | [[ -n "${key[Down]}" ]] && bindkey "${key[Down]}" down-line-or-search 25 | [[ -n "${key[Left]}" ]] && bindkey "${key[Left]}" backward-char 26 | [[ -n "${key[Right]}" ]] && bindkey "${key[Right]}" forward-char 27 | 28 | [[ -n "${key[C-Up]}" ]] && bindkey "${key[C-Up]}" history-beginning-search-backward 29 | [[ -n "${key[C-Down]}" ]] && bindkey "${key[C-Down]}" history-beginning-search-forward 30 | [[ -n "${key[C-Left]}" ]] && bindkey "${key[C-Left]}" backward-word 31 | [[ -n "${key[C-Right]}" ]] && bindkey "${key[C-Right]}" forward-word 32 | -------------------------------------------------------------------------------- /core/90_theme/90_theme.zshrc: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # 90_theme.zshrc: Load AX-ZSH theme 3 | 4 | # Don't load any "enhanced" theme on dumb terminals, but instead use a very 5 | # simple and sane built-in prompt that should work "everywhere". And try to 6 | # make sure that nothing else "disturbs" such terminals ... 7 | if ! axzsh_is_modern_terminal; then 8 | if axzsh_is_dumb_terminal; then 9 | # Don't use any theme on dumb terminals! 10 | unset AXZSH_THEME 11 | 12 | # Set simple prompt: 13 | PS1="%n@%m:%3~ %# " 14 | unset RPS1 15 | else 16 | # Use the default theme on legacy ("not modern") terminals: 17 | AXZSH_THEME="$AXZSH/themes/ax.axzshtheme" 18 | fi 19 | 20 | # See 21 | unset zle_bracketed_paste 22 | fi 23 | 24 | # Default secondary, select and execution trace prompts. Note: Can become 25 | # overwritten by the theme later on. 26 | PS2="%_$fg_no_bold[yellow]»$reset_color " 27 | PS3="$fg_no_bold[yellow]?$reset_color " 28 | PS4="$fg_no_bold[yellow]->$reset_color " 29 | 30 | # The PS3 and PS4 prompts are compatible with sh(1) and bash(1), too, and 31 | # "unlikely" to get overwritten by themes. So let's export them to be useful 32 | # in sub-shells as well! 33 | # NOTE: PS1 is set by themes, and PS2 is set to a ZSH-specific setting here in 34 | # this file. So we DO NOT export those! 35 | export PS3 PS4 36 | 37 | # NOTE: The theme itself is read in by the ax.zsh script itself: last and into 38 | # the global context (code for the cache file is generated as required). 39 | -------------------------------------------------------------------------------- /plugins/vi-mode/vi-mode.zshrc: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # vi-mode.zshrc: Setup "VI mode" in ZSH 3 | 4 | # This plugin is optional. 5 | [[ -z "$AXZSH_PLUGIN_CHECK" ]] || return 92 6 | 7 | bindkey -v 8 | export KEYTIMEOUT=25 9 | 10 | # All modes 11 | 12 | function _bindkey_all { 13 | for mode (viins vicmd); do 14 | bindkey -M ${mode} "$@" 15 | done 16 | } 17 | 18 | _bindkey_all '^[[H' beginning-of-line # POS1 19 | _bindkey_all '^[[F' end-of-line # END 20 | _bindkey_all '^[[3~' delete-char # DEL 21 | 22 | unfunction _bindkey_all 23 | 24 | # Insert mode 25 | 26 | bindkey -M viins '^A' beginning-of-line 27 | bindkey -M viins '^E' end-of-line 28 | 29 | bindkey -M viins '^U' backward-kill-line 30 | bindkey -M viins '^K' kill-line 31 | 32 | bindkey -M viins '^[.' insert-last-word 33 | 34 | # Normal mode (command mode) 35 | 36 | bindkey -M vicmd 'j' history-search-forward 37 | bindkey -M vicmd 'k' history-search-backward 38 | 39 | # VI Mode Environment 40 | 41 | # Change cursor shape for different vi modes. 42 | function zle-line-init zle-keymap-select { 43 | case "${KEYMAP}" in 44 | 'main' | 'viins') 45 | # Use '|' style cursor in main and insert mode: 46 | echo -ne '\e[5 q' 47 | ;; 48 | *) 49 | # Use the default (block) cursor otherwise ... 50 | echo -ne '\e[1 q' 51 | ;; 52 | esac 53 | } 54 | zle -N zle-keymap-select 55 | zle -N zle-line-init 56 | 57 | # Reset the cursor to the default (block) mode before calling commands. 58 | function __vi_mode_cursor_block { 59 | echo -ne '\e[1 q' 60 | } 61 | preexec_functions+=(__vi_mode_cursor_block) 62 | -------------------------------------------------------------------------------- /themes/axemoji.axzshtheme: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # axemoji.axzshtheme: Fancier AX-ZSH Theme 3 | 4 | ZSH_THEME_TTY_PROMPT_PREFIX="%{$fg_no_bold[cyan]%}" 5 | ZSH_THEME_TTY_PROMPT_SUFFIX="%{$reset_color%}" 6 | 7 | ZSH_THEME_PROMPT_PREFIX_SPACING=" " 8 | ZSH_THEME_PROMPT_SUFFIX_SPACING=" " 9 | 10 | if axzsh_is_utf_terminal; then 11 | # UTF8 capable terminal: 12 | if [[ -r "$HOME/.system_emoji-$SHORT_HOST" ]]; then 13 | system_emoji=$(<"$HOME/.system_emoji-$SHORT_HOST") 14 | elif [[ -r "$HOME/.system_emoji" ]]; then 15 | system_emoji=$(<"$HOME/.system_emoji") 16 | else 17 | system_emoji="🍀" 18 | fi 19 | axzsh_is_widechar_terminal \ 20 | && emoji_spacing="" \ 21 | || emoji_spacing=" " 22 | 23 | ZSH_THEME_VCS_PROMPT_CLEAN="👌$emoji_spacing" 24 | ZSH_THEME_VCS_PROMPT_DIRTY="👻$emoji_spacing" 25 | 26 | # Primary prompt on the right-hand side. 27 | RPS1="%(?..%{$fg_no_bold[red]%}🤔$emoji_spacing %?↵%{$reset_color%})" 28 | else 29 | # Non-UTF8 or incompatible terminal 30 | system_emoji=">" 31 | emoji_spacing="" 32 | 33 | # Primary prompt on the right-hand side. 34 | RPS1="%(?..%{$fg_no_bold[red]%}<%?>%{$reset_color%})" 35 | fi 36 | 37 | axzsh_logname_prompt_functions=($axzsh_logname_prompt_functions axzsh_logname_prompt_root) 38 | axzsh_hostname_prompt_functions=($axzsh_hostname_prompt_functions axzsh_hostname_prompt_root) 39 | 40 | # The primary prompt string, printed before a command is read. 41 | PS1="${system_emoji}${emoji_spacing} $(axzsh_tty_prompt_yn)$(axzsh_logname_prompt_yn)$(axzsh_hostname_prompt_yn)%B%2~%b"'$(axzsh_vcs_prompt)'"$(axzsh_prompt)" 42 | 43 | unset system_emoji emoji_spacing 44 | -------------------------------------------------------------------------------- /plugins/homebrew/homebrew.zprofile: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # homebrew.zprofile -- Setup Homebrew Package Manager 3 | 4 | # Look for the "brew(1) command ... 5 | for brew_cmd ( 6 | /home/linuxbrew/.linuxbrew/bin/brew 7 | /opt/homebrew/bin/brew 8 | /usr/local/bin/brew 9 | ); do 10 | [[ -x "$brew_cmd" ]] && break 11 | done 12 | if [[ ! -x "$brew_cmd" ]]; then 13 | unset brew_cmd 14 | return 1 15 | fi 16 | 17 | # Update the environment for Homebrew by evaluating "brew shellenv". 18 | # NOTE: As of 2024-11-26, the brew command (e.g. /opt/homebrew/bin/brew) calls 19 | # "sudo --reset-timestamp" which is, in theory, a very good idea but results in 20 | # long delays if your machine is, for example, linked to Active Directory and 21 | # your domain controller is not available or slow (not sure why sudo(1) actually 22 | # checks any user credentials for _forgetting_ the usage time, but that's how it 23 | # seems to be). Anyway. This can lead to annoying delays spawning new sessions, 24 | # so use a "cache file" to speed this up. 25 | _shellenv_cache="$XDG_CACHE_HOME/axzsh_homebrew_shellenv" 26 | find "$_shellenv_cache" -mmin +1440 -delete 2>/dev/null 27 | if [[ ! -r "$_shellenv_cache" ]]; then 28 | # Create new cache file: 29 | [[ -n "$AXZSH_DEBUG" ]] && echo ' - (creating new "shellenv cache")' 30 | "$brew_cmd" shellenv >"$_shellenv_cache" 31 | fi 32 | . "$_shellenv_cache" 33 | unset _shellenv_cache 34 | 35 | for dir ( 36 | "$HOMEBREW_PREFIX/share/zsh-completions" 37 | "$HOMEBREW_PREFIX/share/zsh/site-functions" 38 | ); do 39 | [[ -d "$dir" ]] && axzsh_fpath+=("$dir") 40 | done 41 | unset dir brew_cmd 42 | 43 | return 0 44 | -------------------------------------------------------------------------------- /core/40_axzsh/functions/_axzsh: -------------------------------------------------------------------------------- 1 | #compdef axzshctl 2 | 3 | _axzshctl() { 4 | _arguments \ 5 | '1: :(( 6 | enable\:"Enable AX-ZSH." 7 | disable\:"Disable AX-ZSH." 8 | enable-plugin\:"Enable plugin(s)." 9 | disable-plugin\:"Disable plugin(s)." 10 | list-enabled\:"List enabled plugin(s)." 11 | plugin-help\:"Show help text for a plugin." 12 | reset-plugins\:"Reset active plugins to the default set." 13 | enable-default-plugins\:"Enable all default plugins." 14 | check-plugins\:"Check \"useful\" plugins." 15 | set-theme\:"Set active theme." 16 | upgrade\:"Upgrade AX-ZSH installation (requires Git)." 17 | update-caches\:"Force rebuild of all cache files." 18 | version\:"Show version and setup information." 19 | help\:"Show help for the axzshctl command." 20 | ))' \ 21 | '*: :->args' 22 | # 23 | case "$state" in 24 | 'args') 25 | case "$words[2]" in 26 | "enable-plugin"|"plugin-help") 27 | compadd "$@" -- \ 28 | "$AXZSH"/plugins/*(/:t) \ 29 | "$AXZSH"/custom_plugins/*(N/:t) \ 30 | "$AXZSH"/repos/*(/:t:s/#/\\/) 31 | for r in "$AXZSH"/repos/@*(N/); do 32 | b=(echo $r(:t)) 33 | compadd "$@" -- \ 34 | $(echo $r/plugins/*(N:t) | sed -E "s/(^| )/ $b\//g") 35 | done 36 | ;; 37 | "disable-plugin") 38 | compadd "$@" -- \ 39 | "$AXZSH"/active_plugins/*(:t:s/#/\\/) 40 | ;; 41 | "set-theme") 42 | compadd "$@" -- "-" \ 43 | "$AXZSH"/themes/*.axzshtheme(:r:t) \ 44 | "$AXZSH"/custom_themes/*.axzshtheme(N:r:t) \ 45 | "$AXZSH"/custom_themes/*.zsh-theme(N:r:t) \ 46 | "$AXZSH"/repos/*/*.axzshtheme(N:r:t) \ 47 | "$AXZSH"/repos/*/*.zsh-theme(N:r:t) 48 | ;; 49 | esac 50 | ;; 51 | esac 52 | } 53 | 54 | _axzshctl "$@" 55 | -------------------------------------------------------------------------------- /plugins/jujutsu/jujutsu.zshrc: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # jujutsu.zshrc: Setup Jujutsu, a version control system. 3 | 4 | # Make sure that "jj(1)" is installed 5 | (( $+commands[jj] )) || return 6 | 7 | jj_prompt_info() { 8 | if axzsh_is_utf_terminal; then 9 | local empty="∅"; local nodesc="⁉" 10 | else 11 | local empty="0"; local nodesc="?" 12 | fi 13 | local jj_info="" 14 | 15 | local jj_status=$(LC_ALL=C jj --color=always status 2>/dev/null) 16 | [[ -n "$jj_status" ]] || return 1 17 | 18 | # Try to get and split the commit ID ... 19 | declare -a jj_id=($( 20 | echo $jj_status \ 21 | | sed -En 's/^Working copy *: \x1B\[1m\x1B\[[0-9;]*m([a-z0-9]*)\x1B\[[0-9;]*m([a-z0-9]*).*/\1 \2/p' 22 | )) 23 | [[ -n "$jj_id" ]] || return 1 24 | 25 | echo $jj_status | grep -E '^Working copy .*\(empty\)' >/dev/null \ 26 | && jj_info+="%{$fg[yellow]%}${empty}%{$fg[default]%}" 27 | echo $jj_status | grep -E '^Working copy .*\(no description set\)' >/dev/null \ 28 | && jj_info+="%{$fg[red]%}${nodesc}%{$fg[default]%}" 29 | 30 | [[ -n "$jj_info" ]] && jj_info=" ${jj_info}" 31 | echo "${ZSH_THEME_VCS_PROMPT_PREFIX}%{$fg_bold[magenta]%}${jj_id[1]}${FG[008]}${jj_id[2]}%{$reset_color%}${jj_info}${ZSH_THEME_VCS_PROMPT_SUFFIX}" 32 | } 33 | 34 | jj_prompt() { 35 | local prompt=$(jj_prompt_info) 36 | [[ -n "$prompt" ]] || return 1 37 | echo "$prompt" 38 | return 0 39 | } 40 | 41 | axzsh_vcs_prompt_functions=($axzsh_vcs_prompt_functions jj_prompt) 42 | 43 | alias jcmsg="jj commit --message" 44 | alias jd="jj diff" 45 | alias jdesc="jj desc" 46 | alias je="jj edit" 47 | alias jf="jj git fetch" 48 | alias jfa="jj git fetch --all-remotes" 49 | alias jlo="jj log" 50 | alias jlon="jj log --limit \$((LINES/3))" 51 | alias jmsg="jj describe --message" 52 | alias jn="jj new" 53 | alias jp="jj git push" 54 | alias jr="jj git remote" 55 | alias jrb="jj rebase" 56 | alias jsh="jj show" 57 | alias jst="jj status" 58 | 59 | # Check for and enable command completion: 60 | if ! type _jj &>/dev/null && ! type _clap_dynamic_completer_jj &>/dev/null; then 61 | # No completion function found so far. 62 | source <(COMPLETE=zsh jj) 63 | fi 64 | -------------------------------------------------------------------------------- /plugins/99-attach-session/99-attach-session.ax-io: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # 99-attach-session: Interactively reattach to a running session. 3 | 4 | # Don't run this plugin on "check-plugins"! 5 | [[ -z "$AXZSH_PLUGIN_CHECK" ]] || return 92 6 | 7 | # Check prerequisites ... 8 | [[ -o interactive ]] || return 91 9 | [[ -z "$STY" ]] || return 91 10 | [[ -z "$TMUX" ]] || return 91 11 | [[ -z "$VIM_TERMINAL" ]] || return 91 12 | 13 | # Don't do anything when ~/.hushlogin exists ... 14 | [[ -r ~/.hushlogin ]] && return 0 15 | 16 | __hello_session() 17 | { 18 | printf "\e[1mThe following $1 sessions are running:\e[m\n" 19 | } 20 | 21 | __get_session_message() 22 | { 23 | echo "Attach to \"$1\" () or enter name; to skip: " 24 | } 25 | 26 | __exit_session() 27 | { 28 | echo 29 | axzsh_handle_stage "attach-session" "zlogout" 30 | exit 0 31 | } 32 | 33 | __break_selection() 34 | { 35 | printf "\nSkipped.\n" 36 | break 37 | } 38 | 39 | # Test for tmux(1) sessions: 40 | if command -v tmux >/dev/null && tmux ls >/dev/null 2>&1; then 41 | __hello_session "tmux(1)" 42 | default=$(tmux ls | head -n 1 | cut -d':' -f1) 43 | tmux ls | awk '{name=$1; $1=""; print "-", "\033[1m"name"\033[m", $0 }' 44 | while true; do 45 | if read "session?$(__get_session_message "$default")"; then 46 | if tmux attach -t "${session:-$default}"; then 47 | __exit_session 48 | fi 49 | else 50 | __break_selection 51 | fi 52 | done 53 | echo 54 | fi 55 | 56 | # Test for screen(1) sessions: 57 | if command -v screen >/dev/null && screen -ls >/dev/null 2>&1; then 58 | __hello_session "screen(1)" 59 | default=$(screen -ls | grep -F '(' | cut -d'.' -f2) 60 | screen -ls | awk '/\(/ {id=$1; name=$2; $1=$2=""; print id, ".\033[1m"name"\033[0m.", $0 }' FS=. OFS= 61 | while true; do 62 | if read "session?$(__get_session_message "$default")"; then 63 | if screen -rd "${session:-$default}"; then 64 | __exit_session 65 | fi 66 | else 67 | __break_selection 68 | fi 69 | done 70 | echo 71 | fi 72 | 73 | # Clean up ... 74 | unfunction __get_session_message __exit_session __break_selection 75 | unset default session 76 | -------------------------------------------------------------------------------- /default_plugins/ssh/ssh.zshrc: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # ssh.zshrc: Setup (Open-) SSH 3 | 4 | # Make sure that "ssh(1)" is installed 5 | (( $+commands[ssh] )) || return 6 | 7 | # Load SSH keys into the SSH agent, when one is running and doesn't have 8 | # any keys already. Not having an SSH agent running at all is ok as well and 9 | # results in an "success" exit code (0) as well. 10 | ssh-autoadd() { 11 | [[ -z "$SSH_AUTH_SOCK" ]] && return 0 12 | ssh-add -l >/dev/null && return 0 13 | [[ $? -eq 2 ]] && return 2 14 | [[ "$1" = "-v" ]] && echo "SSH agent is running, but has no identities." 15 | ssh-add 16 | } 17 | 18 | _axzsh_ssh_prompt() { 19 | [[ -n "$SSH_CLIENT" ]] || return 1 20 | return 0 21 | } 22 | 23 | axzsh_logname_prompt_functions=($axzsh_logname_prompt_functions _axzsh_ssh_prompt) 24 | axzsh_hostname_prompt_functions=($axzsh_hostname_prompt_functions _axzsh_ssh_prompt) 25 | 26 | # Validate SSH_AUTH_SOCK: Inside of screen(1) sessions for example, the socket 27 | # file becomes invalid when the session has been disconnected. 28 | [[ ! -r "$SSH_AUTH_SOCK" ]] && unset SSH_AUTH_SOCK 29 | 30 | # No ssh-agent socket found yet, look for common socket locations ... 31 | if [[ -z "$SSH_AUTH_SOCK" ]]; then 32 | for s ( 33 | /mnt/c/Local/$LOGNAME/ssh-agent.sock 34 | ); do 35 | if [[ -r "$s" ]]; then 36 | export SSH_AUTH_SOCK=$s 37 | break 38 | fi 39 | done 40 | unset s 41 | fi 42 | 43 | # Save SSH environment when available: 44 | if [[ -n "$SSH_AUTH_SOCK" && -d "$XDG_RUNTIME_DIR" ]]; then 45 | # Save current environment when no state exists or state file is invalid. 46 | if [[ -r "$XDG_RUNTIME_DIR/ssh-env.sh" ]]; then 47 | # Check existing state file ... 48 | ( 49 | source "$XDG_RUNTIME_DIR/ssh-env.sh" 50 | if [[ -z "$SSH_AUTH_SOCK" || ! -r "$SSH_AUTH_SOCK" ]]; then 51 | # Content is invalid, remove state file! 52 | rm -f "$XDG_RUNTIME_DIR/ssh-env.sh" 53 | fi 54 | ) 55 | fi 56 | if [[ ! -r "$XDG_RUNTIME_DIR/ssh-env.sh" ]]; then 57 | # No state file exists, create a new one: 58 | echo "SSH_AUTH_SOCK=\"$SSH_AUTH_SOCK\"" >"$XDG_RUNTIME_DIR/ssh-env.sh" 59 | echo "export SSH_AUTH_SOCK" >>"$XDG_RUNTIME_DIR/ssh-env.sh" 60 | fi 61 | fi 62 | 63 | # Restore SSH environment when not set but available: 64 | if [[ -z "$SSH_AUTH_SOCK" && -r "$XDG_RUNTIME_DIR/ssh-env.sh" ]]; then 65 | # Try to recover known good environment ... 66 | source "$XDG_RUNTIME_DIR/ssh-env.sh" 67 | if [[ ! -r "$SSH_AUTH_SOCK" ]]; then 68 | # Clean up! 69 | unset SSH_AUTH_SOCK 70 | rm -f "$XDG_RUNTIME_DIR/ssh-env.sh" 71 | fi 72 | fi 73 | 74 | # No working ssh-agent socket found, look for an GnuPG agent ... 75 | if [[ -z "$SSH_AUTH_SOCK" ]] && (( $+commands[gpgconf] )); then 76 | s=$(gpgconf --list-dirs agent-ssh-socket 2>/dev/null) 77 | [[ -n "$s" && -r "$s" ]] && export SSH_AUTH_SOCK=$s 78 | unset s 79 | fi 80 | -------------------------------------------------------------------------------- /install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # AX-ZSH: Alex' Modular ZSH Configuration 4 | # Copyright (c) 2015-2022 Alexander Barton 5 | # 6 | 7 | # Include "ax-common.sh": 8 | ax_common_sourced= 9 | for dir in "$HOME" "$HOME/.ax" /usr/local /opt/ax /usr; do 10 | [ -z "$ax_common_sourced" ] || break 11 | ax_common="${dir}/lib/ax/ax-common.sh" 12 | # shellcheck source=/usr/local/lib/ax/ax-common.sh 13 | [ -r "$ax_common" ] && . "$ax_common" 14 | done 15 | if [ -z "$ax_common_sourced" ]; then 16 | ax_msg() { 17 | shift 18 | echo "$@" 19 | } 20 | fi 21 | unset dir ax_common ax_common_sourced 22 | 23 | safe_rm() { 24 | if [ -f "$1" ] && [ ! -L "$1" ]; then 25 | rm -f "$1.bak" || abort 26 | mv -v "$1" "$1.bak" || abort 27 | fi 28 | rm -f "$1" || abort 29 | } 30 | 31 | abort() { 32 | ax_msg 2 "Failed to setup AX-ZSH!" 33 | exit 1 34 | } 35 | 36 | umask 027 37 | 38 | [ -n "$AXZSH" ] || AXZSH="${ZDOTDIR:-$HOME}/.axzsh" 39 | export AXZSH 40 | 41 | S=$(dirname "$0") 42 | 43 | if [ "$S" = "$AXZSH" ] || [ "$PWD" = "$AXZSH" ] || [ -L "$AXZSH" ]; then 44 | ax_msg 1 "Initializing \"$AXZSH\":" 45 | else 46 | ax_msg 1 "Install AX-ZSH into \"$AXZSH\":" 47 | mkdir -p "$AXZSH" || abort 48 | 49 | ax_msg - "Copying binaries and scripts ..." 50 | cp -pRv "$S/ax.zsh"* "$AXZSH/" || abort 51 | mkdir -p "$AXZSH/bin" || abort 52 | cp -pRv "$S/bin/"* "$AXZSH/bin/" || abort 53 | 54 | for f in AUTHORS LICENSE.md README.md; do 55 | cp -pRv "$S/$f" "$AXZSH/" || abort 56 | done 57 | 58 | ax_msg - "Copying plugins ..." 59 | for plugin_type in core default_plugins plugins; do 60 | mkdir -p "$AXZSH/$plugin_type" || abort 61 | for p in "$S/$plugin_type/"*; do 62 | echo "$p -> $AXZSH/$p" 63 | rm -fr "${AXZSH:?}/$p" || abort 64 | cp -pR "$S/$p" "$AXZSH/$p" || abort 65 | done 66 | done 67 | 68 | ax_msg - "Copying themes ..." 69 | mkdir -p "$AXZSH/themes" || abort 70 | for p in "$S/themes/"*; do 71 | echo "$p -> $AXZSH/$p" 72 | rm -fr "${AXZSH:?}/$p" || abort 73 | cp -pR "$S/$p" "$AXZSH/$p" || abort 74 | done 75 | fi 76 | 77 | mkdir -p "$AXZSH/custom_plugins" || abort 78 | mkdir -p "$AXZSH/custom_themes" || abort 79 | 80 | ax_msg - "Linking ZSH startup files ..." 81 | 82 | for f in \ 83 | ${ZDOTDIR:-$HOME}/.zlogin \ 84 | ${ZDOTDIR:-$HOME}/.zlogout \ 85 | ${ZDOTDIR:-$HOME}/.zprofile \ 86 | ${ZDOTDIR:-$HOME}/.zshrc \ 87 | ; do 88 | safe_rm "$f" || abort 89 | ln -sv "$AXZSH/ax.zsh" "$f" || abort 90 | done 91 | 92 | if [ ! -d "$AXZSH/active_plugins" ]; then 93 | ax_msg - "Initializing plugin directory \"$AXZSH/active_plugins\" ..." 94 | if command -v zsh >/dev/null; then 95 | zsh "$AXZSH/bin/axzshctl" reset-plugins || abort 96 | else 97 | ax_msg 1 "Oops, \"zsh\" not found!?" 98 | exit 1 99 | fi 100 | else 101 | ax_msg - "Plugin directory \"$AXZSH/active_plugins\" already exists. Ok." 102 | fi 103 | 104 | ax_msg 0 "AX-ZSH setup successfully." 105 | -------------------------------------------------------------------------------- /core/12_locale/12_locale.ax-io: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # 12_locale.zprofile: Initialize locale settings 3 | 4 | # This is only relevant for interactive shells (because the user has to 5 | # manually enter data when the validation fails): 6 | [[ -z "$PS1" ]] && return 0 7 | 8 | # Make sure that LANG and LC_MESSAGES are either unset or set to something sane, 9 | # that is, follow the "xx_ZZ.*" syntax. 10 | fix_locale() { 11 | local encoding locale 12 | 13 | locale="$1:r" 14 | encoding="$1:e" 15 | 16 | if [[ -z "$1" || "$locale" =~ '_' || ${#locale%%_*} -ne 2 ]]; then 17 | echo "$1" 18 | else 19 | locale="${locale:0:2}_${locale:0:2:u}" 20 | [[ -n "$encoding" ]] && locale="$locale.$encoding" 21 | echo "$locale" 22 | fi 23 | } 24 | [[ -n "$AXZSH_DEBUG" ]] && echo " LANG='${LANG:-(unset/empty)}' LANGUAGE='${LANGUAGE:-(unset/empty)}' LC_MESSAGES='${LC_MESSAGES:-(unset/empty)}'" 25 | [[ -n "$LANG" ]] && LANG=$(fix_locale "$LANG") 26 | [[ -n "$LC_MESSAGES" ]] && LANG=$(fix_locale "$LC_MESSAGES") 27 | [[ -n "$AXZSH_DEBUG" ]] && echo " LANG='${LANG:-(unset/empty)}' LANGUAGE='${LANGUAGE:-(unset/empty)}' LC_MESSAGES='${LC_MESSAGES:-(unset/empty)}' - after fix." 28 | unfunction fix_locale 29 | 30 | # Validate the locale(7) settings in interactive shells and try to mimic the 31 | # tset(1) behaviour. 32 | while true; do 33 | lc_messages=$(locale 2>/dev/null | grep -F LC_MESSAGES | cut -d'=' -f2) 34 | [[ "$lc_messages" = '"C"' && "$LANG" != 'C' && "$LC_ALL" != 'C' ]] && lc_messages=$LANG 35 | lc_messages=$lc_messages:gs/\"// 36 | locale=$lc_messages:r 37 | [[ ( "$OSTYPE" =~ '^linux-gnu' || "$OSTYPE" = 'cygwin') && $locale != 'C' ]] \ 38 | && encoding=$lc_messages:e:l:gs/-// \ 39 | || encoding=$lc_messages:e 40 | [[ -n "$encoding" ]] && locale="$locale.$encoding" 41 | [[ -z "$LANG$LANGUAGE$LC_ALL$LC_MESSAGES" ]] && unset lc_messages 42 | 43 | if [[ -n "$LANG$LANGUAGE$LC_ALL$LC_MESSAGES" ]] && locale -a 2>/dev/null | grep "^$locale\$" >/dev/null; then 44 | # The locale setting seems to be valid: one of the LANG, 45 | # LANGUAGE, LC_ALL and/or LC_MESSAGES is set and the locale is 46 | # included in "locale -a" output. Good! 47 | break 48 | fi 49 | 50 | echo "AX-ZSH: Unknown/unsupported locale \"${lc_messages:-unknown}\"!" >&2 51 | unset locale 52 | while [[ -z "$locale" ]]; do 53 | if ! read -r "locale?Locale? "; then 54 | echo >&2 55 | break 2 56 | fi 57 | done 58 | if [[ -n "$locale" ]]; then 59 | export LANG=$locale 60 | unset LANGUAGE LC_ALL LC_MESSAGES 61 | fi 62 | done 63 | unset lc_messages locale encoding 64 | 65 | case "$LANG" in 66 | *_*) 67 | # LANG contains at least one "_" ("aa_BB" form). 68 | if [[ -z "$LANGUAGE" ]]; then 69 | # But LANGUAGE isn't set, so set it automatically to 70 | # "aa_BB:aa" form. 71 | export LANGUAGE=${LANG%.*}:${${LANG%.*}%_*} 72 | fi 73 | esac 74 | [[ -n "$AXZSH_DEBUG" ]] && echo " LANG='${LANG:-(unset/empty)}' LANGUAGE='${LANGUAGE:-(unset/empty)}' LC_MESSAGES='${LC_MESSAGES:-(unset/empty)}' - set." 75 | -------------------------------------------------------------------------------- /core/30_env/30_env.ax-io: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # 30_env.ax-io: Setup environment 3 | 4 | # Setup time zone 5 | if [[ -z "$TZ" && -r "/etc/timezone" ]]; then 6 | TZ=$(<"/etc/timezone") export TZ 7 | fi 8 | 9 | # Validate temporary directory 10 | if [[ -z "$TMPDIR" || "$TMPDIR" = "/" ]]; then 11 | if [[ -n "$XDG_RUNTIME_DIR" && -w "$XDG_RUNTIME_DIR" ]]; then 12 | # The "runtime directory" is set for this user, good, so use 13 | # it silently as the "temporary directory", too: 14 | TMPDIR="$XDG_RUNTIME_DIR" 15 | else 16 | # Try to find a sane "temporary directory", but warn the user 17 | # that this is a best guess only! 18 | TMPDIR="$(dirname $(mktemp -ut tmp.XXXXXXXXXX))/" 19 | [[ -z "$TMPDIR" || "$TMPDIR" = "/" ]] && TMPDIR="/tmp" 20 | user_tmpdir="$TMPDIR$UID" 21 | mkdir -p "$user_tmpdir" >/dev/null 2>&1 22 | if [[ -w "$user_tmpdir" ]]; then 23 | TMPDIR="$user_tmpdir/" 24 | chmod 0700 "$TMPDIR" 25 | fi 26 | echo "AX-ZSH: \"TMPDIR\" was not set, using \"$TMPDIR\"." >&2 27 | unset user_tmpdir 28 | fi 29 | fi 30 | # Make sure TMPDIR ends in a slash (like on macOS by default): this makes its 31 | # usage a bit safer ... 32 | case "$TMPDIR" in 33 | */) ;; 34 | *) TMPDIR="$TMPDIR/" 35 | esac 36 | if [[ ! -w "$TMPDIR" ]]; then 37 | echo "AX-ZSH: Temporary directory \"$TMPDIR\" is not writable!" >&2 38 | fi 39 | export TMPDIR 40 | 41 | # TMPDIR is the only one required to be set, but make sure that TMP, TEMP 42 | # and TEMPDIR are set to the same sane path name when already present in the 43 | # environment: 44 | [[ -n "$TMP" ]] && export TMP="$TMPDIR" 45 | [[ -n "$TEMP" ]] && export TEMP="$TMPDIR" 46 | [[ -n "$TEMPDIR" ]] && export TEMPDIR="$TMPDIR" 47 | 48 | # Setup XDG cache directory 49 | if [[ -z "$XDG_CACHE_HOME" ]]; then 50 | XDG_CACHE_HOME="$LOCAL_HOME/.cache" 51 | fi 52 | if [[ ! -d "$XDG_CACHE_HOME" ]]; then 53 | mkdir -p "$XDG_CACHE_HOME" 54 | chmod 0700 "$XDG_CACHE_HOME" 55 | fi 56 | export XDG_CACHE_HOME 57 | 58 | # Setup XDG runtime directory 59 | if [[ -z "$XDG_RUNTIME_DIR" ]]; then 60 | XDG_RUNTIME_DIR="$TMPDIR/runtime-dir.$UID" 61 | fi 62 | if [[ ! -d "$XDG_RUNTIME_DIR" ]]; then 63 | mkdir -p "$XDG_RUNTIME_DIR" 64 | chmod 0700 "$XDG_RUNTIME_DIR" 65 | fi 66 | export XDG_RUNTIME_DIR 67 | 68 | # Setup ZSH cache directory 69 | if [[ -z "$ZSH_CACHE_DIR" ]]; then 70 | ZSH_CACHE_DIR="$XDG_CACHE_HOME/zsh" 71 | fi 72 | if [[ ! -d "$ZSH_CACHE_DIR" ]]; then 73 | mkdir -p "$ZSH_CACHE_DIR" 74 | chmod 0700 "$ZSH_CACHE_DIR" 75 | fi 76 | export ZSH_CACHE_DIR 77 | 78 | # Save some environment variables as "latest known good values" into a cache 79 | # file, which can be used to "upgrade" sessions already running in a terminal 80 | # multiplexer like screen(1) or tmux(1) but (try to) skip this step if this is 81 | # not the "initial" shell of this session: 82 | [[ "$SHLVL" -eq 1 ]] || return 0 83 | [[ -z "$STY" ]] || return 0 84 | [[ -z "$TMUX" ]] || return 0 85 | [[ -z "$VIM_TERMINAL" ]] || return 0 86 | 87 | state="${ZSH_CACHE_DIR}/axzsh_session_state" 88 | _AX_SESSION=$$ 89 | echo "_AX_SESSION=${_AX_SESSION}" >"$state" 90 | for var in \ 91 | SSH_AUTH_SOCK SSH_CLIENT SSH_CONNECTION SSH_TTY \ 92 | ; do 93 | echo "export ${var}='${(P)var}'" >>"$state" 94 | done 95 | unset state var 96 | -------------------------------------------------------------------------------- /core/40_completion/40_completion.zshrc: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # 50_completion.zshrc: Setup completion 3 | 4 | autoload -Uz compinit 5 | 6 | zstyle ':completion:*' completer _expand _complete _ignored _correct _approximate 7 | 8 | zstyle ':completion:*' accept-exact '*(N)' 9 | zstyle ':completion:*' list-colors '' 10 | zstyle ':completion:*' menu select 11 | zstyle ':completion:*' special-dirs true 12 | zstyle ':completion:*' group-name '' 13 | zstyle ':completion:*' squeeze-slashes true 14 | 15 | # Messages 16 | zstyle ':completion:*:corrections' format '%B%F{green}-> %d (%e errors):%f%b' 17 | zstyle ':completion:*:descriptions' format '%B%F{cyan}-> %d:%f%b' 18 | zstyle ':completion:*:messages' format '%B%F{yellow}-> %d%f%b' 19 | zstyle ':completion:*:warnings' format '%B%F{red}-> no matches found!%f%b' 20 | 21 | # Use caching so that commands like apt and dpkg completions are useable 22 | zstyle ':completion:*' use-cache on 23 | zstyle ':completion:*' cache-path "$ZSH_CACHE_DIR" 24 | 25 | # Manual pages 26 | zstyle ':completion:*:manuals' separate-sections true 27 | zstyle ':completion:*:manuals.*' insert-sections true 28 | 29 | # Don't complete uninteresting users 30 | zstyle ':completion:*:*:*:users' ignored-patterns \ 31 | adm amanda amavis apache arpwatch at avahi backup beaglidx bin bind \ 32 | cacti canna clamav colord daapd daemon davfs2 dbus distcache dnsmasq \ 33 | dovecot dovenull fax fetchmail firebird ftp games gdm geoclue \ 34 | git-daemon gkrellmd gnats gopher hacluster haldaemon halt hsqldb ident \ 35 | irc junkbust kdm ldap libuuid libvirt-qemu list logcheck lp mail \ 36 | mailman mailnull man mariadb messagebus mldonkey mysql nagios named \ 37 | netdata netdump news nfsnobody nobody nscd ntp nut nx obsrun oident \ 38 | openvpn operator pcap polkitd postfix postgres postgrey privoxy proxy \ 39 | pvm quagga radvd redis rpc rpcuser rpm rslsync rtkit rwhod sbuild scard \ 40 | shutdown squid sshd statd stunnel4 svn sync sys tcpdump telnetd \ 41 | telnetd-ssl tftp thelounge tss usbmux uucp uuidd vcsa www-data wwwrun \ 42 | xfs xrdp zabbix \ 43 | '*$' '_*' 'avahi-*' 'cockpit-*' 'cups-*' 'debian-*' 'Debian-*' \ 44 | 'fwupd-*' 'gnome-*' 'speech-*' 'systemd-*' 45 | 46 | # Ignore completion functions 47 | zstyle ':completion:*:functions' ignored-patterns '_*' 48 | 49 | # Show ignore matches, if we really want this 50 | zstyle '*' single-ignored show 51 | 52 | # Save the location of the current completion dump file. 53 | if [[ -z "$ZSH_COMPDUMP" ]]; then 54 | ZSH_COMPDUMP="$ZSH_CACHE_DIR/zcompdump-${SHORT_HOST}-${ZSH_VERSION}" 55 | fi 56 | 57 | # Try to add all folders possibly containing completion functions to the fpath 58 | # before calling compinit. See 59 | # for a discussion of this topic, for example. It boils down to: 60 | # - We have to call compinit early, 61 | # - but plugins can add completions later, that won't be found ... 62 | # (GENCOMPL_FPATH is used by RobSis/zsh-completion-generator) 63 | [[ -n "$GENCOMPL_FPATH" ]] && fpath+=($GENCOMPL_FPATH) 64 | fpath+=("$AXZSH/active_plugins/"*/completions(N)) 65 | fpath+=("$AXZSH/active_plugins/"*/src(N)) 66 | 67 | # Initialize ZSH completion system 68 | if [[ "$ZSH_DISABLE_COMPFIX" = "true" ]]; then 69 | compinit -u -d "$ZSH_COMPDUMP" 70 | else 71 | compinit -d "$ZSH_COMPDUMP" 72 | fi 73 | -------------------------------------------------------------------------------- /plugins/git/git.zshrc: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # git.zshrc: Setup Git 3 | 4 | # Make sure that "git(1)" is installed 5 | (( $+commands[git] )) || return 6 | 7 | git_parse_dirty() { 8 | local flags 9 | flags=( 10 | '--porcelain' 11 | '--ignore-submodules=dirty' 12 | #'--untracked-files=no' 13 | ) 14 | [[ -n "$(git status $flags 2>/dev/null | tail -n1)" ]] \ 15 | && echo "$ZSH_THEME_VCS_PROMPT_DIRTY" \ 16 | || echo "$ZSH_THEME_VCS_PROMPT_CLEAN" 17 | } 18 | 19 | git_current_branch() { 20 | local ref=$(git symbolic-ref --quiet HEAD 2>/dev/null) 21 | local ret=$? 22 | if [[ $ret != 0 ]]; then 23 | [[ $ret == 128 ]] && return # No Git repository 24 | ref=$(git rev-parse --short HEAD 2>/dev/null) || return 25 | fi 26 | echo "${ref#refs/heads/}" 27 | } 28 | 29 | git_prompt_ahead() { 30 | [[ -n "$(git rev-list "@{upstream}..HEAD" 2>/dev/null)" ]] \ 31 | && echo "$ZSH_THEME_VCS_PROMPT_AHEAD" 32 | } 33 | 34 | git_prompt_behind() { 35 | [[ -n "$(git rev-list HEAD..@{upstream} 2>/dev/null)" ]] \ 36 | && echo "$ZSH_THEME_VCS_PROMPT_BEHIND" 37 | } 38 | 39 | git_prompt_info() { 40 | local ref=$(git symbolic-ref HEAD 2>/dev/null) || return 1 41 | [[ -n "$ref" ]] || return 1 42 | echo "${ZSH_THEME_VCS_PROMPT_PREFIX}${ref#refs/heads/}${ZSH_THEME_VCS_PROMPT_SUFFIX}" 43 | } 44 | git_prompt_status() { 45 | local ref=$(git symbolic-ref HEAD 2>/dev/null) || return 1 46 | [[ -n "$ref" ]] || return 1 47 | echo "$(git_parse_dirty)$(git_prompt_ahead)$(git_prompt_behind)" 48 | } 49 | 50 | git_prompt() { 51 | local prompt=$(git_prompt_info) 52 | [[ -n "$prompt" ]] || return 1 53 | echo "$prompt$(git_prompt_status)" 54 | return 0 55 | } 56 | 57 | # OhMyZsh compatibility functions 58 | alias parse_git_dirty=git_parse_dirty 59 | 60 | axzsh_vcs_prompt_functions=($axzsh_vcs_prompt_functions git_prompt) 61 | 62 | alias fix="git diff --name-only | uniq | xargs $EDITOR" 63 | alias g="git" 64 | alias ga="git add" 65 | alias gapa="git add --patch" 66 | alias gc="git commit --verbose" 67 | alias gc!="git commit --verbose --amend" 68 | alias gca="git commit --verbose --all" 69 | alias gcam="git commit --verbose --all --message" 70 | alias gcmsg="git commit --verbose --message" 71 | alias gcn="git commit --verbose --no-edit" 72 | alias gcn!="git commit --verbose --no-edit --amend" 73 | alias gco="git checkout" 74 | alias gd="git diff" 75 | alias gdca="git diff --cached" 76 | alias gdcw="git diff --cached --word-diff" 77 | alias gdw="git diff --word-diff" 78 | alias gf="git fetch" 79 | alias gfa="git fetch --all --prune" 80 | alias gfo="git fetch origin" 81 | alias gl="git pull" 82 | alias glg="git log --stat" 83 | alias glgg="git log --graph" 84 | alias glgga="git log --graph --decorate --all" 85 | alias glgp="git log --stat --patch" 86 | alias glo="git log --oneline --decorate" 87 | alias glog="git log --oneline --decorate --graph" 88 | alias gloga="git log --oneline --decorate --graph --all" 89 | alias glon="git log --oneline --decorate --max-count=\$((LINES*2/3))" 90 | alias gloo="git log --oneline --decorate ORIG_HEAD.." 91 | alias gp="git push" 92 | alias gr="git remote" 93 | alias grb="git rebase" 94 | alias grbi="git rebase --interactive" 95 | alias gsb="git status --short --branch" 96 | alias gsh="git show" 97 | alias gss="git status --short" 98 | alias gst="git status" 99 | alias gsta="git stash push" 100 | alias gstl="git stash list" 101 | alias gstp="git stash pop" 102 | -------------------------------------------------------------------------------- /bin/axttyinfo: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env zsh 2 | # 3 | # AX-ZSH: Alex' Modular ZSH Configuration 4 | # Copyright (c) 2015-2025 Alexander Barton 5 | # 6 | 7 | source "$AXZSH/core/11_terminal/11_terminal.zshrc" || exit 1 8 | 9 | unset VERBOSE ONE_LINE 10 | 11 | while [[ $# -gt 0 ]]; do 12 | case "$1" in 13 | "-1") 14 | ONE_LINE=1 15 | ;; 16 | "-f") 17 | FEATURE_TEST=1 18 | ;; 19 | "-v") 20 | VERBOSE=1 21 | ;; 22 | *) 23 | echo "Usage: ttyinfo [-1] [-f] [-v]" >&2 24 | exit 1 25 | esac 26 | shift 27 | done 28 | 29 | print -Pn -- "$fg[white]$FX[bold]$SHORT_HOST$FX[no-bold] " 30 | print -Pn -- "$fg[yellow]$(tty)$FX[reset], " 31 | print -Pn -- "$fg[green]$FX[underline]${TERM:-?}$FX[reset] " 32 | [[ -n "$TERM_DOWNGRADED_FROM" ]] && print -Pn -- "<<$TERM_DOWNGRADED_FROM " 33 | [[ -n "$TERM_INITIAL" && "$TERM" != "$TERM_INITIAL" ]] && print -Pn -- "<$TERM_INITIAL " 34 | print -Pn -- "(${COLUMNS:-?}x${LINES:-?})" 35 | [[ -n "$TERM_PROGRAM" ]] && print -Pn -- "; $fg[green]$TERM_PROGRAM$FX[reset]" 36 | [[ -n "$$TERM_PROGRAM_VERSION" ]] && print -Pn -- " $TERM_PROGRAM_VERSION" 37 | print -Pn -- "$FX[reset]" 38 | echo 39 | 40 | [[ -n "$ONE_LINE" ]] && return 0 41 | 42 | typeset -i max=${COLUMNS:-80} 43 | typeset -i col=0 44 | for key ( 45 | LANG 46 | LANGUAGE 47 | LC_ALL 48 | LC_ADDRESS 49 | LC_COLLATE 50 | LC_CTYPE 51 | LC_IDENTIFICATION 52 | LC_MEASUREMENT 53 | LC_MESSAGES 54 | LC_MONETARY 55 | LC_NAME 56 | LC_NUMERIC 57 | LC_PAPER 58 | LC_TELEPHONE 59 | LC_TIME 60 | - 61 | COLORTERM 62 | CLICOLOR 63 | TERM_COLORS 64 | VTE_VERSION 65 | - 66 | WAYLAND_DISPLAY 67 | DISPLAY 68 | ); do 69 | if [[ $key == "-" ]]; then 70 | [[ $col -gt 0 ]] && echo 71 | col=0 72 | continue 73 | fi 74 | 75 | [[ "${(P)key-UNSET}" = "UNSET" ]] && continue 76 | val=${(P)key} 77 | 78 | col=$(( $col + ${#key} + ${#val} + 5 )) 79 | if [[ $col -gt $max ]]; then 80 | echo 81 | col=$(( ${#key} + ${#val} + 5 )) 82 | fi 83 | 84 | print -Pn -- "$key=\"$fg[cyan]$val$FX[reset]\"; " 85 | done 86 | [[ $col -gt 0 ]] && echo 87 | 88 | feature_tests=" 89 | Styles: Normal 90 | \033[1mBold\033[0m 91 | \033[2mDim\033[0m 92 | \033[3mItalic\033[0m 93 | \033[3;1mBold italic\033[0m 94 | \033[4mUnderline\033[0m (\033[4:1mvariant 2\033[0m; with \033[58;5;5m\033[4mcolor\033[0m) 95 | \033[4:2mDouble underline\033[0m (\033[21mvariant 2\033[0m) 96 | \033[4:3mCurly underline\033[0m 97 | \033[4:4mDotted underline\033[0m 98 | \033[4:5mDashed underline\033[0m 99 | \033[5mBlink\033[0m 100 | \033[7mReverse\033[0m 101 | Hidden text: \"\033[8mHIDDEN\033[0m\" 102 | \033[9mStrikethrough\033[0m 103 | \033[53mOverline\033[0m 104 | \033[74mSubscript\033[0m 105 | \033[31mRed\033[0m, \"\033[92mbright\033[0m\" \033[32mgreen\033[0m, \033[97mwhite\033[0m on \033[97;44mblue\033[0m, ... 106 | \033]8;;https://github.com/alexbarton/ax-zsh\033\\Hyperlink\033]8;;\033\\ 107 | 108 | Ligatures: -> <- != == === !== >= <= => 109 | 110 | Nerdfont:    󰾆  󰢻 󱑥 󰒲 󰗼 111 | Fontawesome:          112 | " 113 | [[ -n "$FEATURE_TEST" ]] && printf "%b\n" "${feature_tests}" 114 | 115 | [[ -z "$VERBOSE" ]] && return 0 116 | 117 | check_function_result() { 118 | "$1"; r=$? 119 | print -Pn -- " - $fg[white]$1$FX[reset]() = " 120 | if [[ $r -eq 0 ]]; then 121 | print -P -- "$fg[green]yes$FX[reset]" 122 | else 123 | print -P -- "$fg[red]NO$FX[reset]" 124 | fi 125 | return $r 126 | } 127 | 128 | [[ -z "$FEATURE_TEST" ]] && echo 129 | for f ( 130 | axzsh_is_dumb_terminal 131 | axzsh_is_modern_terminal 132 | axzsh_is_utf_terminal 133 | axzsh_is_widechar_terminal 134 | ); do 135 | check_function_result "$f" 136 | done 137 | echo 138 | -------------------------------------------------------------------------------- /core/40_prompt/40_prompt.zshrc: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # 50_prompt.zshrc: Setup default prompts 3 | 4 | # Some dummy functions (used by some OhMyZsh themes, for example) ... 5 | git_prompt_info(){ true; } 6 | git_prompt_status(){ true; } 7 | rvm_prompt_info(){ true; } 8 | 9 | # Logname ("user name") 10 | 11 | ZSH_THEME_LOGNAME_PROMPT_PREFIX_SPACING="" 12 | if (( $UID == 0 )); then 13 | ZSH_THEME_LOGNAME_PROMPT_PREFIX="%{$fg_no_bold[red]%}" \ 14 | ZSH_THEME_LOGNAME_PROMPT_SUFFIX="%{$reset_color%}" 15 | else 16 | ZSH_THEME_LOGNAME_PROMPT_PREFIX="" 17 | ZSH_THEME_LOGNAME_PROMPT_SUFFIX="" 18 | fi 19 | ZSH_THEME_LOGNAME_PROMPT_SUFFIX_SPACING="@" 20 | 21 | function axzsh_logname_prompt_root() { 22 | (( $UID == 0 )) || return 1 23 | return 0 24 | } 25 | 26 | function axzsh_logname_prompt_yn() { 27 | local func 28 | for func ($axzsh_logname_prompt_functions); do 29 | $func || continue 30 | 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}" 31 | return 32 | done 33 | } 34 | 35 | # Hostname 36 | 37 | ZSH_THEME_HOSTNAME_PROMPT_PREFIX_SPACING="" 38 | ZSH_THEME_HOSTNAME_PROMPT_PREFIX="" 39 | ZSH_THEME_HOSTNAME_PROMPT_SUFFIX="" 40 | ZSH_THEME_HOSTNAME_PROMPT_SUFFIX_SPACING=":" 41 | 42 | function axzsh_hostname_prompt_root() { 43 | (( $UID == 0 )) || return 1 44 | return 0 45 | } 46 | 47 | function axzsh_hostname_prompt_yn() { 48 | local func 49 | for func ($axzsh_hostname_prompt_functions); do 50 | $func || continue 51 | 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}" 52 | return 53 | done 54 | } 55 | 56 | axzsh_hostname_prompt_functions=() 57 | 58 | # TTY 59 | 60 | ZSH_THEME_TTY_PROMPT_PREFIX_SPACING="[" 61 | ZSH_THEME_TTY_PROMPT_PREFIX="" 62 | ZSH_THEME_TTY_PROMPT_SUFFIX="" 63 | ZSH_THEME_TTY_PROMPT_SUFFIX_SPACING="] " 64 | 65 | function axzsh_tty_prompt_yn() { 66 | [[ "$TTY" = /dev/tty[0-9]* ]] || return 67 | echo "${ZSH_THEME_TTY_PROMPT_PREFIX_SPACING}${ZSH_THEME_TTY_PROMPT_PREFIX}${TTY##*/}${ZSH_THEME_TTY_PROMPT_SUFFIX}${ZSH_THEME_TTY_PROMPT_SUFFIX_SPACING}" 68 | } 69 | 70 | # VCS 71 | 72 | if axzsh_is_utf_terminal; then 73 | clean="✔"; dirty="✘"; ahead="→"; behind="←" 74 | else 75 | clean="+"; dirty="x"; ahead=">"; behind="<" 76 | fi 77 | 78 | ZSH_THEME_VCS_PROMPT_PREFIX_SPACING="(" 79 | ZSH_THEME_VCS_PROMPT_PREFIX="%{$fg_no_bold[yellow]%}" 80 | ZSH_THEME_VCS_PROMPT_SUFFIX="%{$fg[default]%}" 81 | ZSH_THEME_VCS_PROMPT_SUFFIX_SPACING=")" 82 | 83 | ZSH_THEME_VCS_PROMPT_CLEAN=" %{$fg_no_bold[green]%}$clean%{$fg[default]%}" 84 | ZSH_THEME_VCS_PROMPT_DIRTY=" %{$fg_no_bold[red]%}$dirty%{$fg[default]%}" 85 | ZSH_THEME_VCS_PROMPT_AHEAD="%{$fg_no_bold[cyan]%}$ahead%{$fg[default]%}" 86 | ZSH_THEME_VCS_PROMPT_BEHIND="%{$fg_no_bold[blue]%}$behind%{$fg[default]%}" 87 | 88 | unset clean dirty ahead behind 89 | 90 | function axzsh_vcs_prompt() { 91 | local func 92 | local p 93 | for func ($axzsh_vcs_prompt_functions); do 94 | p=$( $func ) || continue 95 | echo "${ZSH_THEME_VCS_PROMPT_PREFIX_SPACING}${p}${ZSH_THEME_VCS_PROMPT_SUFFIX_SPACING}" 96 | return 97 | done 98 | } 99 | 100 | axzsh_vcs_prompt_functions=() 101 | 102 | # Prompt 103 | 104 | ZSH_THEME_PROMPT="$" 105 | ZSH_THEME_PROMPT_ROOT="#" 106 | 107 | ZSH_THEME_PROMPT_PREFIX_SPACING="" 108 | ZSH_THEME_PROMPT_PREFIX="" 109 | ZSH_THEME_PROMPT_ROOT_PREFIX="" 110 | ZSH_THEME_PROMPT_SUFFIX="" 111 | ZSH_THEME_PROMPT_SUFFIX_SPACING="" 112 | 113 | function axzsh_prompt() { 114 | local p 115 | (( $UID == 0 )) \ 116 | && p="${ZSH_THEME_PROMPT_ROOT_PREFIX}${ZSH_THEME_PROMPT_ROOT}" \ 117 | || p="${ZSH_THEME_PROMPT_PREFIX}${ZSH_THEME_PROMPT}" 118 | echo "${ZSH_THEME_PROMPT_PREFIX_SPACING}${p}${ZSH_THEME_PROMPT_SUFFIX}${ZSH_THEME_PROMPT_SUFFIX_SPACING}" 119 | } 120 | 121 | # Options and defaults 122 | 123 | setopt PROMPT_SUBST 124 | -------------------------------------------------------------------------------- /plugins/iterm2/iterm2.zshrc: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # iterm2.zshrc: iTerm2 Shell Integration 3 | 4 | [[ -z "$AXZSH_PLUGIN_CHECK" ]] || return 92 5 | 6 | # Check prerequisites ... 7 | axzsh_is_modern_terminal || return 91 8 | [[ -o interactive ]] || return 91 9 | [[ -z "$ITERM_SHELL_INTEGRATION_INSTALLED" ]] || return 91 10 | [[ -z "$VIM_TERMINAL" ]] || return 91 11 | [[ "${ITERM_ENABLE_SHELL_INTEGRATION_WITH_TMUX-}$TERM" =~ "^screen" ]] && return 91 12 | [[ "${ITERM_ENABLE_SHELL_INTEGRATION_WITH_TMUX-}$TERM" =~ "^tmux" ]] && return 91 13 | 14 | # Add iTerm2 commands to PATH, when available. 15 | [[ -d ~/.iterm2 ]] && path+=(~/.iterm2) 16 | 17 | # Try to source user-local shell integration installed by iTerm2 itself, 18 | # and only fall back to the implementation here when not found. 19 | [[ -e "$HOME/.iterm2_shell_integration.zsh" ]] && source "$HOME/.iterm2_shell_integration.zsh" 20 | 21 | # ax-zsh specific iTerm2 functions 22 | iterm2_clear_captured_output() { 23 | printf "\e]1337;ClearCapturedOutput\e\\" 24 | } 25 | 26 | [[ -z "$ITERM_SHELL_INTEGRATION_INSTALLED" ]] || return 0 27 | 28 | ITERM_SHELL_INTEGRATION_INSTALLED="Yes" 29 | ITERM2_SHOULD_DECORATE_PROMPT="1" 30 | 31 | if [[ -n "$TMUX" ]]; then 32 | # Pass escape sequences through in tmux(1), see 33 | # . 34 | TMUX_PREFIX='\ePtmux;\e' 35 | TMUX_POSTFIX='\e\\' 36 | else 37 | unset TMUX_PREFIX TMUX_POSTFIX 38 | fi 39 | 40 | # Indicates start of command output. Runs just before command executes. 41 | iterm2_before_cmd_executes() { 42 | if [[ "$TERM_PROGRAM" = "iTerm.app" ]]; then 43 | printf "${TMUX_PREFIX}\033]133;C;\r\007${TMUX_POSTFIX}" 44 | else 45 | printf "${TMUX_PREFIX}\033]133;C;\007${TMUX_POSTFIX}" 46 | fi 47 | } 48 | 49 | iterm2_set_user_var() { 50 | printf "${TMUX_PREFIX}\033]1337;SetUserVar=%s=%s\007${TMUX_POSTFIX}" "$1" "$(printf "%s" "$2" | base64 | tr -d '\n')" 51 | } 52 | 53 | # Users can write their own version of this method. It should call 54 | # iterm2_set_user_var but not produce any other output. 55 | # e.g., iterm2_set_user_var currentDirectory $PWD 56 | # Accessible in iTerm2 (in a badge now, elsewhere in the future) as 57 | # \(user.currentDirectory). 58 | if ! whence iterm2_print_user_vars >/dev/null; then 59 | iterm2_print_user_vars() { 60 | : 61 | } 62 | fi 63 | 64 | iterm2_print_state_data() { 65 | printf "${TMUX_PREFIX}\033]1337;RemoteHost=%s@%s\007${TMUX_POSTFIX}" "$USER" "$HOST" 66 | printf "${TMUX_PREFIX}\033]1337;CurrentDir=%s\007${TMUX_POSTFIX}" "$PWD" 67 | iterm2_print_user_vars 68 | } 69 | 70 | # Report return code of command; runs after command finishes but before prompt 71 | iterm2_after_cmd_executes() { 72 | printf "${TMUX_PREFIX}\033]133;D;%s\007${TMUX_POSTFIX}" "$STATUS" 73 | iterm2_print_state_data 74 | } 75 | 76 | # Mark start of prompt 77 | iterm2_prompt_mark() { 78 | printf "${TMUX_PREFIX}\033]133;A\007${TMUX_POSTFIX}" 79 | } 80 | 81 | # Mark end of prompt 82 | iterm2_prompt_end() { 83 | printf "${TMUX_PREFIX}\033]133;B\007${TMUX_POSTFIX}" 84 | } 85 | 86 | # There are three possible paths in life. 87 | # 88 | # 1) A command is entered at the prompt and you press return. 89 | # The following steps happen: 90 | # * iterm2_preexec is invoked 91 | # * PS1 is set to ITERM2_PRECMD_PS1 92 | # * ITERM2_SHOULD_DECORATE_PROMPT is set to 1 93 | # * The command executes (possibly reading or modifying PS1) 94 | # * iterm2_precmd is invoked 95 | # * ITERM2_PRECMD_PS1 is set to PS1 (as modified by command execution) 96 | # * PS1 gets our escape sequences added to it 97 | # * zsh displays your prompt 98 | # * You start entering a command 99 | # 100 | # 2) You press ^C while entering a command at the prompt. 101 | # The following steps happen: 102 | # * (iterm2_preexec is NOT invoked) 103 | # * iterm2_precmd is invoked 104 | # * iterm2_before_cmd_executes is called since we detected that iterm2_preexec was not run 105 | # * (ITERM2_PRECMD_PS1 and PS1 are not messed with, since PS1 already has our escape 106 | # sequences and ITERM2_PRECMD_PS1 already has PS1's original value) 107 | # * zsh displays your prompt 108 | # * You start entering a command 109 | # 110 | # 3) A new shell is born. 111 | # * PS1 has some initial value, either zsh's default or a value set before this script is sourced. 112 | # * iterm2_precmd is invoked 113 | # * ITERM2_SHOULD_DECORATE_PROMPT is initialized to 1 114 | # * ITERM2_PRECMD_PS1 is set to the initial value of PS1 115 | # * PS1 gets our escape sequences added to it 116 | # * Your prompt is shown and you may begin entering a command. 117 | # 118 | # Invariants: 119 | # * ITERM2_SHOULD_DECORATE_PROMPT is 1 during and just after command execution, and "" while the prompt is 120 | # shown and until you enter a command and press return. 121 | # * PS1 does not have our escape sequences during command execution 122 | # * After the command executes but before a new one begins, PS1 has escape sequences and 123 | # ITERM2_PRECMD_PS1 has PS1's original value. 124 | iterm2_decorate_prompt() { 125 | # This should be a raw PS1 without iTerm2's stuff. It could be changed during command 126 | # execution. 127 | ITERM2_PRECMD_PS1="$PS1" 128 | ITERM2_SHOULD_DECORATE_PROMPT="" 129 | 130 | # Add our escape sequences just before the prompt is shown. 131 | # Use ITERM2_SQUELCH_MARK for people who can't modify PS1 directly, like powerlevel9k users. 132 | # This is gross but I had a heck of a time writing a correct if statement for zsh 5.0.2. 133 | local PREFIX="" 134 | if [[ $PS1 == *"$(iterm2_prompt_mark)"* ]]; then 135 | PREFIX="" 136 | elif [[ "${ITERM2_SQUELCH_MARK-}" != "" ]]; then 137 | PREFIX="" 138 | else 139 | PREFIX="%{$(iterm2_prompt_mark)%}" 140 | fi 141 | PS1="$PREFIX$PS1%{$(iterm2_prompt_end)%}" 142 | ITERM2_DECORATED_PS1="$PS1" 143 | } 144 | 145 | iterm2_precmd() { 146 | local STATUS="$?" 147 | if [[ -z "${ITERM2_SHOULD_DECORATE_PROMPT-}" ]]; then 148 | # You pressed ^C while entering a command (iterm2_preexec did not run) 149 | iterm2_before_cmd_executes 150 | if [[ "$PS1" != "${ITERM2_DECORATED_PS1-}" ]]; then 151 | # PS1 changed, perhaps in another precmd. See issue 9938. 152 | ITERM2_SHOULD_DECORATE_PROMPT="1" 153 | fi 154 | fi 155 | 156 | iterm2_after_cmd_executes "$STATUS" 157 | 158 | if [[ -n "$ITERM2_SHOULD_DECORATE_PROMPT" ]]; then 159 | iterm2_decorate_prompt 160 | fi 161 | } 162 | 163 | # This is not run if you press ^C while entering a command. 164 | iterm2_preexec() { 165 | # Set PS1 back to its raw value prior to executing the command. 166 | PS1="$ITERM2_PRECMD_PS1" 167 | ITERM2_SHOULD_DECORATE_PROMPT="1" 168 | iterm2_before_cmd_executes 169 | } 170 | 171 | precmd_functions+=(iterm2_precmd) 172 | preexec_functions+=(iterm2_preexec) 173 | 174 | iterm2_print_state_data 175 | printf "${TMUX_PREFIX}\033]1337;ShellIntegrationVersion=14;shell=zsh\007${TMUX_POSTFIX}" 176 | -------------------------------------------------------------------------------- /ax.zsh: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # Copyright (c) 2015-2024 Alexander Barton 3 | 4 | script_name="${${(%):-%N}:t}" 5 | script_type="$script_name[2,-1]" 6 | 7 | # Handle "initialization stage", load all plugins of that stage, either from an 8 | # existing cache file or individually, optionally creating the cache. 9 | # - $1: Script name 10 | # - $2: Stage name (ax-io, zprofile, zshrc, zlogin, zlogout) 11 | function axzsh_handle_stage { 12 | local name="$1" 13 | local type="$2" 14 | 15 | [[ -n "$AXZSH_DEBUG" ]] && echo "» $name ($type):" 16 | 17 | # Look for some 3rd-party integrations ... 18 | 19 | # --- Powerlevel10k --- 20 | # Enable instant prompt. Should stay close to the top of ~/.zshrc. 21 | # Initialization code that may require console input (password prompts, 22 | # [y/n] confirmations, etc.) must be executed before this, so all ax-zsh 23 | # plugins should do output in their "ax-io" stage only! 24 | # Read the initialization script in the "zprofile" stage for login 25 | # shells, and in the "zshrc" stage for non-login sub-shells (which have 26 | # the profile already read in and therefore will skip the "ax-io" and 27 | # "zprofile" stages and not catch up). 28 | if [[ \ 29 | ( "$type" == "zprofile" ) || \ 30 | ( ! -o login && "$type" == "zshrc" && -n "$AXZSH_ZPROFILE_READ" ) \ 31 | ]]; then 32 | p10k_instant_prompt="${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" 33 | if [[ -r "$p10k_instant_prompt" ]]; then 34 | [[ -n "$AXZSH_DEBUG" ]] && echo " Reading \"$p10k_instant_prompt\" ..." 35 | source "$p10k_instant_prompt" 36 | fi 37 | unset p10k_instant_prompt 38 | fi 39 | # Read in Powerlevel10k configuration file, if not already read: 40 | [[ -z "$POWERLEVEL9K_CONFIG_FILE" && -r ~/.p10k.zsh ]] && source ~/.p10k.zsh 41 | 42 | # Initialize cache 43 | [[ -d "$AXZSH/cache" ]] || mkdir -p "$AXZSH/cache" 44 | local cache_file="$AXZSH/cache/$type.cache" 45 | 46 | local cat_cmd=${commands[cat]:-cat} 47 | 48 | if [[ -r "$cache_file" ]]; then 49 | # Cache file exists, use it! 50 | # But when in the "zshrc" stage, make sure that the "zprofile" stage 51 | # has already been handled (this uses the "01_zprofile" plugin which 52 | # is used in the "zshrc.cache" as well, but can't be used successfully 53 | # there because it becomes sourced inside of a ZSH function; so we have 54 | # to source it here in the global context manually ...): 55 | [[ -z "$AXZSH_ZPROFILE_READ" && "$type" = "zshrc" ]] \ 56 | && source "$AXZSH/core/01_zprofile/01_zprofile.zshrc" 57 | [[ -n "$AXZSH_DEBUG" ]] \ 58 | && echo " - Reading cache file \"$cache_file\" ..." 59 | source "$cache_file" 60 | (( $+functions[axzsh_plugin_init] )) && unfunction axzsh_plugin_init 61 | else 62 | # No cache file available. 63 | local new_cache_file="$cache_file.NEW" 64 | 65 | # Setup list of plugins to load: 66 | local plugin_list 67 | typeset -U plugin_list 68 | plugin_list=( 69 | "$AXZSH/core/"[0-4]* 70 | "$AXZSH/active_plugins/"[0-4]*(N) 71 | "$AXZSH/active_plugins/"[@A-Za-z]*(N) 72 | "$AXZSH/core/"[5-7]* 73 | "$AXZSH/active_plugins/"[5-7]*(N) 74 | "$AXZSH/core/"[8-9]* 75 | "$AXZSH/active_plugins/"[8-9]*(N) 76 | ) 77 | 78 | # Create new cache file: 79 | [[ -n "$AXZSH_DEBUG" ]] \ 80 | && echo " (Writing new cache file to \"$new_cache_file\" ...)" 81 | if ! printf "# %s\n\n" "$(LC_ALL=C date)" >"$new_cache_file"; then 82 | unset new_cache_file 83 | else 84 | # New cache file successfully created ... 85 | if [[ "$type" = "ax-io" ]]; then 86 | # AX-IO Stage: 87 | # Write an initial PATH variable to the cache 88 | # file, which becomes overwritten by the path 89 | # plugin at the "zprofile" stage later on, but 90 | # this way "ax-io" stage plugins have a somewhat 91 | # saner PATH to begin with ... 92 | printf 'export PATH=/usr/bin:/bin\n\n' >>"$new_cache_file" 93 | fi 94 | fi 95 | 96 | # Read in all the plugins for the current "type": 97 | for plugin ($plugin_list); do 98 | # Read the "theme file", if any and in "zshrc" stage. 99 | # This must be done before 99_cleanup is run! 100 | if [[ "$plugin:t" == "99_cleanup" && "$type" = "zshrc" ]]; then 101 | if [[ -r "$AXZSH_THEME" ]]; then 102 | source "$AXZSH_THEME" 103 | if [[ -n "$new_cache_file" ]]; then 104 | # Source the theme in the new cache file: 105 | echo "# BEGIN Theme" >>"$new_cache_file" 106 | echo 'test -r "$AXZSH_THEME" && source "$AXZSH_THEME"' >>"$new_cache_file" 107 | echo "# END Theme" >>"$new_cache_file" 108 | fi 109 | fi 110 | fi 111 | axzsh_load_plugin "$plugin" "$type" "$new_cache_file" 112 | done 113 | 114 | if [[ -n "$cache_file" && -n "$new_cache_file" && -r "$new_cache_file" ]]; then 115 | # Move newly created cache file in place: 116 | mv "$new_cache_file" "$cache_file" 117 | fi 118 | fi 119 | } 120 | 121 | # Load plugin code of a given type. 122 | # - $1: plugin name 123 | # - $2: plugin type (optional; defaults to "zshrc") 124 | # - $3: cache file (optional) 125 | function axzsh_load_plugin { 126 | local dname="$1:A" 127 | local plugin="$dname:t" 128 | [[ -z "$2" ]] && local type="zshrc" || local type="$2" 129 | local fname="$dname/$plugin.$type" 130 | local cache_file="$3" 131 | 132 | # Strip repository prefix (like "alexbarton#test-plugin"): 133 | [[ "$plugin" =~ "#" ]] && plugin=$(echo $plugin | cut -d'#' -f2-) 134 | 135 | # "short plugin name": strip ".zsh" suffix: 136 | plugin_short=${plugin%.zsh} 137 | 138 | if [[ ! -d "$dname" ]]; then 139 | # Plugin not found! 140 | if [[ -n "$AXZSH_DEBUG" ]]; then 141 | # Show error message for all stages in "debug mode": 142 | echo "AX-ZSH plugin \"$plugin\" not found (type \"$type\")!" >&2 143 | elif [[ "$type" == "zshrc" ]]; then 144 | # Show error message for the "zshrc" stage: 145 | echo "AX-ZSH plugin \"$plugin\" not found, skipped!" >&2 146 | fi 147 | return 1 148 | fi 149 | 150 | if [[ ! -r "$fname" && "$type" == "zshrc" ]]; then 151 | zsh_themes=("$dname/"*.zsh-theme(NY1)) 152 | if [[ -r "$dname/$plugin.ax-io" || -r "$dname/$plugin.zprofile" || -r "$dname/$plugin.zlogout" ]]; then 153 | # Native AX-ZSH plugin, but for different stage. Skip it! 154 | : 155 | elif [[ -r "$dname/${plugin_short}.plugin.zsh" ]]; then 156 | # Oh My ZSH plugin 157 | type="plugin.zsh" 158 | fname="$dname/${plugin_short}.plugin.zsh" 159 | elif [[ -r "$dname/${plugin_short##zsh-}.plugin.zsh" ]]; then 160 | # Oh My ZSH plugin with "zsh-" prefix stripped 161 | type="plugin.zsh" 162 | fname="$dname/${plugin_short##zsh-}.plugin.zsh" 163 | elif [[ -r "$dname/${plugin%.plugin.zsh}.plugin.zsh" ]]; then 164 | # Oh My ZSH plugin with ".plugin.zsh" suffix in its name 165 | type="plugin.zsh" 166 | fname="$dname/${plugin}" 167 | elif [[ -r "$dname/init.zsh" ]]; then 168 | # Prezto module 169 | type="init.zsh" 170 | fname="$dname/init.zsh" 171 | elif [[ ${#zsh_themes} -gt 0 ]]; then 172 | # ZSH "theme plugin", ignore here! 173 | : 174 | elif [[ -r "${dname}/${plugin_short}.zsh" ]]; then 175 | # Raw plugin with ".zsh" suffix. 176 | type="raw.zsh" 177 | fname="${dname}/${plugin_short}.zsh" 178 | elif [[ -r "${dname}/${plugin_short}.sh" ]]; then 179 | # Raw plugin with ".sh" suffix. 180 | type="raw.sh" 181 | fname="${dname}/${plugin_short}.sh" 182 | elif [[ -r "${dname}/${plugin_short}" ]]; then 183 | # Raw plugin without suffix. 184 | type="raw" 185 | fname="${dname}/${plugin_short}" 186 | else 187 | echo "AX-ZSH plugin type of \"$plugin\" unknown, skipped!" >&2 188 | echo "Contents of \"$dname\":" >&2 189 | ls -lh "$dname/" >&2 190 | return 0 191 | fi 192 | fi 193 | 194 | if [[ "$type" == "zprofile" && -d "$dname/functions" ]]; then 195 | # Add plugin function path when folder exists 196 | [[ -n "$AXZSH_DEBUG" ]] \ 197 | && echo " - $plugin ($type): functions ..." 198 | axzsh_fpath+=("$dname/functions") 199 | 200 | # Add function path to cache file. 201 | [[ -n "$cache_file" ]] \ 202 | && echo "axzsh_fpath+=('$dname/functions')" >>$cache_file 203 | fi 204 | 205 | if [[ -r "$fname" ]]; then 206 | # Read plugin ... 207 | [[ -n "$AXZSH_DEBUG" ]] \ 208 | && echo " - $plugin ($type) ..." 209 | 210 | # Note for external ("repo/*") plugins on dumb terminals: These 211 | # (modern?) plugins most probably don't expect such a terminal 212 | # configuration and don't behave well (echo color sequences, 213 | # for example). Therefore we DON'T load any external plugins at 214 | # all in that case: this results in reduced/disabled 215 | # functionality, but hopefully in readable output ... 216 | 217 | case "$fname" in 218 | *"/repos/"*) 219 | axzsh_is_dumb_terminal || source "$fname" 220 | ;; 221 | *) 222 | source "$fname" 223 | esac 224 | 225 | if [[ -n "$cache_file" ]]; then 226 | # Add plugin data to cache 227 | printf "# BEGIN: %s\naxzsh_plugin_init()\n{\n" "$fname" >>"$cache_file" 228 | case "$fname" in 229 | *"/repos/"*) 230 | echo "[[ -n \"\$AXZSH_DEBUG\" ]] && echo ' - $plugin ($type): \"$fname\" ...'" >>$cache_file 231 | echo "axzsh_is_dumb_terminal || source '$fname'" >>$cache_file 232 | ;; 233 | *) 234 | echo "[[ -n \"\$AXZSH_DEBUG\" ]] && echo ' - $plugin ($type, cached) ...'" >>$cache_file 235 | "$cat_cmd" "$fname" >>"$cache_file" 236 | esac 237 | printf "}\naxzsh_plugin_init\n# END: %s\n\n" "$fname" >>"$cache_file" 238 | fi 239 | fi 240 | 241 | # It is a success, even if only the plugin directory (and no script!) 242 | # exists at all! Rationale: The script could be of an other type ... 243 | return 0 244 | } 245 | 246 | # Make sure that "my" (=ZSH) directory is in the search path ... 247 | if [[ -z "$AXZSH" ]]; then 248 | _p="${0:h}" 249 | [[ "$_p" != "." ]] && PATH="$PATH:${0:h}" 250 | unset _p 251 | fi 252 | 253 | # Make sure that "SHELL" variable is set and exported 254 | [[ -n "$SHELL" ]] || export SHELL=$(command -v zsh) 255 | 256 | # Make sure that "AXZSH" variable is set and exported 257 | [[ -n "$AXZSH" ]] || export AXZSH="${ZDOTDIR:-$HOME}/.axzsh" 258 | 259 | # Check for "debug mode" ... 260 | if [[ -f "$AXZSH/debug" || -f "$HOME/.axzsh.debug" ]]; then 261 | export AXZSH_DEBUG=1 262 | export POWERLEVEL9K_INSTANT_PROMPT=quiet 263 | echo "AXZSH=$AXZSH" 264 | echo "AXZSH_DEBUG=$AXZSH_DEBUG" 265 | echo "AXZSH_PLUGIN_D=$AXZSH_PLUGIN_D" 266 | echo "AXZSH_ZLOGIN_READ=$AXZSH_ZLOGIN_READ" 267 | echo "AXZSH_ZPROFILE_READ=$AXZSH_ZPROFILE_READ" 268 | fi 269 | 270 | # Reset some caches. These should become refreshed per-stage: 271 | unset _axzsh_is_modern_terminal_cache _axzsh_is_widechar_terminal_cache 272 | 273 | if [[ "$script_type" = "zprofile" ]]; then 274 | # Load all "output" plugins first, that is, before the "zprofile stage": 275 | axzsh_handle_stage "$script_name" "ax-io" 276 | fi 277 | 278 | axzsh_handle_stage "$script_name" "$script_type" 279 | 280 | # Clean up ... 281 | unfunction axzsh_handle_stage axzsh_load_plugin 282 | unset script_name script_type 283 | 284 | # Hints for external installers: 285 | # - iTerm2: DON'T install "iterm2_shell_integration"! 286 | -------------------------------------------------------------------------------- /core/11_terminal/11_terminal.zshrc: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | # 11_terminal.zshrc: Initialize terminal settings 3 | 4 | # Fix up TERM. Do this here in the zshrc stage (and not in zprofile), because 5 | # terminal emulators often don't start a new login shell but "only" a new 6 | # interactive shell. 7 | 8 | [[ -n "$AXZSH_DEBUG" ]] && \ 9 | echo " TERM='${TERM:-(unset/empty)}' TERM_COLORS='${TERM_COLORS:-(unset/empty)}' TERM_DOWNGRADED_FROM='${TERM_DOWNGRADED_FROM:-(unset/empty)}' ..." 10 | 11 | # Normally, TERM_INITIAL is set in the zprofile stage; but make sure that it is 12 | # set, for example in non-login shells! 13 | [[ -n "$TERM_INITIAL" ]] || TERM_INITIAL="$TERM" 14 | 15 | # Try to get a value for TERM_COLORS, when it is not yet set. Note: it will be 16 | # re-detected for the final TERM type later on below! 17 | [[ -n "$TERM_COLORS" ]] || TERM_COLORS=$(tput colors 2>/dev/null) 18 | initial_term_colors="$TERM_COLORS" 19 | 20 | # VTE based terminals (like GNOME Terminal) support 256 colors, but old(er) 21 | # versions of GNOME Terminal (at least) set TERM=xterm ... 22 | [[ "$TERM" = "xterm" && "$VTE_VERSION" != "" ]] && TERM="xterm-256color" 23 | 24 | # Fix TERM_COLORS according to the initial TERM setting ... This is mostly 25 | # relevant in terminal multiplexers like screen(1) and tmux(1) which, sometimes 26 | # by default, use their "*-256color" TERM type -- even when the initial 27 | # terminal only supports a subset! 28 | # Note that the final value for the TERM_COLORS variable is determined 29 | # according to the final TERM value and overwritten later on below! 30 | [[ $TERM_COLORS -gt 16 && "$TERM_INITIAL" = *-16color ]] && TERM_COLORS=16 31 | [[ $TERM_COLORS -gt 8 && ( 32 | "$TERM_INITIAL" = ansi || 33 | "$TERM_INITIAL" = linux || 34 | "$TERM_INITIAL" = xterm 35 | ) ]] && TERM_COLORS=8 36 | [[ $TERM_COLORS -gt 2 && ( 37 | "$TERM_INITIAL" = dumb || 38 | "$TERM_INITIAL" = vt52 || 39 | "$TERM_INITIAL" = vt100 40 | ) ]] && TERM_COLORS=2 41 | 42 | # Check if TERM_COLORS match the TERM setting, and fix TERM if not: 43 | [[ $TERM_COLORS -lt 16 && "$TERM" = *-16color ]] \ 44 | && downgrade="16color" 45 | [[ $TERM_COLORS -lt 256 && "$TERM" = *-256color ]] \ 46 | && downgrade="256color" 47 | if [[ -n "$downgrade" ]]; then 48 | # Save the "pre-downgrade" setting(s) ... 49 | [[ -z "$TERM_DOWNGRADED_FROM" ]] \ 50 | && TERM_DOWNGRADED_FROM="${TERM}[${initial_term_colors}]" \ 51 | || TERM_DOWNGRADED_FROM="${TERM}[${initial_term_colors}],${TERM_DOWNGRADED_FROM}" 52 | export TERM_DOWNGRADED_FROM 53 | # Cut off the wrong suffix! Try first to use a "-color"-type, 54 | # and fall back to the plain type if this is not known. 55 | new_term="${TERM%*-$downgrade}" 56 | TERM="${new_term}-${TERM_COLORS}color" tput colors 1>/dev/null 2>&1 \ 57 | && TERM="${new_term}-${TERM_COLORS}color" || TERM="${new_term}" 58 | export TERM 59 | unset new_term 60 | # Adjust color definitions for ls(1): 61 | unset LS_COLORS 62 | (( $+commands[dircolors] )) && eval $(dircolors) 63 | fi 64 | unset downgrade initial_term_colors 65 | 66 | # Common helper functions 67 | 68 | # Check if terminal supports Unicode. 69 | # 70 | function axzsh_is_utf_terminal { 71 | case "$LANG $CHARSET $LANGUAGE" in 72 | (*utf*) return 0 ;; 73 | (*UTF*) return 0 ;; 74 | (*) return 1 ;; 75 | esac 76 | } 77 | # Compatibility with GRMLZSHRC, see : 78 | alias isutfenv=axzsh_is_utf_terminal 79 | 80 | # Get the length of a string when shown on the terminal. The return code of the 81 | # function is the length in "cells". Note: Echoing the length to the terminal, 82 | # which looks cleaner at first, doesn't work: this command can't be called with 83 | # its stdin and/or stdout redirected, as it must be able to interact with the 84 | # terminal (write to and read from it). 85 | function axzsh_get_displayed_length { 86 | echo -ne "$*\033[6n" 87 | read -s -d\[ garbage 88 | read -s -d R pos 89 | echo -ne "\033[1K\r" 90 | return $((${pos#*;} - 1)) 91 | } 92 | 93 | # Check if terminal correctly handles "wide" characters, which means, displays 94 | # them with the correct width (>1). 95 | # 96 | typeset -g _axzsh_is_widechar_terminal_cache 97 | function axzsh_is_widechar_terminal { 98 | if [[ -z "$_axzsh_is_widechar_terminal_cache" ]]; then 99 | # No cached result, call test function ... 100 | _axzsh_is_widechar_terminal 101 | _axzsh_is_widechar_terminal_cache=$? 102 | fi 103 | return $_axzsh_is_widechar_terminal_cache 104 | } 105 | function _axzsh_is_widechar_terminal { 106 | [[ -t 1 ]] || return 1 107 | [[ -z "$AXZSH_PLUGIN_CHECK" ]] || return 1 108 | axzsh_is_utf_terminal || return 1 109 | axzsh_get_displayed_length "🍀" 110 | [[ $? -eq 2 ]] && return 0 || return 1 111 | } 112 | 113 | # Test for "modern" terminal 114 | function axzsh_is_modern_terminal { 115 | if [[ -z "$TERM" ]]; then 116 | # Ops, the TERM environment variable is no (longer) set? 117 | # This is definitely not a "modern" terminal! 118 | unset _axzsh_is_modern_terminal_cache 119 | return 1 120 | fi 121 | [[ -n "$TERM_DOWNGRADED_FROM" ]] && return 1 122 | [[ "$TERM_COLORS" -le 8 ]] && return 1 123 | [[ -n "$_axzsh_is_modern_terminal_cache" ]] \ 124 | && return $(test "$_axzsh_is_modern_terminal_cache" -eq 0 2>/dev/null) 125 | 126 | result=1 127 | [[ "$TERM" = cygwin ]] && result=0 128 | [[ "$TERM" = foot ]] && result=0 129 | [[ "$TERM" = ghostty ]] && result=0 130 | [[ "$TERM" = kitty ]] && result=0 131 | [[ "$TERM" = putty* ]] && result=0 132 | [[ "$TERM" = screen* ]] && result=0 133 | [[ "$TERM" = tmux* ]] && result=0 134 | [[ "$TERM" = xterm* ]] && result=0 135 | 136 | export _axzsh_is_modern_terminal_cache=$result 137 | return $result 138 | } 139 | 140 | # Test for "dumb" terminal 141 | function axzsh_is_dumb_terminal { 142 | [[ -z "$TERM" ]] && return 0 143 | axzsh_is_modern_terminal && return 1 144 | [[ "$TERM" = dumb* ]] && return 0 145 | [[ "$TERM" = "vt52" ]] && return 0 146 | return 1 147 | } 148 | 149 | # Resize terminal window (when possible) 150 | function axzsh_resize_terminal { 151 | printf '\e[8;%d;%dt' "$2" "$1" 152 | } 153 | 154 | # Set terminal title 155 | 156 | # Set terminal "hardstatus" and "icon title" 157 | function axzsh_terminal_set_icon_title { 158 | [[ "$TERM" == "screen"* ]] && printf '\ek%s\e\\' "$1" 159 | printf '\e]1;%s\a' "$1" 160 | } 161 | 162 | # Set terminal window title 163 | function axzsh_terminal_set_window_title { 164 | printf '\e]2;%s\a' "$1" 165 | } 166 | 167 | # Update terminal titles before echoing the shell prompt 168 | function axzsh_terminal_title_precmd { 169 | axzsh_is_modern_terminal || return 170 | axzsh_terminal_set_window_title '' 171 | if [[ "$TERM_PROGRAM" == "Apple_Terminal" && "$TERM" != "screen"* ]]; then 172 | axzsh_terminal_set_icon_title "$LOGNAME@$SHORT_HOST" 173 | # Update CWD in Terminal.app 174 | local url=$(echo "file://$HOST$PWD" | sed -e 's| |%20|g') 175 | printf '\e]7;%s\a' "$url" 176 | else 177 | axzsh_terminal_set_icon_title "$LOGNAME@$SHORT_HOST:$PWD" 178 | fi 179 | } 180 | 181 | precmd_functions+=(axzsh_terminal_title_precmd) 182 | 183 | # Reset the terminal to "sane defaults" before executing a command 184 | function axzsh_terminal_reset_prexec { 185 | # Reset colors. Some prompt commands fail to do this on their own on 186 | # some terminals ... so let's play it safe! 187 | print -Pn -- "$FX[reset]" 188 | } 189 | 190 | # Update terminal titles before executing a command 191 | function axzsh_terminal_title_preexec { 192 | axzsh_is_modern_terminal || return 193 | 194 | local cmd="${1[(w)1]}" 195 | local remote="" 196 | 197 | case "$cmd" in 198 | "mosh"*|"root"*|"ssh"*|"telnet"*) 199 | remote=1 200 | ;; 201 | esac 202 | if [[ "$TERM_PROGRAM" == "Apple_Terminal" ]]; then 203 | # Apple Terminal.app ... 204 | if [[ -n "$remote" ]]; then 205 | # Reset CWD for remote commands 206 | printf '\e]7;%s\a' '' 207 | fi 208 | fi 209 | 210 | if [[ -n "$cmd" ]]; then 211 | # Add the command to the title 212 | TITLE_ADD=" – $cmd" 213 | fi 214 | 215 | if [[ -z "$remote" ]]; then 216 | axzsh_terminal_set_icon_title "$LOGNAME@$SHORT_HOST$TITLE_ADD" 217 | else 218 | axzsh_terminal_set_icon_title "$1" 219 | fi 220 | } 221 | 222 | preexec_functions+=(axzsh_terminal_reset_prexec axzsh_terminal_title_preexec) 223 | 224 | alias axttyinfo="zsh \"\$AXZSH/bin/axttyinfo\"" 225 | 226 | # "Dumb" terminals most likely have no color or style support. So stop here! 227 | if axzsh_is_dumb_terminal; then 228 | # But clean up a bit! 229 | unset CLICOLOR TERM_COLORS 230 | return 0 231 | fi 232 | 233 | # Colors 234 | # See , for example. 235 | 236 | autoload -Uz colors 237 | colors 238 | 239 | if axzsh_is_modern_terminal; then 240 | fg[default]="\e[39m" 241 | bg[default]="\e[49m" 242 | else 243 | fg[default]="\e[37m" 244 | bg[default]="\e[47m" 245 | fi 246 | 247 | # Try to detect the number of supported colors and store it in TERM_COLORS: 248 | # first by querying the "termcap" database, and if this does not work, some 249 | # hardcoded defaults. 250 | TERM_COLORS=$(tput colors 2>/dev/null) 251 | if [[ -z "$TERM_COLORS" ]]; then 252 | case "$TERM" in 253 | *-256color|xterm-ghostty|xterm-kitty) 254 | TERM_COLORS=256 ;; 255 | linux) 256 | TERM_COLORS=8 ;; 257 | *) 258 | # Assume 16 colors by default ... 259 | TERM_COLORS=16 260 | esac 261 | fi 262 | export TERM_COLORS 263 | 264 | # Set "CLICOLOR" when there are at least 4 colors available. And try to set 265 | # CLICOLOR to a sane value, too: 266 | if [[ "${TERM_COLORS:-0}" -ge 4 ]]; then 267 | # At least 4 colors ... 268 | export CLICOLOR=1 269 | if [[ "${TERM_COLORS:-0}" -lt 256 ]]; then 270 | COLORTERM="yes" 271 | else 272 | [[ -z "$COLORTERM" || "$COLORTERM" = "no" ]] && COLORTERM="yes" 273 | fi 274 | export COLORTERM 275 | else 276 | # Less than 4 colors ("no colors"): 277 | unset CLICOLOR 278 | unset COLORTERM 279 | fi 280 | 281 | # Foreground (FG) and background (BG) colors. 282 | typeset -Ag FG BG 283 | if [[ $TERM_COLORS -gt 16 ]]; then 284 | for color in {000..$((TERM_COLORS-1))}; do 285 | FG[$color]="%{\e[38;5;${color}m%}" 286 | BG[$color]="%{\e[48;5;${color}m%}" 287 | done 288 | elif [[ $TERM_COLORS -gt 0 ]]; then 289 | typeset -i c 290 | for color in {000..$((TERM_COLORS-1))}; do 291 | c=$color 292 | if [[ $c -ge 8 ]]; then 293 | c=$c-8 294 | p="1;" 295 | fi 296 | FG[$color]="%{\e[${p}3${c}m%}" 297 | BG[$color]="%{\e[${p}4${c}m%}" 298 | done 299 | unset c p 300 | fi 301 | 302 | # Text effects (FX) 303 | # See , for example. 304 | 305 | typeset -Ag FX 306 | FX=( 307 | reset "%{\e[0m%}" 308 | bold "%{\e[1m%}" no-bold "%{\e[22m%}" 309 | dim "%{\e[2m%}" no-dim "%{\e[22m%}" 310 | italic "%{\e[3m%}" no-italic "%{\e[23m%}" 311 | underline "%{\e[4m%}" no-underline "%{\e[24m%}" 312 | blink "%{\e[5m%}" no-blink "%{\e[25m%}" 313 | reverse "%{\e[7m%}" no-reverse "%{\e[27m%}" 314 | ) 315 | 316 | # NOTE for FG, BG and FX arrays, and spectrum_ls() and spectrum_bls() functions: 317 | # Based on a script to make using 256 colors in zsh less painful, written by 318 | # P.C. Shyamshankar . 319 | # Copied from OhMyZsh https://github.com/robbyrussell/oh-my-zsh/blob/master/lib/spectrum.zsh 320 | # which was copied from https://github.com/sykora/etc/blob/master/zsh/functions/spectrum/ :-) 321 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # AX-ZSH: Alex' Modular ZSH Configuration 2 | 3 | [AX-ZSH] is a modular configuration system for the Z shell ([ZSH]). 4 | It provides sane defaults and is extendable by plugins. 5 | 6 | AX-ZSH integrates well with [Powerlevel10k] and other extensions, even plugins 7 | of [OhMyZsh], see [below](#integration-with-other-projects). And it uses a 8 | *cache* and supports the Powerlevel10k *instant prompt* feature to speed up ZSH 9 | startup times, even when using multiple plugins. 10 | 11 | The homepage of [AX-ZSH] can be found at [GitHub]: 12 | . 13 | 14 | ## Installation 15 | 16 | Prerequisites: 17 | 18 | * [ZSH] – obviously ;-) 19 | * [Git] (optional but recommended!) 20 | 21 | Installing AX-ZSH is a two-step process: 22 | 23 | 1. Clone or copy the source files into the `~/.axzsh` directory, 24 | 2. Run the `~/.axzsh/install.sh` script. 25 | 26 | The `install.sh` script creates symbolic links for `~/.zprofile`, `~/.zshrc`, 27 | `~/.zlogin`, and `~/.zlogout`. But don't worry, preexisting files are backed 28 | up. 29 | 30 | *Note:* The installation is per-user and only changes/installs files into the 31 | home directory of the current user (`~`). AX-ZSH is not meant to be installed 32 | globally for all users on a system at once, and you don't need to become "root" 33 | or any other user with elevated privileges! 34 | 35 | ### Installation using Git 36 | 37 | The preferred method for installing AX-ZSH is using [Git] to clone the 38 | repository directly into the `~/.axzsh` directory and to call the `install.sh` 39 | script from this location: 40 | 41 | ```sh 42 | git clone https://github.com/alexbarton/ax-zsh.git ~/.axzsh 43 | ~/.axzsh/install.sh 44 | ``` 45 | 46 | On Debian, you can fulfil the prerequisites like this: 47 | 48 | ```sh 49 | apt update && apt install --no-install-recommends \ 50 | ca-certificates git zsh 51 | ``` 52 | 53 | ### Installation without Git 54 | 55 | *Note:* If you do not use [Git] to install AX-ZSH, you will not be able to 56 | upgrade AX-ZSH itself afterwards with the integrated `axzsh upgrade` command! 57 | Therefore this method is *not recommended* for normal use! 58 | 59 | ```sh 60 | curl -Lo ax-zsh-master.zip https://github.com/alexbarton/ax-zsh/archive/refs/heads/master.zip 61 | unzip ax-zsh-master.zip 62 | mv ax-zsh-master ~/.axzsh 63 | ~/.axzsh/install.sh 64 | ``` 65 | 66 | On Debian, you can fulfil the prerequisites like this: 67 | 68 | ```sh 69 | apt update && apt install --no-install-recommends \ 70 | ca-certificates curl unzip zsh 71 | ``` 72 | 73 | ### Post-Installation Tasks 74 | 75 | After installing AX-ZSH, using Git or via an archive file, you should close all 76 | running ZSH sessions and restart them to activate AX-ZSH. And maybe you want to 77 | change your default shell to ZSH if you haven't already? 78 | 79 | For example like this: 80 | 81 | ```sh 82 | # Set new default shell 83 | chsh -s $(command -v zsh) 84 | 85 | # Replace running shell with a ZSH login shell 86 | exec $(command -v zsh) -l 87 | ``` 88 | 89 | ## Upgrade 90 | 91 | When you used [Git] to install AX-ZSH (and/or plugins), you can use the 92 | `axzshctl` command to upgrade AX-ZSH itself and external plugins like this: 93 | 94 | ```sh 95 | axzshctl upgrade 96 | ``` 97 | 98 | ## Usage 99 | 100 | AX-ZSH comes with a hopefully sane default configuration and can be extended 101 | using plugins. Different types of plugins are supported: 102 | 103 | * Plugins shipped with AX-ZSH. 104 | * Themes shipped with AX-ZSH. 105 | * 3rd-party plugins: 106 | * installed manually into `$AXZSH/custom_plugins` 107 | * stand-alone plugins stored on GitHub 108 | * plugins of OhMyZsh from its GitHub repository 109 | * 3rd-party themes: 110 | * installed manually into `$AXZSH/custom_themes` 111 | * some stand-alone themes stored on GitHub 112 | 113 | ### Configuration of other applications & tools 114 | 115 | Some tools, notably remote access tools like ssh(1) and screen-multiplexers 116 | like screen(1) or tmux(1), can be configured to better support AX-ZSH. For 117 | example, AX-ZSH tries to adjust itself for a sane terminal and locale setup, 118 | which in turn requires some information (mostly environment variables) being 119 | available and passed to the ZSH running AX-ZSH on the (target) system. 120 | 121 | #### OpenSSH Client 122 | 123 | If you are using the OpenSSH client, the following configuration in your 124 | `~/.ssh/config` file is very useful: 125 | 126 | ```ini 127 | # Some defaults. 128 | # Note: Place this block LAST to not override some other settings, if any, as 129 | # OpenSSH uses the first(!) match it finds! 130 | Host * 131 | # Pass some environment variables to the remote host to allow the remote 132 | # system to get a better idea of your used and desired working environment: 133 | SendEnv COLORTERM LANG LC_* TERM_* TZ 134 | 135 | # Don't hash host names in the ~/.ssh/known_hosts file, so that ZSH 136 | # compeltion functions can detect helpful host names to complete. 137 | # Note: This has an "security impact". It is on YOU to check what your 138 | # security requirements are! 139 | HashKnownHosts no 140 | ``` 141 | 142 | #### OpenSSH Server 143 | 144 | On an OpenSSH server, the following configuration in one of its configuration 145 | files (for example, a good place is in a drop-in configuration file like 146 | `/etc/ssh/sshd_config.d/local.conf`) allows SSH clients to pass some 147 | environment variables to the server: 148 | 149 | ```init 150 | # Allow SSH client to pass some "safe" environment variables to the server: 151 | AcceptEnv COLORTERM LANG LC_* TERM_* TZ 152 | ``` 153 | 154 | This is required for the SSH client configuration shown above to work. 155 | 156 | Don't forget to have `sshd` reload its configuration, for example using 157 | `systemctl reload ssh.service` or `pkill -o -HUP sshd`, or whatever is used on 158 | your operating system. 159 | 160 | ### Check whether all locally available "useful" plug-ins are activated 161 | 162 | Most plugins can be enabled even when the commands they work with aren't 163 | available and won't do any harm. But to keep ZSH startup times low, you should 164 | only enable plugins that are useable on your local system and which you actually 165 | plan to use. 166 | 167 | You can use the following command to let AX-ZSH scan the status of all locally 168 | available plugins: 169 | 170 | ```sh 171 | axzshctl check-plugins 172 | ``` 173 | 174 | It will summarize the status of all enabled plugins, and suggest to enable 175 | plugins which seem to make sense on the system and to disable enabled plugins 176 | that seem not to be supported (for example because of missing dependencies). 177 | 178 | ### List enabled plugins 179 | 180 | Run the following command to list all currently enabled plugins: 181 | 182 | ```sh 183 | axzshctl list-enabled 184 | ``` 185 | 186 | ### Enable plugins 187 | 188 | AX-ZSH comes with a sane "core ZSH configuration", but it can show its true 189 | strengths when enabling additional plugins for additional tools and commands 190 | that are available on your system and you want to use. 191 | 192 | Different types of plugins are supported (see the introduction to the section 193 | "*usage*" above) which are differentiated by their identifier: 194 | 195 | * ``: locally available plugin, either bundled with AX-ZSH itself, or 196 | installed manually (see below). 197 | * `/`: stand-alone [GitHub] repository. 198 | * `@ohmyzsh/`: [OhMyZsh] plugin from the OhMyZsh GitHub 199 | repository (see ). 200 | 201 | You can enable one or more plugins like this: 202 | 203 | ```sh 204 | axzshctl enable-plugin [ […]] 205 | ``` 206 | 207 | *Hint:* *Tab-completion* works for sub-commands and already locally available 208 | plugin names! 209 | 210 | Some examples: 211 | 212 | ```sh 213 | # Enable some plugins bundled with AX-ZSH: 214 | axzshctl enable-plugin editor_select git ssh_autoadd 215 | 216 | # Enable the Powerlevel10k "theme plugin" from GitHub, see 217 | # : 218 | axzshctl enable-plugin romkatv/powerlevel10k 219 | 220 | # Enable the "fast-syntax-highlighting" plugin from GitHub, see 221 | # : 222 | axzshctl enable-plugin zdharma-continuum/fast-syntax-highlighting 223 | 224 | # Enable the Git and tmux plugins of OhMyZsh: 225 | axzshctl enable-plugin @ohmyzsh/git @ohmyzsh/tmux 226 | ``` 227 | 228 | #### Custom local plugins 229 | 230 | You can link custom plugins stored in arbitrary directories using `axzshctl` 231 | by specifying the complete path name. Or you can place additional plugins into 232 | the `$AXZSH/custom_plugins` folder which is searched by the `axzshctl` tool 233 | by default. 234 | 235 | In addition you can set the `AXZSH_PLUGIN_D` variable (and `ZSH_CUSTOM` like 236 | [OhMyZsh]) to specify additional plugin search directories. 237 | 238 | ### Disable plugins 239 | 240 | Run the following command to disable a currently enabled plugin: 241 | 242 | ```sh 243 | axzshctl disable-plugin [ […]] 244 | ``` 245 | 246 | *Hint:* *Tab-completion* works for sub-commands and plugin names! 247 | 248 | ### Update plugin cache 249 | 250 | AX-ZSH uses a "plugin cache" to speedup ZSH start times. This cache is 251 | automatically updated when using the `axzshctl` sub-commands, for example when 252 | enabling or disabling plugins, or when upgrading the AX-ZSH installation and 253 | all plugins. 254 | 255 | But you *have to* update the cache when manually installing plugins or during 256 | development of a own local plugin after updating its code! 257 | 258 | Run the following command to update the AX-ZSH cache: 259 | 260 | ```sh 261 | axzshctl update-caches 262 | ``` 263 | 264 | ### Other `axzshctl` sub-commands 265 | 266 | Please run `axzshctl --help` to get a full list of a available sub-commands: 267 | 268 | ```sh 269 | axzshctl --help 270 | ``` 271 | 272 | ## Integration with other projects 273 | 274 | ### Powerlevel10k 275 | 276 | AX-ZSH supports [Powerlevel10k] out of the box, you just have to install it as a 277 | plugin: 278 | 279 | ```sh 280 | axzshctl enable-plugin romkatv/powerlevel10k 281 | ``` 282 | 283 | *Hint:* Once the Powerlevel10k plugin theme is installed, you can use the 284 | regular `axzshctl set-theme` command to enable it, like for any other installed 285 | theme: `axzshctl set-theme powerlevel10k`. 286 | 287 | ## AX-ZSH & local ZSH configuration 288 | 289 | Don't modify `~/.zprofile`, `~/.zshrc`, `~/.zlogin`, or `~/.zlogout`! These 290 | are links to "AX-ZSH"-private files that can become overwritten when updating. 291 | 292 | You can use the following files for local ZSH configuration: 293 | 294 | 1. AX-ZSH doesn't use `~/.zshenv` in any way. So you can use this file for your 295 | own purposes (for example, to set up some environment variables that AX-ZSH 296 | relies on). 297 | 298 | 2. AX-ZSH reads the optional files `~/.zprofile.local`, `~/.zshrc.local`, 299 | `~/.zlogin.local`, and `~/.zlogout.local` after its own core initialization 300 | files when present. 301 | 302 | ## Environment variables 303 | 304 | Expected to be already set: 305 | 306 | * `HOME` 307 | * `LOGNAME` 308 | 309 | Validated and/or set up by core plugins: 310 | 311 | * `AXZSH` – AX-ZSH installation directory 312 | * `HOST` 313 | * `HOSTNAME` (same as HOST, deprecated) 314 | * `LOCAL_HOME` 315 | * `PS1` 316 | * `SHORT_HOST` 317 | * `TMPDIR` (set and always ends with a "/") 318 | * `XDG_CACHE_HOME` 319 | * `XDG_RUNTIME_DIR` 320 | * `ZSH_CACHE_DIR` 321 | 322 | ___ 323 | [AX-ZSH]: "AX-ZSH Homepage" 324 | [Git]: "Git Homepage" 325 | [GitHub]: "GitHub Homepage" 326 | [OhMyZsh]: "OhMyZsh Homepage" 327 | [Powerlevel10k]: "Powerlevel10k Homepage" 328 | [ZSH]: "ZSH Homepage" 329 | 330 | [AX-ZSH] Copyright (c) 2015-2025 Alexander Barton 331 | -------------------------------------------------------------------------------- /bin/axzshctl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env zsh 2 | # 3 | # AX-ZSH: Alex' Modular ZSH Configuration 4 | # Copyright (c) 2015-2025 Alexander Barton 5 | # 6 | 7 | # Embedded ax-common compatibility functions ... 8 | function ax_msg { 9 | case "$1" in 10 | "0") c="32"; ;; 11 | "1") c="33"; ;; 12 | "2") c="31"; ;; 13 | "-") c="1"; ;; 14 | *) c="0"; ;; 15 | esac 16 | shift 17 | printf "\e[${c}m%s\e[0m\n" "$@" 18 | } 19 | function ax_error { 20 | ax_msg 2 "$@" >&2 21 | } 22 | 23 | function Version { 24 | echo "ax-zsh -- Modular configuration system for the Z shell (ZSH)" 25 | echo "Copyright (c) 2015-2025 Alexander Barton ." 26 | echo "Licensed under the terms of the MIT license, see LICENSE.md for details." 27 | echo "Homepage: " 28 | echo 29 | echo "Installation prefix: $AXZSH" 30 | echo -n "Version: " 31 | if [[ -d "$AXZSH/.git" && -n "$commands[git]" ]]; then 32 | echo -n "Git Commit-ID " 33 | ( cd "$AXZSH" && git describe --always ) 34 | else 35 | echo "unknown" 36 | fi 37 | echo -n "Active theme: " 38 | if [[ -n "$AXZSH_THEME" ]]; then 39 | echo "${AXZSH_THEME:A:t:r}" 40 | else 41 | echo "unknown" 42 | fi 43 | echo 44 | exit 0 45 | } 46 | 47 | function Usage { 48 | echo "Usage: $NAME [...]" 49 | echo 50 | echo " enable" 51 | echo " Enable AX-ZSH altogether." 52 | echo " disable" 53 | echo " Disable AX-ZSH altogether." 54 | echo 55 | echo " enable-plugin [ [...]]" 56 | echo " Enable plugin(s)." 57 | echo " disable-plugin [ [...]]" 58 | echo " Disable plugin(s)." 59 | echo " list-enabled" 60 | echo " List enabled plugins." 61 | echo " plugin-help" 62 | echo " Show help text for a plugin (when provided by the plugin)." 63 | echo 64 | echo " reset-plugins" 65 | echo " Reset active plugins to the default set." 66 | echo " enable-default-plugins" 67 | echo " Enable all default plugins." 68 | echo " check-plugins" 69 | echo " Detect plugins which are \"useful\" on this system." 70 | echo 71 | echo " set-theme {|-}" 72 | echo " Set active theme to , or to the default." 73 | echo 74 | echo " upgrade" 75 | echo " Upgrade AX-ZSH installation (requires Git)." 76 | echo " update-caches" 77 | echo " Force rebuild of all cache files." 78 | echo 79 | echo " help" 80 | echo " Show this help text." 81 | echo " version" 82 | echo " Show version and setup information." 83 | echo 84 | exit 0 85 | } 86 | 87 | function UpdatePluginCache { 88 | [[ -r "$AXZSH/cache" ]] || return 0 89 | 90 | [[ "$1" = "-v" ]] && ax_msg - "Invalidating & updating caches ..." 91 | 92 | if [[ -d "$ZSH_CACHE_DIR" ]]; then 93 | [[ "$1" = "-v" ]] && echo "Removing ZSH cache folder ..." 94 | rm -fr "$ZSH_CACHE_DIR" 95 | fi 96 | 97 | [[ "$1" = "-v" ]] && echo "Removing AX-ZSH cache files ..." 98 | rm -rf \ 99 | $AXZSH/cache/ax-io.cache \ 100 | $AXZSH/cache/zlogin.cache \ 101 | $AXZSH/cache/zlogout.cache \ 102 | $AXZSH/cache/zprofile.cache \ 103 | $AXZSH/cache/zshrc.cache \ 104 | || return 1 105 | 106 | echo "Regenerating AX-ZSH cache ..." 107 | [[ -z "$AXZSH_DEBUG" ]] \ 108 | && AXZSH_PLUGIN_CHECK=1 zsh -ilc '' >/dev/null \ 109 | || AXZSH_PLUGIN_CHECK=1 zsh -ilc '' 110 | } 111 | 112 | function NormalizedPluginName { 113 | if [[ "$1" =~ "^@?[[:alnum:]-]+/[[:alnum:]_.-]+$" ]]; then 114 | echo "${1:gs/\//#}" 115 | elif [[ "$1" =~ "/" ]]; then 116 | echo "${1:t}" 117 | else 118 | echo "$1" 119 | fi 120 | } 121 | 122 | function EnableAXZSH { 123 | for f (~/.zlogin ~/.zlogout ~/.zprofile ~/.zshrc); do 124 | ln -s "$AXZSH/ax.zsh" "$f" \ 125 | || ax_error "Failed to create symbolic link for \"$f\"!" 126 | done 127 | if [[ -z "$AXZSH_FPATH" ]]; then 128 | echo "AX-ZSH was enabled. Now you should restart your shell, for example like this:" 129 | echo "$ exec -l \"\$SHELL\"" 130 | fi 131 | } 132 | 133 | function DisableAXZSH { 134 | for f (~/.zlogin ~/.zlogout ~/.zprofile ~/.zshrc); do 135 | if [[ -h "$f" ]]; then 136 | rm "$f" || ax_msg 2 "Failed to remove \"$f\"!" 137 | elif [[ -e "$f" ]]; then 138 | ax_error "Error: Not removing \"$f\", it is not a symbolic link!" 139 | else 140 | ax_msg 1 "Warning: \"$f\" already does not exist. Ok." 141 | fi 142 | done 143 | } 144 | 145 | function EnablePlugin { 146 | local plugin=$(NormalizedPluginName "$1") 147 | local dir="$AXZSH/active_plugins" 148 | local name="$plugin" 149 | 150 | if [[ -h "$dir/$plugin" ]]; then 151 | ax_msg 1 "Plugin \"$1\" already active!" 152 | return 1 153 | fi 154 | 155 | if [[ "$1" =~ "^@[[:alnum:]-]+/[[:alnum:]_.+-]+$" ]]; then 156 | # GitHub plugin repository (like OhMyZsh) 157 | local repo="${1##@}" 158 | repo="${repo%/*}" 159 | mkdir -p "$AXZSH/repos/@$repo" 160 | if [[ ! -d "$AXZSH/repos/@$repo/plugins" ]]; then 161 | ax_msg - "Cloning \"$repo\" from GitHub ..." 162 | git clone --depth=1 --recurse-submodules --single-branch "https://github.com/$repo/$repo.git" \ 163 | "$AXZSH/repos/@$repo" \ 164 | || ax_error "Failed to clone \"$repo\" repository!" 165 | fi 166 | plugin="@$repo/plugins/${1#*/}" 167 | echo "Trying to enable \"$1\" ..." 168 | elif [[ "$1" =~ "^[[:alnum:]-]+/[[:alnum:]_.-]+$" ]]; then 169 | # GitHub plugin 170 | mkdir -p "$AXZSH/repos" 171 | if [[ ! -e "$AXZSH/repos/$plugin" ]]; then 172 | ax_msg - "Cloning module from GitHub ..." 173 | git clone --depth=1 --recurse-submodules --single-branch "https://github.com/$1.git" \ 174 | "$AXZSH/repos/$plugin" \ 175 | || ax_error "Failed to clone repository!" 176 | fi 177 | # Try to enable a theme in this "foreign module", but ignore 178 | # errors: we don't know if this module provides a theme or is 179 | # a "regular" plugin ... 180 | if SetTheme "$plugin" 2>/dev/null; then 181 | ax_msg 0 "Module \"$1\" was enabled as theme \"${plugin#*#}\"." 182 | # A theme was enabled: So assume that this is a theme 183 | # and don't enable it as plugin. 184 | return 0 185 | fi 186 | echo "Trying to enable \"$1\" as plugin ..." 187 | elif ! [[ "$1" =~ "^[[:alnum:]_.-]+$" ]]; then 188 | ax_error "Invalid plugin name!" 189 | return 1 190 | fi 191 | 192 | for dname ( 193 | "$plugin:A" 194 | "$AXZSH_PLUGIN_D/$plugin" 195 | "$ZSH_CUSTOM/$plugin" 196 | "$AXZSH/custom_plugins/$plugin" 197 | "$AXZSH/repos/$plugin" 198 | "$AXZSH/plugins/$plugin" 199 | "$AXZSH/default_plugins/$plugin" 200 | "$AXZSH/core/$plugin" 201 | ); do 202 | [[ ! -d "$dname" ]] && continue 203 | mkdir -p "$dir" 204 | if ! ( 205 | cd "$dir" || exit 9 206 | ln -s "$dname" "$PWD/$name" 207 | ); then 208 | ax_error "Failed to create link!" 209 | return 1 210 | fi 211 | ax_msg 0 "Plugin \"$1\" enabled." 212 | return 0 213 | done 214 | 215 | ax_error "Plugin \"$1\" not found!" 216 | return 1 217 | } 218 | 219 | function DisablePlugin { 220 | local plugin=$(NormalizedPluginName "$1") 221 | local dir="$AXZSH/active_plugins" 222 | local r=-1 223 | 224 | # Active theme? 225 | if [[ $(readlink "$AXZSH/active_theme") = "$AXZSH/repos/$plugin/"* ]]; then 226 | rm "$AXZSH/active_theme"; r=$? 227 | fi 228 | 229 | # Active plugin? 230 | if [[ -h "$dir/$plugin" ]]; then 231 | rm "$dir/$plugin"; r=$? 232 | fi 233 | 234 | if [[ $r -eq -1 ]]; then 235 | ax_msg 1 "Plugin \"$1\" not active, nothing to do?" 236 | r=1 237 | fi 238 | 239 | if [[ "$plugin" = *"#"* ]]; then 240 | # Name matches a cloned repository, try to clean up! 241 | echo "Cleaning up cloned repository ..." 242 | rm -fr "$AXZSH/repos/$plugin" 243 | fi 244 | 245 | return $r 246 | } 247 | 248 | function ListEnabledPlugins { 249 | for plugin ($AXZSH/active_plugins/*(N)); do 250 | print ${plugin:t:s/#/\//} 251 | done 252 | return 0 253 | } 254 | 255 | function PluginHelp { 256 | local plugin=$(NormalizedPluginName "$1") 257 | local repo_plugin=$(echo "$plugin" | sed -e 's|#|/plugins/|') 258 | local plugin_found= 259 | 260 | for plugin_d ( 261 | "$plugin:A" 262 | "$AXZSH/active_plugins/$plugin" 263 | "$AXZSH/active_plugins/$repo_plugin" 264 | "$AXZSH_PLUGIN_D/$plugin" 265 | "$ZSH_CUSTOM/$plugin" 266 | "$AXZSH/custom_plugins/$plugin" 267 | "$AXZSH/repos/$plugin" 268 | "$AXZSH/repos/$repo_plugin" 269 | "$AXZSH/plugins/$plugin" 270 | "$AXZSH/default_plugins/$plugin" 271 | "$AXZSH/core/$plugin" 272 | ); do 273 | [[ -e "$plugin_d" ]] && plugin_found=1 274 | [[ -r "$plugin_d/README.md" ]] || continue 275 | less "$plugin_d/README.md" 276 | return 0 277 | done 278 | [[ -n "$plugin_found" ]] \ 279 | && echo "Plugin \"$1\" found, but no help available!" >&2 \ 280 | || echo "Plugin \"$1\" not found!" >&2 281 | return 1 282 | } 283 | 284 | function ResetPlugins { 285 | local dir="$AXZSH/active_plugins" 286 | local r1=0, r2=0 287 | 288 | if [[ -e "$dir" ]]; then 289 | ax_msg - "Removing all symbolic links in $dir ..." 290 | find "$dir" -type l -print -delete; r1=$? 291 | fi 292 | 293 | ax_msg - "Removing all external repositories in \"$AXZSH/repos\" ..." 294 | rm -fr "$AXZSH/repos"; r2=$? 295 | 296 | [[ $r1 == 0 && $r2 == 0 ]] && return 0 || return 1 297 | } 298 | 299 | function EnableDefaultPlugins { 300 | local dir="$AXZSH/active_plugins" 301 | 302 | ax_msg - "Activating default plugins ..." 303 | mkdir -p "$dir" 304 | ( 305 | cd "$dir" || exit 9 306 | ln -sf "$AXZSH/default_plugins/"* "$PWD" 307 | ) 308 | return $? 309 | } 310 | 311 | function SetTheme { 312 | local link_name="$AXZSH/active_theme" 313 | 314 | # --- Powerlevel10k --- 315 | # Remove "instant prompt" configuration, if any ... 316 | rm -f "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" 317 | 318 | if [[ "$1" = "-" ]]; then 319 | rm -f "$link_name" || return 1 320 | ax_msg 0 "Theme settings have been reset." 321 | return 0 322 | fi 323 | 324 | if [[ -r "$1" ]]; then 325 | theme="$1" 326 | elif [[ -r "$AXZSH/custom_themes/$1.axzshtheme" ]]; then 327 | theme="$AXZSH/custom_themes/$1.axzshtheme" 328 | elif [[ -r "$AXZSH/themes/$1.axzshtheme" ]]; then 329 | theme="$AXZSH/themes/$1.axzshtheme" 330 | else 331 | # Look for theme in specific remote module: 332 | for f ( 333 | "$AXZSH/repos/$1/"*.axzshtheme(N[1]) 334 | "$AXZSH/repos/$1/"*.zsh-theme(N[1]) 335 | ); do 336 | if [[ -r "$f" ]]; then 337 | theme="$f" 338 | break 339 | fi 340 | done 341 | 342 | # Look for theme inside of installed plugins: 343 | for dname ( 344 | "$AXZSH/custom_themes" 345 | "$AXZSH/custom_plugins/"*(N) 346 | "$AXZSH/repos/"*(N) 347 | ); do 348 | if [[ -r "$dname/$1.axzshtheme" ]]; then 349 | theme="$dname/$1.axzshtheme" 350 | break 351 | elif [[ -r "$dname/$1.zsh-theme" ]]; then 352 | theme="$dname/$1.zsh-theme" 353 | break 354 | fi 355 | done 356 | 357 | if [[ -z "$theme" ]]; then 358 | ax_error "Theme \"$1\" not found!" 359 | return 1 360 | fi 361 | fi 362 | ln -fs "$theme" "$link_name" || return 1 363 | return $? 364 | } 365 | 366 | function UpgradeAXZSH { 367 | if [[ $+commands[git] -eq 0 ]]; then 368 | ax_error "The git(1) command is not available!" 369 | return 1 370 | fi 371 | if [[ ! -d "$AXZSH/.git" ]]; then 372 | ax_error "AX-ZSH seems not to be installed using Git. Can't upgrade!" 373 | return 1 374 | fi 375 | 376 | ax_msg - "Upgrading AX-ZSH in \"$AXZSH\" using git(1) ..." 377 | ( 378 | set -e 379 | cd "$AXZSH" 380 | git pull --ff-only || ax_error "Git pull failed!" 381 | git log --pretty=format:"%C(yellow)%h %C(blue)%ar %C(green)%an %Creset%s" ORIG_HEAD.. 382 | ) 383 | } 384 | 385 | function UpgradeForeignPlugins { 386 | if [[ $+commands[git] -eq 0 ]]; then 387 | ax_error "The git(1) command is not available!" 388 | return 1 389 | fi 390 | 391 | for dir ($AXZSH/repos/*(N)); do 392 | name=${dir:t:s/#/\//} 393 | if [[ -d "$dir/.git" ]]; then 394 | ax_msg - "Upgrading \"$name\" [git] ..." 395 | ( 396 | set -e 397 | cd "$dir" 398 | git pull --ff-only || ax_error "Git pull failed!" 399 | git log --pretty=format:"%C(yellow)%h %C(blue)%ar %C(green)%an %Creset%s" ORIG_HEAD.. 400 | ) 401 | else 402 | ax_error "Unknown repository type!" 403 | fi 404 | done 405 | } 406 | 407 | function CheckPlugins { 408 | missing_plugins=() 409 | invalid_plugins=() 410 | 411 | # Building cache file for all zshrc core files: 412 | if ! T=$(mktemp); then 413 | ax_error "Failed to create temporary file!" 414 | return 1 415 | fi 416 | for p in $AXZSH/core/*/*.zshrc; do 417 | [[ "$(basename "$p")" == "01_zprofile.zshrc" ]] && continue 418 | printf "# BEGIN: %s\naxzsh_plugin_init()\n{\n" "$p" >>"$T" 419 | cat "$p" >>"$T" 420 | printf "}\naxzsh_plugin_init\n# END: %s\n\n" "$p" >>"$T" 421 | done 422 | 423 | ax_msg - "Checking plugins ..." 424 | for dir ($AXZSH/plugins/[a-z0-9]*(N)); do 425 | plugin=${dir:t} 426 | 427 | # Test if plugin is already enabled 428 | if [[ -e "$AXZSH/active_plugins/$plugin" ]]; then 429 | printf ' \e[1;32m+\e[m "\e[1m%s\e[m" ... ' "${plugin}" 430 | enabled=1 431 | else 432 | printf ' \e[1;31m-\e[m "%s" ... ' "${plugin}" 433 | unset enabled 434 | fi 435 | 436 | # Test plugin ... 437 | new_plugin="" 438 | for script ($AXZSH/plugins/$plugin/$plugin.{zshrc,zprofile,ax-io}); do 439 | [[ -r "$script" ]] || continue 440 | ( 441 | AXZSH_PLUGIN_CHECK=1 442 | source "$T" 443 | axzsh_plugin_fnc() { source "$script" } 444 | axzsh_plugin_fnc 445 | ); r=$? 446 | [[ $r -eq 0 ]] && new_plugin=$plugin 447 | break 448 | done 449 | if [[ -n "$new_plugin" ]]; then 450 | detected_plugins+=($new_plugin) 451 | [[ -n "$enabled" ]] || missing_plugins+=($new_plugin) 452 | ax_msg 0 "OK." 453 | elif [[ $r -eq 91 ]]; then 454 | ax_msg 1 "ignored." 455 | elif [[ $r -eq 92 ]]; then 456 | ax_msg 1 "optional." 457 | else 458 | [[ -n "$enabled" ]] && invalid_plugins+=($plugin) 459 | ax_msg 2 "failed ($r)." 460 | fi 461 | done 462 | rm -f "$T" 463 | echo 464 | 465 | result=0 466 | if [[ -n "$missing_plugins" ]]; then 467 | ax_msg 1 "Run the following command to enable all missing plugins:" 468 | echo "$AXZSH/bin/axzshctl enable-plugin" $missing_plugins 469 | echo 470 | result=1 471 | else 472 | ax_msg 0 "All detected plugins are already enabled." 473 | fi 474 | 475 | if [[ -n "$invalid_plugins" ]]; then 476 | ax_msg 1 "Run the following command to disable all failed plugins:" 477 | echo "$AXZSH/bin/axzshctl disable-plugin" $invalid_plugins 478 | result=1 479 | else 480 | ax_msg 0 "No failed plugins are enabled." 481 | fi 482 | 483 | echo 484 | return $result 485 | } 486 | 487 | NAME="$0:t" 488 | 489 | [[ $# -gt 0 ]] || Usage 490 | 491 | if [[ -z "$AXZSH" || ! -r "$AXZSH/ax.zsh" ]]; then 492 | [[ -r "$HOME/.axzsh/ax.zsh" ]] && AXZSH="$HOME/.axzsh" 493 | if [[ ! -r "$AXZSH/ax.zsh" ]]; then 494 | ax_error "Oops, \"AXZSH\" is not set or invalid and can't be autodetected!" 495 | exit 3 496 | fi 497 | fi 498 | 499 | cmd="$1" 500 | shift 501 | 502 | case "$cmd" in 503 | "enable") 504 | [[ $# -eq 0 ]] || Usage 505 | EnableAXZSH 506 | ;; 507 | "disable") 508 | [[ $# -eq 0 ]] || Usage 509 | DisableAXZSH 510 | ;; 511 | "enable-plugin") 512 | [[ $# -gt 0 ]] || Usage 513 | for plugin in "$@"; do 514 | EnablePlugin "$plugin" 515 | done 516 | UpdatePluginCache 517 | ;; 518 | "disable-plugin") 519 | [[ $# -gt 0 ]] || Usage 520 | for plugin in "$@"; do 521 | DisablePlugin "$plugin" 522 | done 523 | UpdatePluginCache 524 | ;; 525 | "list-enabled") 526 | [[ $# -eq 0 ]] || Usage 527 | ListEnabledPlugins 528 | ;; 529 | "plugin-help") 530 | [[ $# -eq 1 ]] || Usage 531 | PluginHelp "$1" 532 | ;; 533 | "reset-plugins") 534 | [[ $# -eq 0 ]] || Usage 535 | ResetPlugins 536 | EnableDefaultPlugins 537 | UpdatePluginCache 538 | ;; 539 | "enable-default-plugins") 540 | [[ $# -eq 0 ]] || Usage 541 | EnableDefaultPlugins && UpdatePluginCache 542 | ;; 543 | "check-plugins") 544 | [[ $# -eq 0 ]] || Usage 545 | CheckPlugins 546 | ;; 547 | "set-theme") 548 | [[ $# -eq 1 ]] || Usage 549 | SetTheme "$1" 550 | ;; 551 | "upgrade") 552 | [[ $# -eq 0 ]] || Usage 553 | UpgradeAXZSH 554 | UpgradeForeignPlugins 555 | UpdatePluginCache 556 | ;; 557 | "update-caches") 558 | [[ $# -eq 0 ]] || Usage 559 | UpdatePluginCache -v 560 | ;; 561 | "--version"|"version") 562 | Version >&2 563 | ;; 564 | "--help"|"help") 565 | Usage >&2 566 | ;; 567 | *) 568 | ax_error "Invalid command \"$cmd\"!" 569 | ax_error "Try \"$0 --help\" for more information." 570 | exit 2 571 | esac 572 | --------------------------------------------------------------------------------