├── .codeclimate.yml ├── .github ├── FUNDING.yml ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── PULL_REQUEST_TEMPLATE.md ├── dependabot.yml └── workflows │ ├── awesomebot.yml │ └── mega-linter.yml ├── .gitignore ├── .pre-commit-config.yaml ├── .zsh-quickstart-local-plugins-example ├── Changes.md ├── Code_Of_Conduct.md ├── Contributing.md ├── LICENSE.txt ├── Readme.md └── zsh ├── .zgen-setup ├── .zsh_aliases ├── .zsh_functions ├── .zshrc └── .zshrc.d └── 001-load-mise-if-present /.codeclimate.yml: -------------------------------------------------------------------------------- 1 | --- 2 | version: "2" 3 | plugins: 4 | pep8: 5 | enabled: true 6 | duplication: 7 | enabled: true 8 | config: 9 | languages: 10 | - "python" 11 | fixme: 12 | enabled: true 13 | exclude_patterns: 14 | - config/engines.yml 15 | markdownlint: 16 | enabled: true 17 | checks: 18 | MD004: 19 | enabled: false 20 | MD013: 21 | enabled: false 22 | MD026: 23 | enabled: false 24 | MD029: 25 | enabled: false 26 | MD033: 27 | enabled: false 28 | shellcheck: 29 | enabled: true 30 | exclude_patterns: 31 | - .bundle/ 32 | - benchmarks/**/* 33 | - node_modules/**/* 34 | - bin/**/* 35 | - include/**/* 36 | - lib/**/* 37 | - License.md 38 | - spec/**/* 39 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: unixorn # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] 4 | patreon: unixorn # Replace with a single Patreon username 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: unixorn 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | otechie: # Replace with a single Otechie username 12 | custom: ['https://www.redbubble.com/people/unixorn/shop'] 13 | # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] 14 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: "[BUG]" 5 | labels: bug 6 | assignees: '' 7 | 8 | --- 9 | 10 | # Describe the bug 11 | 12 | A clear and concise description of what the bug is. 13 | 14 | ## To Reproduce 15 | 16 | Steps to reproduce the behavior: 17 | 18 | 1. Go to '...' 19 | 2. Click on '....' 20 | 3. Scroll down to '....' 21 | 4. See error 22 | 23 | ## Expected behavior 24 | 25 | A clear and concise description of what you expected to happen. 26 | 27 | ## Screenshots 28 | 29 | If applicable, add screenshots to help explain your problem. 30 | 31 | ## Desktop (please complete the following information): 32 | 33 | - OS/distro: [e.g. macOS, Debian, Ubuntu, Red Hat] 34 | - Version [e.g. 22] 35 | 36 | ## Additional context 37 | 38 | Add any other context about the problem here. 39 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: enhancement 6 | assignees: '' 7 | 8 | --- 9 | # Feature Request 10 | 11 | ## Is your feature request related to a problem? Please describe. 12 | 13 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 14 | 15 | ## Describe the solution you'd like 16 | 17 | A clear and concise description of what you want to happen. 18 | 19 | ## Describe alternatives you've considered 20 | 21 | A clear and concise description of any alternative solutions or features you've considered. 22 | 23 | ## Additional context 24 | 25 | Add any other context or screenshots about the feature request here. 26 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | # License Acceptance 2 | 3 | - [ ] This repository is Apache version 2.0 licensed (some scripts may have alternate licensing inline in their code) and by making this PR, I am contributing my changes to the repository under the terms of the Apache 2 license. 4 | 5 | 6 | 7 | ## Description 8 | 9 | 10 | 11 | ## Type of changes 12 | 13 | 14 | 15 | - [ ] A helper script 16 | - [ ] A link to an external resource like a blog post or video 17 | - [ ] Text cleanups/updates 18 | - [ ] Test updates 19 | - [ ] Bug fix 20 | - [ ] New feature 21 | - [ ] Plugin list change 22 | 23 | ## Checklist 24 | 25 | 26 | 27 | 28 | - [ ] I have read the **CONTRIBUTING** document. 29 | - [ ] I have updated the readme if this PR changes/updates quickstart functionality. 30 | - [ ] All new and existing tests pass. 31 | - [ ] Any scripts added use `#!/usr/bin/env interpreter` instead of potentially platform-specific direct paths (`#!/bin/sh` is an allowed exception) 32 | - [ ] Scripts are marked executable 33 | - [ ] Scripts _do not_ have a language file extension unless they are meant to be sourced and not run standalone. No one should have to know if a script was written in bash, python, ruby or whatever. Not including file extensions makes it easier to rewrite the script in another language later without having to change every reference to the previous version. 34 | - [ ] I have added a credit line to README.md for the script 35 | - [ ] If there was no author credit in a script added in this PR, I have added one. 36 | - [ ] I have confirmed that the link(s) in my PR are valid. 37 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | --- 2 | version: 2 3 | updates: 4 | - package-ecosystem: "github-actions" 5 | directory: "/" 6 | schedule: 7 | interval: "weekly" 8 | -------------------------------------------------------------------------------- /.github/workflows/awesomebot.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: Check links in README.md 3 | 4 | on: 5 | push: 6 | branches: [ '*' ] 7 | pull_request: 8 | branches: [ '*' ] 9 | 10 | jobs: 11 | build: 12 | 13 | runs-on: ubuntu-latest 14 | 15 | steps: 16 | - uses: actions/checkout@v4 17 | - uses: docker://dkhamsing/awesome_bot:latest 18 | with: 19 | args: /github/workspace/Readme.md --allow 500,501,502,503,504,509,521 --allow-dupe --request-delay 1 --allow-redirect --allow-ssl --white-list https://ipfs.io,slideshare,https://img.shields.io 20 | -------------------------------------------------------------------------------- /.github/workflows/mega-linter.yml: -------------------------------------------------------------------------------- 1 | --- 2 | ########################### 3 | ########################### 4 | ## Linter GitHub Actions ## 5 | ########################### 6 | ########################### 7 | name: Lint Code Base 8 | 9 | # 10 | # Documentation: 11 | # https://help.github.com/en/articles/workflow-syntax-for-github-actions 12 | # 13 | 14 | ############################# 15 | # Start the job on all push # 16 | ############################# 17 | on: 18 | push: 19 | branches-ignore: [main] 20 | # Remove the line above to run when pushing to main 21 | pull_request: 22 | branches: [main] 23 | 24 | ############### 25 | # Set the Job # 26 | ############### 27 | jobs: 28 | build: 29 | # Name the Job 30 | name: Megalint Code Base 31 | # Set the agent to run on 32 | runs-on: ubuntu-latest 33 | 34 | ################## 35 | # Load all steps # 36 | ################## 37 | steps: 38 | ########################## 39 | # Checkout the code base # 40 | ########################## 41 | - name: Checkout Code 42 | uses: actions/checkout@v4 43 | with: 44 | # Full git history is needed to get a proper list of changed files 45 | # within `mega-linter` 46 | fetch-depth: 0 47 | 48 | ################################ 49 | # Run Linter against code base # 50 | ################################ 51 | - name: Lint Code Base 52 | uses: megalinter/megalinter@v8 53 | env: 54 | VALIDATE_ALL_CODEBASE: false 55 | DEFAULT_BRANCH: main 56 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 57 | DISABLE_LINTERS: MARKDOWN_MARKDOWN_LINK_CHECK,REPOSITORY_SECRETLINT,SPELL_CSPELL,SPELL_LYCHEE,REPOSITORY_DEVSKIM 58 | ACTION_ACTIONLINT_DISABLE_ERRORS: true 59 | REPOSITORY_CHECKOV_DISABLE_ERRORS: true 60 | REPOSITORY_KICS_DISABLE_ERRORS: true 61 | REPOSITORY_TRIVY_DISABLE_ERRORS: true 62 | 63 | # Upload Mega-Linter artifacts. 64 | # They will be available on Github action page "Artifacts" section 65 | - name: Archive production artifacts 66 | if: ${{ success() }} || ${{ failure() }} 67 | uses: actions/upload-artifact@v4 68 | with: 69 | name: Mega-Linter reports 70 | path: | 71 | mega-linter-reports 72 | mega-linter.log 73 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Don't remove the zsh-quickstart-kit comment or selfupdate will break. 2 | # zsh-quickstart-kit 3 | *.*.un~ 4 | *.a 5 | *.bz2 6 | *.gz 7 | *.o 8 | *.pyc 9 | *.pyo 10 | *.sublime-project 11 | *.sublime-workspace 12 | *.tbz 13 | *.tbz2 14 | *.tgz 15 | *.Z 16 | *~ 17 | .DS_Store 18 | .idea 19 | .vscode 20 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | repos: 3 | - repo: https://github.com/pre-commit/pre-commit-hooks 4 | rev: v5.0.0 5 | hooks: 6 | - id: check-added-large-files 7 | - id: check-executables-have-shebangs 8 | - id: check-merge-conflict 9 | - id: check-shebang-scripts-are-executable 10 | - id: check-symlinks 11 | - id: check-yaml 12 | - id: debug-statements 13 | - id: end-of-file-fixer 14 | - id: forbid-submodules 15 | - id: mixed-line-ending 16 | - id: trailing-whitespace 17 | 18 | - repo: https://github.com/igorshubovych/markdownlint-cli 19 | rev: v0.45.0 20 | hooks: 21 | - id: markdownlint-fix 22 | args: ["--ignore", "LICENSE.md", "--disable", "~MD013"] 23 | 24 | - repo: https://github.com/thlorenz/doctoc 25 | rev: v2.2.0 26 | hooks: 27 | - id: doctoc 28 | args: ["--update-only"] 29 | -------------------------------------------------------------------------------- /.zsh-quickstart-local-plugins-example: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | # 3 | # Only including a shebang to trigger editors to use shell syntax highlighting 4 | # 5 | # Copyright 2006-2021 Joseph Block 6 | # 7 | # The ZSH Starter Kit allows you to replace the curated plugins list it 8 | # ships with with a custom one by creating a file named .zsh-quickstart-local-plugins. 9 | # 10 | # This is to make it easier to customize without having to maintain a separate 11 | # fork of the starter kit. 12 | # 13 | # This example file duplicates the list of plugins that shipped with the 14 | # kit as of 2020-01-01. 15 | 16 | ZGEN_LOADED=() 17 | ZGEN_COMPLETIONS=() 18 | 19 | if [[ $(_zqs-get-setting load-omz-plugins true) == 'true' ]]; then 20 | zgenom oh-my-zsh 21 | fi 22 | 23 | warn-about-prompt-change() { 24 | if [[ ! -f ~/.zsh-quickstart-kit-prompt-switch-warning ]]; then 25 | echo 26 | echo "The default ZSH prompt in the quickstart kit has changed from" 27 | echo "bullet-train to powerlevel10k." 28 | echo 29 | echo "If you want to use the old prompt, run zsh-quickstart-select-bullet-train" 30 | echo 31 | echo "Run zsh-quickstart-select-powerlevel10k to switch to the new prompt" 32 | echo 33 | echo "If you do nothing, you will be switched to powerlevel10k" 34 | echo 35 | touch ~/.zsh-quickstart-kit-prompt-switch-warning 36 | fi 37 | } 38 | 39 | # If you want to customize your plugin list, create a file named 40 | # .zsh-quickstart-local-plugins in your home directory. That file will be sourced 41 | # during startup *instead* of running this load-starter-plugin-list function, 42 | # so make sure to include everything from this function that you want to 43 | # keep. 44 | # 45 | # To make customizing easier, there's a .zsh-quickstart-local-plugins-example 46 | # file at the top level of the zsh-quickstart-kit repository that you can copy 47 | # as a starting point. This keeps you from having to maintain a fork of 48 | # the quickstart kit. 49 | 50 | # If zsh-syntax-highlighting is bundled after zsh-history-substring-search, 51 | # they break, so get the order right. 52 | zgenom load zdharma-continuum/fast-syntax-highlighting 53 | zgenom load zsh-users/zsh-history-substring-search 54 | 55 | # Set keystrokes for substring searching 56 | zmodload zsh/terminfo 57 | bindkey "$terminfo[kcuu1]" history-substring-search-up 58 | bindkey "$terminfo[kcud1]" history-substring-search-down 59 | 60 | # Tab complete rakefile targets. 61 | zgenom load unixorn/rake-completion.zshplugin 62 | 63 | # Automatically run zgenom update and zgenom selfupdate every 7 days. 64 | zgenom load unixorn/autoupdate-zgenom 65 | 66 | # Add my collection of miscellaneous utility functions. 67 | zgenom load unixorn/jpb.zshplugin 68 | 69 | # Colorize the things if you have grc installed. Well, some of the 70 | # things, anyway. 71 | zgenom load unixorn/warhol.plugin.zsh 72 | 73 | # macOS helpers. This plugin is smart enough to detect when it isn't running 74 | # on macOS and not load itself, so you can safely share the same plugin list 75 | # across macOS and Linux/BSD. 76 | zgenom load unixorn/tumult.plugin.zsh 77 | 78 | # Deal with Apple's squirrelly DNS 79 | zgenom load eventi/noreallyjustfuckingstopalready 80 | 81 | # Warn you when you run a command that you've set an alias for without 82 | # using the alias. 83 | zgenom load djui/alias-tips 84 | 85 | # Add my collection of git helper scripts. 86 | zgenom load unixorn/git-extra-commands 87 | 88 | # Add diff-so-fancy so git can use it 89 | if [[ "$(_zqs-get-setting diff-so-fancy true)" == 'true' ]]; then 90 | zgenom load so-fancy/diff-so-fancy 91 | fi 92 | 93 | # Supercharge your history search with fzf 94 | zgenom load unixorn/fzf-zsh-plugin 95 | 96 | # Soup up command history search with fzf. 97 | zgen load unixorn/fzf-zsh-plugin 98 | 99 | # Add my bitbucket git helpers plugin. 100 | zgenom load unixorn/bitbucket-git-helpers.plugin.zsh 101 | 102 | # A collection of scripts that might be useful to sysadmins. 103 | zgenom load skx/sysadmin-util 104 | 105 | # Adds aliases to open your current repo & branch on github. 106 | zgenom load peterhurford/git-it-on.zsh 107 | 108 | # Tom Limoncelli's tooling for storing private information (keys, etc) 109 | # in a repository securely by encrypting them with gnupg. 110 | zgenom load StackExchange/blackbox 111 | 112 | if [[ $(_zqs-get-setting load-omz-plugins true) == 'true' ]]; then 113 | # Load some oh-my-zsh plugins 114 | zgenom oh-my-zsh plugins/pip 115 | zgenom oh-my-zsh plugins/sudo 116 | zgenom oh-my-zsh plugins/aws 117 | zgenom oh-my-zsh plugins/chruby 118 | zgenom oh-my-zsh plugins/colored-man-pages 119 | zgenom oh-my-zsh plugins/git 120 | zgenom oh-my-zsh plugins/github 121 | zgenom oh-my-zsh plugins/python 122 | zgenom oh-my-zsh plugins/rsync 123 | zgenom oh-my-zsh plugins/screen 124 | zgenom oh-my-zsh plugins/vagrant 125 | if [[ $(uname -a | grep -ci Darwin) = 1 ]]; then 126 | # Load macOS-specific plugins 127 | zgenom oh-my-zsh plugins/brew 128 | zgenom oh-my-zsh plugins/macos 129 | fi 130 | 131 | fi 132 | 133 | # A set of shell functions to make it easy to install small apps and 134 | # utilities distributed with pip. 135 | zgenom load sharat87/pip-app 136 | 137 | zgenom load chrissicool/zsh-256color 138 | 139 | # Load more completion files for zsh from the zsh-lovers github repo. 140 | zgenom load zsh-users/zsh-completions src 141 | 142 | # Docker completion 143 | zgenom load srijanshetty/docker-zsh 144 | 145 | # Load tab completions for 1Password's op command line tool if it's installed 146 | zgenom load unixorn/1password-op.plugin.zsh 147 | 148 | # Load me last 149 | GENCOMPL_FPATH=$HOME/.zsh/complete 150 | 151 | # Very cool plugin that generates zsh completion functions for commands 152 | # if they have getopt-style help text. It doesn't generate them on the fly, 153 | # you'll have to explicitly generate a completion, but it's still quite cool. 154 | zgenom load RobSis/zsh-completion-generator 155 | 156 | # Add Fish-like autosuggestions to your ZSH. 157 | zgenom load zsh-users/zsh-autosuggestions 158 | 159 | # k is a zsh script / plugin to make directory listings more readable, 160 | # adding a bit of color and some git status information on files and 161 | # directories. 162 | zgenom load supercrabtree/k 163 | 164 | if [[ $(_zqs-get-setting bullet-train false) == 'true' ]]; then 165 | # Bullet train prompt setup. 166 | zgenom load https://github.com/caiogondim/bullet-train.zsh 167 | else 168 | # p10k is faster and what I'm using now, so it is the new default 169 | zgenom load romkatv/powerlevel10k powerlevel10k 170 | warn-about-prompt-change 171 | fi 172 | 173 | # Save it all to init script 174 | zgenom save 175 | -------------------------------------------------------------------------------- /Changes.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## 1.0.0 4 | 5 | * It's been four years, this is 1.0 6 | * Switch to powerlevel10k prompt instead of bullettrain. If you want to keep bullettrain, run `zsh-quickstart-select-bullettrain`, and you can switch to p10k with `zsh-quickstart-select-powerlevel10k` 7 | 8 | ## 0.7 9 | 10 | * autoload `zmv` by default 11 | * Allow disabling oh-my-zsh inclusion by creating `~/.zsh-quickstart-no-omz` 12 | 13 | ## 0.6 14 | 15 | * Stop stepping on OS-provided `$PATH`. 16 | 17 | ## 0.5.2 18 | 19 | * Added zsh-autosuggestions plugin 20 | 21 | ## 0.5 22 | 23 | * Added Changes file 24 | * Switched to using `~/.zshrc.d` files instead of a single `.zshrc.local` file 25 | * Stopped trying to be so clever about modification times so new users could understand how it was working 26 | * Made it easier for users to customize without having to maintain a fork, we now allow them to use their own plugin list if they create `.zgen-local-plugins` 27 | * Broke out a lot of the OS X specific functions and aliases into a separate plugin, [tumult.plugin.zsh](https://github.com/unixorn/tumult.plugin.zsh) that only loads itself when it detects it is being run on an OS X system. 28 | * Added font installation instructions for Linux 29 | * We now de-duplicate your `$PATH` after loading everything 30 | * Added self-update capability 31 | -------------------------------------------------------------------------------- /Code_Of_Conduct.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## TL;DR 4 | 5 | Don't be an asshole. I'm fine with not getting contributions from smart assholes. 6 | 7 | ## Our Pledge 8 | 9 | In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. 10 | 11 | ## Our Standards 12 | 13 | Examples of behavior that contributes to creating a positive environment include: 14 | 15 | * Using welcoming and inclusive language 16 | * Being respectful of differing viewpoints and experiences 17 | * Gracefully accepting constructive criticism 18 | * Focusing on what is best for the community 19 | * Showing empathy towards other community members 20 | 21 | Examples of unacceptable behavior by participants include: 22 | 23 | * The use of sexualized language or imagery and unwelcome sexual attention or advances 24 | * Trolling, insulting/derogatory comments, and personal or political attacks 25 | * Public or private harassment 26 | * Publishing others' private information, such as a physical or electronic address, without explicit permission 27 | * Other conduct which could reasonably be considered inappropriate in a professional setting 28 | 29 | ## Our Responsibilities 30 | 31 | Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. 32 | 33 | Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. 34 | 35 | ## Scope 36 | 37 | This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. 38 | 39 | ## Enforcement 40 | 41 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at jpb@unixorn.net. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. 42 | 43 | Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. 44 | 45 | ## Attribution 46 | 47 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] 48 | 49 | [homepage]: http://contributor-covenant.org 50 | [version]: http://contributor-covenant.org/version/1/4/ 51 | -------------------------------------------------------------------------------- /Contributing.md: -------------------------------------------------------------------------------- 1 | # Contributing to the ZSH Quickstart Kit 2 | 3 | The **ZSH Quickstart Kit** is a batteries-included starter kit for using `zsh`. 4 | 5 | 6 | 7 | ## Table of Contents 8 | 9 | - [Contribution Guidelines](#contribution-guidelines) 10 | - [New Features](#new-features) 11 | - [Readme](#readme) 12 | 13 | 14 | 15 | ## Contribution Guidelines 16 | 17 | Please only add scripts that have a license attached. I want to avoid the gray area of unlicensed code. 18 | 19 | ## New Features 20 | 21 | Please open an issue before starting to code so we can discuss the new feature, especially if it adds new dependency requirements for the kit. 22 | 23 | When adding a new feature, please also add `zqs-enable-featurename` and `zqs-disable-featurename` functions to `.zshrc`, and also update the `zqs-help` function. New features should use the `_zqs-get-setting` and `_zqs-set-setting` functions to load any settings they need instead of directly creating cookie files. 24 | 25 | ## Readme 26 | 27 | Please update the README to include instructions for your new feature. You don't have to bother with updating the TOC, I'll do that with `doctoc` after merging your PR. 28 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2006-2021, Joseph Block 2 | 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 6 | 7 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | 9 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 10 | 11 | 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 12 | 13 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 14 | -------------------------------------------------------------------------------- /Readme.md: -------------------------------------------------------------------------------- 1 | # ZSH Quickstart Kit 2 | 3 | [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) 4 | [![Build Status](https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2Funixorn%2Fzsh-quickstart-kit%2Fbadge&style=plastic)](https://actions-badge.atrox.dev/unixorn/zsh-quickstart-kit/goto) 5 | ![Awesomebot](https://github.com/unixorn/zsh-quickstart-kit/actions/workflows/awesomebot.yml/badge.svg) 6 | ![Megalinter](https://github.com/unixorn/zsh-quickstart-kit/actions/workflows/mega-linter.yml/badge.svg) 7 | [![GitHub last commit (branch)](https://img.shields.io/github/last-commit/unixorn/zsh-quickstart-kit/main.svg)](https://github.com/unixorn/zsh-quickstart-kit) 8 | 9 | 10 | 11 | ## Table of Contents 12 | 13 | - [Announcement](#announcement) 14 | - [Installation](#installation) 15 | - [Prerequisites](#prerequisites) 16 | - [Fonts](#fonts) 17 | - [OS-specific setup](#os-specific-setup) 18 | - [fzf](#fzf) 19 | - [macOS](#macos) 20 | - [Linux](#linux) 21 | - [Set up Zgenom and the starter kit](#set-up-zgenom-and-the-starter-kit) 22 | - [Contents of the kit](#contents-of-the-kit) 23 | - [Included plugins](#included-plugins) 24 | - [Customizing the kit](#customizing-the-kit) 25 | - [Behavior toggles](#behavior-toggles) 26 | - [zqs](#zqs) 27 | - [zqs check-for-updates](#zqs-check-for-updates) 28 | - [zqs disable-bindkey-handling](#zqs-disable-bindkey-handling) 29 | - [zqs disable-1password-agent](#zqs-disable-1password-agent) 30 | - [zqs enable-1password-agent](#zqs-enable-1password-agent) 31 | - [zqs enable-bindkey-handling](#zqs-enable-bindkey-handling) 32 | - [zqs disable-diff-so-fancy](#zqs-disable-diff-so-fancy) 33 | - [zqs enable-diff-so-fancy](#zqs-enable-diff-so-fancy) 34 | - [zqs disable-omz-plugins](#zqs-disable-omz-plugins) 35 | - [zqs enable-control-c-decorator](#zqs-enable-control-c-decorator) 36 | - [zqs disable-control-c-decorator](#zqs-disable-control-c-decorator) 37 | - [zqs enable-omz-plugins](#zqs-enable-omz-plugins) 38 | - [zqs enable-ssh-askpass-require](#zqs-enable-ssh-askpass-require) 39 | - [zqs disable-ssh-askpass-require](#zqs-disable-ssh-askpass-require) 40 | - [zqs-disable-ssh-key-listing](#zqs-disable-ssh-key-listing) 41 | - [zqs-enable-ssh-key-listing](#zqs-enable-ssh-key-listing) 42 | - [zqs-disable-ssh-key-loading](#zqs-disable-ssh-key-loading) 43 | - [zqs-enable-ssh-key-loading](#zqs-enable-ssh-key-loading) 44 | - [zqs-disable-zmv-autoloading](#zqs-disable-zmv-autoloading) 45 | - [zqs-enable-zmv-autoloading](#zqs-enable-zmv-autoloading) 46 | - [zqs-disable-zsh-profiling](#zqs-disable-zsh-profiling) 47 | - [zqs-enable-zsh-profiling](#zqs-enable-zsh-profiling) 48 | - [zqs selfupdate](#zqs-selfupdate) 49 | - [zqs update](#zqs-update) 50 | - [zqs update-plugins](#zqs-update-plugins) 51 | - [zqs cleanup](#zqs-cleanup) 52 | - [zqs get-setting](#zqs-get-setting) 53 | - [zqs set-setting](#zqs-set-setting) 54 | - [zqs delete-setting](#zqs-delete-setting) 55 | - [Functions and Aliases](#functions-and-aliases) 56 | - [Customizing with ~/.zshrc.d](#customizing-with-zshrcd) 57 | - [I like a plugin, but some of the aliases and functions it installs overwrite other commands or aliases I use](#i-like-a-plugin-but-some-of-the-aliases-and-functions-it-installs-overwrite-other-commands-or-aliases-i-use) 58 | - [ZSH options](#zsh-options) 59 | - [Fragment file directories](#fragment-file-directories) 60 | - [Self-update Settings](#self-update-settings) 61 | - [Customizing the plugin list](#customizing-the-plugin-list) 62 | - [Using fragment files](#using-fragment-files) 63 | - [Complete plugin list replacement](#complete-plugin-list-replacement) 64 | - [Disabling zmv](#disabling-zmv) 65 | - [Disabling oh-my-zsh](#disabling-oh-my-zsh) 66 | - [FAQ](#faq) 67 | - [How do I reconfigure the prompt?](#how-do-i-reconfigure-the-prompt) 68 | - [Powerlevel 10k warns that there is console output during startup](#powerlevel-10k-warns-that-there-is-console-output-during-startup) 69 | - [I added a new completion plugin, and it isn't working](#i-added-a-new-completion-plugin-and-it-isnt-working) 70 | - [I get a git error when I try to update the kit](#i-get-a-git-error-when-i-try-to-update-the-kit) 71 | - [GNU stow is warning that stowing zsh would cause conflicts](#gnu-stow-is-warning-that-stowing-zsh-would-cause-conflicts) 72 | - [_arguments:comparguments:325: can only be called from completion function](#_argumentscomparguments325-can-only-be-called-from-completion-function) 73 | - [Could not open a connection to your authentication agent](#could-not-open-a-connection-to-your-authentication-agent) 74 | - [I want to pin a plugin version](#i-want-to-pin-a-plugin-version) 75 | - [Other Resources](#other-resources) 76 | - [ZSH](#zsh) 77 | - [Dotfiles in general](#dotfiles-in-general) 78 | - [Vim](#vim) 79 | - [Thanks](#thanks) 80 | 81 | 82 | 83 | ## Announcement 84 | 85 | I've switched the quickstart kit to use [zgenom](https://github.com/jandamm/zgenom.git) instead of `zgen`. This should be a painless update since `zgenom` is a superset of `zgen`. 86 | ## Installation 87 | 88 | ### Prerequisites 89 | 90 | #### Fonts 91 | 92 | This quickstart includes the [powerlevel10k](https://github.com/romkatv/powerlevel10k) ZSH theme, which requires a Powerline-compatible font in your terminal to display status glyphs. Powerline-compatible fonts include many useful glyphs, including the nice branch icon that the theme in this `.zshrc` uses. 93 | 94 | Here are a few good Powerline-compatible fonts: 95 | 96 | * [Awesome Terminal Fonts](https://github.com/gabrielelana/awesome-terminal-fonts) - A family of fonts that include some nice monospaced Icons. 97 | * [Cascadia Code](https://github.com/microsoft/cascadia-code) - Microsoft's Cascadia Code 98 | * [Fantasque Awesome Font](https://github.com/ztomer/fantasque_awesome_powerline) - A nice monospaced font, patched with Font-Awesome, Octoicons, and Powerline-Glyphs. 99 | * [Fira Mono](https://github.com/mozilla/Fira) - Mozilla's Fira type family. 100 | * [Hack](http://sourcefoundry.org/hack/) - Another Powerline-compatible font designed for source code and terminal usage. 101 | * [Input Mono](https://input.djr.com/) - A family of fonts designed specifically for code. It offers both monospaced and proportional fonts and includes Powerline glyphs. 102 | * [Iosevka](https://be5invis.github.io/Iosevka/) - Iosevka is an open source slender monospace sans-serif and slab-serif typeface inspired by [Pragmata Pro](http://www.fsd.it/fonts/pragmatapro.htm), M+ and [PF DIN Mono](https://www.myfonts.com/fonts/parachute/pf-din-mono/), designed to be the ideal font for programming. 103 | * [Monoid](http://larsenwork.com/monoid/) - Monoid is customizable and optimized for coding with bitmap-like sharpness at 15px line-height even on low res displays. 104 | * [Mononoki](https://madmalik.github.io/mononoki/) - Mononoki is a typeface by Matthias Tellen, created to enhance code formatting. 105 | * [More Nerd Fonts](https://www.nerdfonts.com/font-downloads) - Another site to download nerd fonts. 106 | * [Nerd fonts](https://github.com/ryanoasis/nerd-fonts) - A collection of over 20 patched fonts (over 1,700 variations) & the fontforge font patcher python script for Powerline, devicons, and vim-devicons: includes Droid Sans, Meslo, AnonymousPro, ProFont, Inconsolta, and many more. These can be installed with `brew` - do `brew tap homebrew/cask-fonts && brew install --cask fontname` 107 | * [Powerline patched font collection](https://github.com/powerline/fonts) - A collection of a dozen or so fonts patched to include Powerline glyphs. 108 | * [Victor Mono](https://rubjo.github.io/victor-mono/) - Victor Mono is a free programming font with semi-connected cursive italics, symbol ligatures (!=, ->>, =>, ===, <=, >=, ++) and Latin, Cyrillic and Greek characters. 109 | * [spacemono](https://github.com/googlefonts/spacemono) - Google's new original monospace display typeface family. 110 | 111 | ### OS-specific setup 112 | 113 | #### fzf 114 | 115 | To enable the enhanced history search, you'll need to install [fzf](https://github.com/junegunn/fzf/). Manual install instructions can be found at [fzf](https://github.com/junegunn/fzf) and os-specific instructions below. 116 | 117 | #### macOS 118 | 119 |
macOS instructions 120 | 121 | 1. Download iTerm2 from [http://www.iterm2.com](http://www.iterm2.com) (optional). In my opinion, it is considerably nicer than the stock Terminal application that comes with macOS. There is an RCE flaw in all versions of iTerm 2 before 3.3.6, so update if you're using an affected version. 122 | 2. Install the current version of Homebrew from [http://brew.sh/](http://brew.sh/). 123 | 3. Install GNU Stow with `brew install stow` 124 | 4. Homebrew has a newer version of `zsh` than the one Apple shipped with the OS before 11.6, so `brew install zsh` to install it. 125 | 5. Switch your shell to `zsh` if necessary - Apple has defaulted the shell for new users to `zsh` since macOS Catalina (10.15): 126 | 1. System Preferences -> Users & Groups. 127 | 2. Unlock the preferences 128 | 3. Select your user 129 | 4. Select advanced options 130 | 5. Set your login shell to `/bin/zsh` (or `/usr/local/bin/zsh` if you decided to use the version packaged by `brew`) 131 | 6. Install some Powerline-compatible or NerdFont fonts from one of the links in the Fonts section above. 132 | 1. In iTerm 2, go to Preferences->Profile in your iTerm 2 preferences, then select one of the Powerline-compatible fonts you just installed. 133 | 2. **Make sure you also specify a Powerline-compatible font for non-ASCII in your iTerm 2 preferences or the prompt separators and branch glyphs will show up garbled**. 134 | 7. Install `fzf` 135 | 1. Install `fzf` with `brew install fzf` 136 | 2. Run the `sh "$(brew --prefix fzf)/install"` command to configure `fzf` 137 | 3. Press `Enter` (`y` default) for all questions except `Do you want to update your shell configuration files? ([y]/n)`. For this question, select `n` and press `Enter`. 138 | 139 |
140 | 141 | #### Linux 142 | 143 |
Linux instructions 144 | 145 | 1. Switch your shell to `zsh` with `chsh -s /bin/zsh` 146 | 2. Install GNU Stow - `sudo yum install -y stow` on Red Hat / CentOS systems, `sudo apt-get -y install stow` on Debian / Ubuntu. 147 | 3. Install `fzf` - `sudo apt-get install -y fzf` on Debian / Ubuntu, do a manual install on Red Hat / Centos - instructions are at [fzf](https://github.com/junegunn/fzf). 148 | 4. Install the patched font in a valid X font path. Valid font paths can be listed with `xset q`: `mv YourChosenPowerlineFont.otf ~/.fonts` 149 | 5. Update the font cache for the path the font was installed in (root privileges may be needed for updating the font cache for some paths): `fc-cache -vf ~/.fonts/` 150 | 151 | After installing a Nerdfont or Powerline-compatible font, you will need to configure your terminal emulator to use your selected Powerline-compatible font. The name of the correct font usually ends with *for Powerline*. 152 | 153 | If the Powerline symbols can't be seen or are garbled, try closing all instances of the terminal emulator. The X Server may also need to be restarted for the new font to load correctly. 154 | 155 | If you still can’t see the new fonts, confirm that the font has been installed to a valid X font path. 156 | 157 | If you get garbled branch glyphs, make sure there isn't a separate font setting for non-ASCII characters in your terminal application that you also need to set to use a Powerline-compatible font. Konsole needs to be set to use UTF-8 encoding, for example. 158 | 159 |
160 | 161 | ### Set up Zgenom and the starter kit 162 | 163 | Now that your fonts and default shell have been set up, install [zgenom](https://github.com/jandamm/zgenom.git) and the dotfiles from this starter kit repository. 164 | 165 | 1. Install [Zgenom](https://github.com/jandamm/zgenom.git) 166 | 1. `cd ~` 167 | 2. `git clone https://github.com/jandamm/zgenom.git` 168 | 2. Install the starter kit 169 | 1. `cd ~` 170 | 2. `git clone https://github.com/unixorn/zsh-quickstart-kit.git` 171 | 3. Configure zsh by symlinking the `.zshrc`, `.zsh-functions`, `.zgen-setup` and `.zsh_aliases` from this repository into your `~`. 172 | 1. You can do this with `stow` by: 173 | 1. `cd zsh-quickstart-kit` 174 | 2. `stow --target=~ zsh`. If you have issues using `~` as a target, do `stow --target="$HOME" zsh`. If you still have errors, symlink the files in the kit's `zsh` directory into your home directory. 175 | 176 | The `.zshrc`, `.zsh_aliases` & `.zsh_functions` files included in this kit enable the plugins listed below. 177 | 178 | ## Contents of the kit 179 | 180 | The zsh-quickstart-kit configures your ZSH environment so that it includes: 181 | 182 | * Automatic periodic updates of both `zgenom` and your plugins 183 | * Cross-session shared history so commands typed in one terminal window can be seen and searched in all your other `zsh` sessions on the same machine. 184 | * Automatic deduplication of your command history. 185 | * Many more tab completions, courtesy of the [zsh-users/zsh-completions](https://github.com/zsh-users/zsh-completions) repository, and periodic updating to the tip of master of that repository, so you get updates to the extra tab completions. 186 | * Supercharged command history search with [fzf](https://github.com/junegunn/fzf). 187 | * Syntax highlighting at the command line. 188 | * Tab completion of Rakefile targets. 189 | * Enabling [oh-my-zsh](https://github.com/robbyrussell/oh-my-zsh)-compatible plugins and themes (via the [zgenom](https://github.com/jandamm/zgenom.git) framework). 190 | * Various helper functions for interacting with macOS' clipboard, audio volume, Spotlight, and Quicklook. For your convenience, these will only load if you are on a macOS machine so that you can use the same plugin list on any *NIX system. 191 | * If you've installed iTerm2's shell integration, it will automatically be loaded during shell startup. 192 | 193 | ### Included plugins 194 | 195 | * [chrissicool/zsh-256color](https://github.com/chrissicool/zsh-256color) - Sets your terminal to 256 colors if available. 196 | * [djui/alias-tips](https://github.com/djui/alias-tips) - Warns you when you have an alias for the command you just typed and tells you what it is. 197 | * [eventi/noreallyjustfuckingstopalready](https://github.com/eventi/noreallyjustfuckingstopalready)- Deals with Apple's squirrelly DNS resolver. Only loads when you're running on macOS. 198 | * [peterhurford/git-it-on.zsh](https://github.com/peterhurford/git-it-on.zsh) - Opens your current repository on GitHub, in your current branch. 199 | * [robSis/zsh-completion-generator](https://github.com/RobSis/zsh-completion-generator) - Adds a tool to generate ZSH completion functions for programs missing them by parsing their `--help` output. Note that this doesn't happen dynamically; you'll have to explicitly run it to create a completion for each command missing one. 200 | * [sharat87/pip-app](https://github.com/sharat87/pip-app) - A set of shell functions to make it easy to install small apps and utilities distributed with `pip`. 201 | * [skx/sysadmin-util](https://github.com/skx/sysadmin-util) - A collection of scripts useful for sysadmins. 202 | * [srijanshetty/docker-zsh](https://github.com/srijanshetty/docker-zsh) - Adds completions for `docker`. 203 | * [stackexchange/blackbox](https://github.com/stackexchange/blackbox) - Tom Limoncelli's tool for storing secret information in a repository with GnuPG encryption, automatically decrypting as needed. 204 | * [supercrabtree/k](https://github.com/supercrabtree/k) - `k` is a directory lister that also shows git status on files & directories. 205 | * [unixorn/1password-op.plugin.zsh](https://github.com/unixorn/1password-op.plugin.zsh) - Tab completions for [1Password](https://1password.com)'s [op](https://developer.1password.com/docs/cli/get-started/) command line tool. Only installs itself if `op` is in your `$PATH`. 206 | * [unixorn/autoupdate-zgenom](https://github.com/unixorn/autoupdate-zgenom) - Adds autoupdate (for both `zgenom` itself, and your plugins) to `zgenom`. 207 | * [unixorn/bitbucket-git-helpers](https://github.com/unixorn/bitbucket-git-helpers.plugin.zsh) - Adds `git` helper scripts for bitbucket. 208 | * [unixorn/fzf-zsh-plugin](https://github.com/unixorn/fzf-zsh-plugin) - This enables `fzf`-powered history search. 209 | * [unixorn/git-extra-commands](https://github.com/unixorn/git-extra-commands) - A collection of extra helper scripts for `git`. 210 | * [unixorn/jpb.zshplugin](https://github.com/unixorn/jpb.zshplugin) - Some of my standard aliases & functions. 211 | * [unixorn/rake-completion.zshplugin](https://github.com/unixorn/rake-completion.zshplugin) - Reads the Rakefile in the current directory so you can tab-complete the Rakefile targets. 212 | * [unixorn/tumult.plugin.zsh](https://github.com/unixorn/tumult.plugin.zsh) - Adds macOS-specific functions and scripts. This plugin only adds itself to your `$PATH` if you're running macOS to allow you to use the same plugin list on macOS and other systems. 213 | * [zdharma-continuum/fast-syntax-highlighting](https://github.com/zdharma-continuum/fast-syntax-highlighting) - Syntax highlighting as you type. 214 | * [zsh-autosuggestions](https://github.com/zsh-users/zsh-autosuggestions) - Adds fish-like autosuggestions to your ZSH sessions. 215 | * [zsh-users/zsh-completions](https://github.com/zsh-users/zsh-completions) - Tab completions for many more applications than come standard with ZSH. 216 | * [zsh-users/zsh-history-substring-search](https://github.com/zsh-users/zsh-history-substring-search) - Better history search. 217 | 218 | The quickstart kit also uses `zgenom` to load oh-my-zsh and these plugins: 219 | 220 | * aws 221 | * brew - only loaded on macOS 222 | * chruby 223 | * colored-man 224 | * git 225 | * github 226 | * osx - only loaded on macOS 227 | * pip 228 | * python 229 | * rsync 230 | * screen 231 | * sudo 232 | * vagrant 233 | 234 | ## Customizing the kit 235 | 236 | ### Behavior toggles 237 | 238 | Running the following commands will toggle behavior the next time you start a shell session: 239 | 240 | * Prompt selectors - We now use the [powerlevel10k](https://github.com/romkatv/powerlevel10k) prompt. I won't change the prompt out from under people without a way for them to get the old behavior, so there are commands to switch back and forth. 241 | * `zsh-quickstart-select-powerlevel10k` - Switch to the [powerlevel10k](https://github.com/romkatv/powerlevel10k) prompt now used as the kit's default. 242 | * `zsh-quickstart-select-bullet-train` - Switch back to the [bullet-train](https://github.com/caiogondim/bullet-train.zsh) prompt originally used in the kit. 243 | * You can disable printing the list of `ssh` keys by executing `zqs disable-ssh-key-listing`. 244 | * `bash` prints `^C` when you're typing a command and hit control-c to cancel it, so it is easy to see it wasn't executed. By default, ZSH doesn't print the `^C`. I prefer seeing the `^C`, so by default, the quickstart traps `SIGINT` and prints the `^C`. You can disable this behavior by running `zqs disable-control-c-decorator` and enable it with `zqs enable-control-c-decorator`. 245 | 246 | #### zqs 247 | 248 | As of 2021-11-13, I've added a `zqs` command to start exposing some of the configurable parts in a more user-friendly way. The `zqs` command has the following subcommands: 249 | 250 | ##### zqs check-for-updates 251 | 252 | Updates the quickstart kit if it has been longer than seven days since the last update. 253 | 254 | ##### zqs disable-bindkey-handling 255 | 256 | Disable `bindkey` setup and alias expansion in the quickstart `.zshrc` so people can use plugins like [globalias](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/globalias) to handle it instead. 257 | 258 | ##### zqs disable-1password-agent 259 | 260 | Disable using 1Password's `ssh` agent 261 | 262 | ##### zqs enable-1password-agent 263 | 264 | Enable using 1Password's `ssh` agent starting with the next new ZSH session. This is the default behavior when `op` is in your `$PATH`. 265 | 266 | ##### zqs enable-bindkey-handling 267 | 268 | Let the quickstart's `.zshrc` configure `bindkey` setup and alias expansion. This is the default behavior. 269 | 270 | ##### zqs disable-diff-so-fancy 271 | 272 | Stop loading the [diff-so-fancy](https://github.com/so-fancy/diff-so-fancy) plugin starting with the next ZSH session. 273 | 274 | ##### zqs enable-diff-so-fancy 275 | 276 | Start loading the [diff-so-fancy](https://github.com/so-fancy/diff-so-fancy) plugin starting with the next ZSH session. This is the default behavior. 277 | 278 | ##### zqs disable-omz-plugins 279 | 280 | Set the quickstart to not include any oh-my-zsh plugins from the standard plugin list. Loading omz plugins can make terminal startup significantly slower. 281 | 282 | ##### zqs enable-control-c-decorator 283 | 284 | Set the quickstart to create a `TRAPINT` handler in future `zsh` sessions to also display control-C when you type control-c. This is the default behavior. 285 | 286 | ##### zqs disable-control-c-decorator 287 | 288 | Set the quickstart to not create the `TRAPINT` handler to display control-C when you type control-c in future `zsh` sessions. 289 | 290 | ##### zqs enable-omz-plugins 291 | 292 | Sets the quickstart to include the oh-my-zsh plugins from the standard plugin list. 293 | 294 | ##### zqs enable-ssh-askpass-require 295 | 296 | Enable the quickstart to prompt for your ssh passphrase on the command line. 297 | 298 | ##### zqs disable-ssh-askpass-require 299 | 300 | The quickstart will prompt for your ssh passphrase via a gui program. Default behavior. 301 | 302 | ##### zqs-disable-ssh-key-listing 303 | 304 | Don't print the loaded `ssh` keys when creating a new session. 305 | 306 | ##### zqs-enable-ssh-key-listing 307 | 308 | Print the loaded `ssh` keys when creating a new session. This is the default behavior. 309 | 310 | ##### zqs-disable-ssh-key-loading 311 | 312 | Don't load `ssh` keys when creating a new session. Useful if you're storing your private keys in a [yubikey](https://www.yubico.com/). 313 | 314 | ##### zqs-enable-ssh-key-loading 315 | 316 | Load missing `ssh` private keys when creating a new session. This is the default behavior. 317 | 318 | ##### zqs-disable-zmv-autoloading 319 | 320 | Don't run `autoload -U zmv` when creating a new session. 321 | 322 | ##### zqs-enable-zmv-autoloading 323 | 324 | Run `autoload -U zmv` when creating a new session. This is the default behavior. 325 | 326 | ##### zqs-disable-zsh-profiling 327 | 328 | Disable ZSH's profiler. This is the default. 329 | 330 | ##### zqs-enable-zsh-profiling 331 | 332 | Turn on ZSH's profiler 333 | 334 | ##### zqs selfupdate 335 | 336 | Force an immediate update of the quickstart kit. 337 | 338 | ##### zqs update 339 | 340 | Update the quickstart kit and all your plugins. 341 | 342 | ##### zqs update-plugins 343 | 344 | Updates all your plugins. 345 | 346 | ##### zqs cleanup 347 | 348 | Cleanup unused plugins after removing them from the list 349 | 350 | ##### zqs get-setting 351 | 352 | `zqs get-setting NAME [OPTIONAL default value]` prints the value of a `zqs` setting, or if unset and a default value was passed, the specified default. 353 | 354 | ##### zqs set-setting 355 | 356 | `zqs set-setting NAME VALUE` writes a setting. 357 | 358 | ##### zqs delete-setting 359 | 360 | `zqs delete-setting NAME` deletes a setting from `zqs`'s crude parameter store. 361 | 362 | ### Functions and Aliases 363 | 364 | #### Customizing with ~/.zshrc.d 365 | 366 | The `.zshrc` included in this kit will automatically source any files it finds in `~/.zshrc.d`. This happens after plugins are loaded. If you need to set variables or aliases before plugins are loaded, create files in `~/.zshrc.pre-plugins.d`. 367 | 368 | This makes it easy for you to add extra functions and aliases without having to maintain a separate fork of this repository and allows you to configure the behavior of some of the plugins by setting environment variables. 369 | 370 | The files will be sourced in alphanumeric order after loading all the plugins, and I suggest you use a naming scheme of `001-onething`, `002-something-else` etc., to ensure they're loaded in the order you expect. 371 | 372 | ### I like a plugin, but some of the aliases and functions it installs overwrite other commands or aliases I use 373 | 374 | Make a file in `~/.zshrc.d` named something like `999-reset-aliases`. Because files in `~/.zshrc.d` are loaded after all the ZSH plugins, you can add lines like `unalias xyzzy` to remove an alias named `xyzzy`, or `unset -f abcd` to remove a function named `abcd`. 375 | 376 | Once you've cleared all the unwanted aliases and functions, you can add new ones with your preferred names. 377 | 378 | ### ZSH options 379 | 380 | The quickstart kit does an opinionated (i.e., my way) setup of ZSH options and adds some functions and aliases I like on my systems. I don't want you to have to maintain a separate fork if you don't like them and/or want to add your own, so the kit allows you to override or add behavior by creating fragment files that it will load during session startup. 381 | 382 | #### Fragment file directories 383 | 384 | You can customize the quickstart by adding files to its various `zshrc.d` directories. 385 | 386 | If you want to set variables _before_ the quickstart starts loading plugins to alter their behavior, stick your fragment files in `~/.zshrc.pre-plugins.d`. 387 | 388 | After the quickstart sets up its aliases, functions, plugins and ZSH options, it will source every fragment file in `~/.zshrc.d`. 389 | 390 | To make it easier to have macOS, FreeBSD or Linux-specific settings tweaks, the quickstart also supports OS-specific pre & post `.zshrc.d` directories. If you want a file to only be sourced on a single OS, the quickstart also checks for `.zshrc.pre-plugins.$(uname).d` and `~/.zshrc.$(uname).d` during loading. 391 | 392 | For your convenience, the quickstart will also look for a `.zshrc.work.d` directory, and if it's present, load fragment files from there. This lets you have a separate directory in your dotfiles repository for work-specific customizations. 393 | 394 | ### Self-update Settings 395 | 396 | The quickstart kit will automatically check for updates every seven days. If you want to change the interval, set `QUICKSTART_KIT_REFRESH_IN_DAYS` in a file in `~/.zshrc.d`. If you're going to disable self-updating entirely, add `unset QUICKSTART_KIT_REFRESH_IN_DAYS` in a file in `~/.zshrc.d`. 397 | 398 | ### Customizing the plugin list 399 | 400 | I've included what I think is a good starter set of ZSH plugins in this repository. However, everyone has their preferences for their environment. 401 | 402 | To make things easier to customize without users having to maintain their own forks, the kit provides two ways to customize the list of plugins it will load. 403 | 404 | You can either add a fragment file to `~/.zshrc.add-plugins.d`, or you can make a `~/.zsh-quickstart-local-plugin` file. 405 | 406 | #### Using fragment files 407 | 408 | If all you want to do is add plugins to the standard list and you want to still automatically get any new changes I make to that standard list (new plugins, new locations when existing plugins are moved, etc) then adding a file into `~/.zshrc.add-plugins.d` with your extra plugins listed as `zgenom load githubuser/pluginrepo` (one line per plugin) is the way to go. The kit will load its plugins, then add yours on the end. You can add separate files with plugins in the `~/.zshrc.add-plugins.d` directory - my personal use case is having one file with all the plugins I use everywhere, and one that has extra plugins I only need on my work machines. This is the easiest option. 409 | 410 | #### Complete plugin list replacement 411 | 412 | If you don't care about future changes to the kit's plugins and want to fully replace the built-in list, then create a `~/.zsh-quickstart-local-plugins` file. When the kit detects a file named `~/.zsh-quickstart-local-plugins`, its `.zshrc` will source that **instead** of running the `load-starter-plugin-list` function defined in `~/.zgen-setup`. 413 | 414 | **Using `~/.zsh-quickstart-local-plugins` is not additive. It will *completely replace* the kit-provided list of plugins.** If you want to just add more plugins, use the fragment file method above. 415 | 416 | Creating a `.zsh-quickstart-local-plugins` from scratch is a pain, so to make customizing your plugin list easier, I've included a `.zsh-quickstart-local-plugins-example` file at the root of the repository that installs the same plugin list that the kit does by default that you can use as a starting point for your own `.zsh-quickstart-local-plugins` file. 417 | 418 | Copy that to your `$HOME/.zsh-quickstart-local-plugins`, change the list, and the next time you start a terminal session, you'll get your plugin list loaded instead of the kit's defaults. 419 | 420 | ### Disabling zmv 421 | 422 | The quickstart automatically autoloads `zmv`. If you want to disable that so you can configure it with another plugin or on your own, run `zqs disable-zmv-autoloading`. 423 | 424 | ### Disabling oh-my-zsh 425 | 426 | If you don't want `zgenom` to load the oh-my-zsh defaults, run `zqs-disable-omz-plugins`. 427 | 428 | ## FAQ 429 | 430 | ### How do I reconfigure the prompt? 431 | 432 | You may want to reconfigure your prompt after using it. The quickstart uses the [powerlevel10k](https://github.com/romkatv/powerlevel10k) theme, so you can reconfigure your prompt by running `p10k configure`. 433 | 434 | ### Powerlevel 10k warns that there is console output during startup 435 | 436 | You see a warning during session startup - 437 | 438 | ```sh 439 | [WARNING]: Console output during zsh initialization detected. 440 | When using Powerlevel10k with instant prompt, console output during zsh 441 | initialization may indicate issues. 442 | ``` 443 | 444 | You can stifle this output by adding `typeset -g POWERLEVEL9K_INSTANT_PROMPT=quiet` in a fragment file in `~/.zshrc.pre-plugins.d`. 445 | 446 | ### I added a new completion plugin, and it isn't working 447 | 448 | I've had reports that sometimes you may need to reset your completions after adding a new plugin. 449 | 450 | ```sh 451 | rm ~/.zcompdump* 452 | compinit 453 | ``` 454 | 455 | ### I get a git error when I try to update the kit 456 | 457 | You try to update the kit, and you get an error similar to this: 458 | 459 | ```sh 460 | From https://github.com/unixorn/zsh-quickstart-kit 461 | 0c5bad9..2064c6b master -> origin/master 462 | 463 | 755f689...e3f8677 switch-to-zgenom -> origin/switch-to-zgenom (forced update) 464 | Updating 0c5bad9..2064c6b 465 | error: Your local changes to the following files would be overwritten by merge: 466 | zsh/.zshrc 467 | Please commit your changes or stash them before you merge. 468 | Aborting 469 | ``` 470 | 471 | This happens when you edit a file provided by the quickstart kit, in this case, `.zshrc`. This is annoying, and to let you customize your ZSH settings without being forced to maintain your own fork of the kit, the kit-provided `.zshrc` will load any files it finds in the various `~/.zshrc.d` directories. See [Fragment File Directories](https://github.com/unixorn/zsh-quickstart-kit#fragment-file-directories) for more details. 472 | 473 | ### GNU stow is warning that stowing zsh would cause conflicts 474 | 475 | You ran `stow --target=/Users/YourUsername zsh` in the top level of the repo and stow printed the following error: 476 | 477 | ```sh 478 | WARNING! stowing zsh would cause conflicts: 479 | * existing target is neither a link nor a directory: .zshrc 480 | All operations aborted. 481 | ``` 482 | 483 | Per @jefheaton, this is caused when trying to replace an existing `.zshrc` file. He fixed it by closing `~` in Finder so Finder wouldn't create a `.DS_Store` file, deleting the existing `.DS_Store` and removing the old `.zshrc`. You may have to rename it first if ZSH is keeping the file open, then delete it after closing all your Terminal/iTerm 2 windows. 484 | 485 | ### _arguments:comparguments:325: can only be called from completion function 486 | 487 | This has been solved by running `zgen update` or switching to [zgenom](https://github.com/jandamm/zgenom). New users of the kit should already be running `zgenom`. Thanks @RonanJackson, for reporting the fix. 488 | 489 | ### Could not open a connection to your authentication agent 490 | 491 | Confirm that `ssh-agent` is running. If not, Rob Montero has a good [blog post](https://rob.cr/blog/using-ssh-agent-mac-os-x/) on setting up `ssh-agent` on macOS, and here are [instructions](https://wiki.archlinux.org/title/SSH_keys#Start_ssh-agent_with_systemd_user) for starting `ssh-agent` with `systemd` on Linux. 492 | 493 | ### I want to pin a plugin version 494 | 495 | The plugin standard doesn't include a standard way of determining a version. If you need to pin a version of a plugin, the easiest way to do it is to fork the plugin's repository and then have your `~/.zsh-quickstart-local-plugins` refer to that. 496 | 497 | If you don't want to maintain a fork, you can also have `zgenom` load from a local directory. So clone the repository, then add something like 498 | ```sh 499 | zgenom load ~/path/to/your/copy/of/example.plugin.zsh 500 | ``` 501 | 502 | Then you can tag working versions, pull from upstream for testing, and if the upstream doesn't work for you, check out your `last-working-version` tag, and `zgenom` will use your tagged version instead of the tip of the default branch. 503 | 504 | ## Other Resources 505 | 506 | ### ZSH 507 | 508 | * For a list of other ZSH plugins, completions, and themes you might like to use, check out my [awesome-zsh-plugins](https://github.com/unixorn/awesome-zsh-plugins) list. It also contains a list of other ZSH [tutorials and starter kits](https://github.com/unixorn/awesome-zsh-plugins#generic-zsh). 509 | * Justin Garrison has a good repository that details [Mastering ZSH](https://github.com/rothgar/mastering-zsh). 510 | 511 | ### Dotfiles in general 512 | 513 | [dotfiles.github.io/](https://dotfiles.github.io/) has a lot of great resources for dotfiles - frameworks for managing them, configurations for editors, and other bootstraps with initial configurations to start from. 514 | 515 | ### Vim 516 | 517 | If you're using vim, [spf13](https://github.com/spf13/spf13-vim) is an excellent starter configuration and plugin collection. 518 | 519 | ## Thanks 520 | 521 | Many thanks to all the contributors over the years who've helped make the quickstart better. 522 | 523 | 524 | 525 | 526 | 527 | Made with [contributors-img](https://contributors-img.web.app). 528 | -------------------------------------------------------------------------------- /zsh/.zgen-setup: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env zsh 2 | # 3 | # Only including a shebang to trigger editors to use shell 4 | # syntax highlighting. 5 | # 6 | # Copyright 2006-2022 Joseph Block 7 | # 8 | # BSD licensed, see LICENSE.txt 9 | 10 | # Clone zgenom if you haven't already 11 | if [[ -z "$ZGENOM_PARENT_DIR" ]]; then 12 | ZGENOM_PARENT_DIR=$HOME 13 | ZGENOM_SOURCE_FILE=$ZGENOM_PARENT_DIR/.zqs-zgenom/zgenom.zsh 14 | 15 | # Set ZGENOM_SOURCE_FILE to the old directory if it already exists 16 | if [[ -f "$ZGENOM_PARENT_DIR/zgenom/zgenom.zsh" ]] ; then 17 | ZGENOM_SOURCE_FILE=$ZGENOM_PARENT_DIR/zgenom/zgenom.zsh 18 | fi 19 | fi 20 | 21 | # zgenom stores the clones plugins & themes in $ZGEN_DIR when it 22 | # is set. Otherwise it stuffs everything in the source tree, which 23 | # is unclean. 24 | ZGEN_DIR=${ZGEN_DIR:-$HOME/.zgenom} 25 | 26 | if [[ ! -f "$ZGENOM_SOURCE_FILE" ]] ; then 27 | if [[ ! -d "$ZGENOM_PARENT_DIR" ]]; then 28 | mkdir -p "$ZGENOM_PARENT_DIR" 29 | fi 30 | pushd $ZGENOM_PARENT_DIR 31 | git clone https://github.com/jandamm/zgenom.git .zqs-zgenom 32 | popd 33 | fi 34 | 35 | if [[ ! -f "$ZGENOM_SOURCE_FILE" ]] ; then 36 | echo "Can't find zgenom.zsh" 37 | else 38 | # echo "Loading zgenom" 39 | source "$ZGENOM_SOURCE_FILE" 40 | fi 41 | 42 | unset ZGENOM_PARENT_DIR ZGENOM_SOURCE_FILE 43 | 44 | warn-about-prompt-change() { 45 | if [[ ! -f ~/.zsh-quickstart-kit-prompt-switch-warning ]]; then 46 | echo 47 | echo "The default ZSH prompt in the quickstart kit has changed from" 48 | echo "bullet-train to powerlevel10k." 49 | echo 50 | echo "If you want to use the old prompt, run zsh-quickstart-select-bullet-train" 51 | echo 52 | echo "Run zsh-quickstart-select-powerlevel10k to switch to the new prompt" 53 | echo 54 | echo "If you do nothing, you will be switched to powerlevel10k" 55 | echo 56 | touch ~/.zsh-quickstart-kit-prompt-switch-warning 57 | fi 58 | } 59 | 60 | load-starter-plugin-list() { 61 | echo "Creating a zgenom save" 62 | ZGEN_LOADED=() 63 | ZGEN_COMPLETIONS=() 64 | 65 | if [[ ! -f ~/.zsh-quickstart-no-omz ]] || [[ $(_zqs-get-setting load-omz-plugins true) == 'true' ]]; then 66 | zgenom oh-my-zsh 67 | fi 68 | 69 | # If you want to customize your plugin list, create a file named 70 | # .zsh-quickstart-local-plugins-example in your home directory. That 71 | # file will be sourced during startup *instead* of running this 72 | # load-starter-plugin-list function, so make sure to include everything 73 | # from this function that you want to keep. 74 | # 75 | # To make customizing easier, there's a .zsh-quickstart-local-plugins-example 76 | # file at the top level of the zsh-quickstart-kit repository that you can 77 | # copy as a starting point. This keeps you from having to maintain a fork of 78 | # the quickstart kit. 79 | 80 | # If zsh-syntax-highlighting is bundled after zsh-history-substring-search, 81 | # they break, so get the order right. 82 | zgenom load zdharma-continuum/fast-syntax-highlighting 83 | zgenom load zsh-users/zsh-history-substring-search 84 | 85 | # Set keystrokes for substring searching 86 | zmodload zsh/terminfo 87 | bindkey "$terminfo[kcuu1]" history-substring-search-up 88 | bindkey "$terminfo[kcud1]" history-substring-search-down 89 | 90 | # Tab complete rakefile targets. 91 | zgenom load unixorn/rake-completion.zshplugin 92 | 93 | # Automatically run zgenom update and zgenom selfupdate every 7 days. 94 | zgenom load unixorn/autoupdate-zgenom 95 | 96 | # Add my collection of miscellaneous utility functions. 97 | zgenom load unixorn/jpb.zshplugin 98 | 99 | # Colorize the things if you have grc installed. Well, some of the 100 | # things, anyway. 101 | zgenom load unixorn/warhol.plugin.zsh 102 | 103 | # macOS helpers. This plugin is smart enough to detect when it isn't running 104 | # on macOS and not load itself, so you can safely share the same plugin list 105 | # across macOS and Linux/BSD. 106 | zgenom load unixorn/tumult.plugin.zsh 107 | 108 | # Deal with Apple's squirrelly DNS 109 | zgenom load eventi/noreallyjustfuckingstopalready 110 | 111 | # Warn you when you run a command that you've set an alias for without 112 | # using the alias. 113 | zgenom load djui/alias-tips 114 | 115 | # Add my collection of git helper scripts. 116 | zgenom load unixorn/git-extra-commands 117 | 118 | # Add diff-so-fancy so git can use it 119 | if [[ "$(_zqs-get-setting diff-so-fancy true)" == 'true' ]]; then 120 | zgenom load so-fancy/diff-so-fancy 121 | fi 122 | 123 | # Supercharge your history search with fzf 124 | zgenom load unixorn/fzf-zsh-plugin 125 | 126 | # Add my bitbucket git helpers plugin. 127 | zgenom load unixorn/bitbucket-git-helpers.plugin.zsh 128 | 129 | # A collection of scripts that might be useful to sysadmins. 130 | zgenom load skx/sysadmin-util 131 | 132 | # Adds aliases to open your current repo & branch on github. 133 | zgenom load peterhurford/git-it-on.zsh 134 | 135 | # Tom Limoncelli's tooling for storing private information (keys, etc) 136 | # in a repository securely by encrypting them with gnupg. 137 | zgenom load StackExchange/blackbox 138 | 139 | if [[ -f ~/.zqs-add-plugins ]]; then 140 | source ~/.zqs-add-plugins 141 | fi 142 | 143 | if [[ -d ~/.zshrc.add-plugins.d ]]; then 144 | load-shell-fragments ~/.zshrc.add-plugins.d 145 | fi 146 | 147 | if [[ ! -f ~/.zsh-quickstart-no-omz ]] || [[ $(_zqs-get-setting load-omz-plugins false) == 'true' ]]; then 148 | # Load some oh-my-zsh plugins 149 | zgenom oh-my-zsh plugins/pip 150 | zgenom oh-my-zsh plugins/sudo 151 | zgenom oh-my-zsh plugins/aws 152 | zgenom oh-my-zsh plugins/chruby 153 | zgenom oh-my-zsh plugins/colored-man-pages 154 | zgenom oh-my-zsh plugins/git 155 | zgenom oh-my-zsh plugins/github 156 | zgenom oh-my-zsh plugins/python 157 | zgenom oh-my-zsh plugins/rsync 158 | zgenom oh-my-zsh plugins/screen 159 | zgenom oh-my-zsh plugins/vagrant 160 | 161 | if (( $+commands[brew] )); then 162 | zgenom oh-my-zsh plugins/brew 163 | fi 164 | 165 | if [ $(uname -a | grep -ci Darwin) = 1 ]; then 166 | # Load macOS-specific plugins 167 | zgenom oh-my-zsh plugins/macos 168 | fi 169 | fi 170 | 171 | # A set of shell functions to make it easy to install small apps and 172 | # utilities distributed with pip. 173 | zgenom load sharat87/pip-app 174 | 175 | zgenom load chrissicool/zsh-256color 176 | 177 | # Load more completion files for zsh from the zsh-lovers github repo. 178 | zgenom load zsh-users/zsh-completions src 179 | 180 | # Docker completion 181 | zgenom load srijanshetty/docker-zsh 182 | 183 | # Load tab completions for 1Password's op command line tool if it's installed 184 | zgenom load unixorn/1password-op.plugin.zsh 185 | 186 | # Load me last 187 | GENCOMPL_FPATH=$HOME/.zsh/complete 188 | 189 | # Very cool plugin that generates zsh completion functions for commands 190 | # if they have getopt-style help text. It doesn't generate them on the fly, 191 | # you'll have to explicitly generate a completion, but it's still quite cool. 192 | zgenom load RobSis/zsh-completion-generator 193 | 194 | # Add Fish-like autosuggestions to your ZSH. 195 | zgenom load zsh-users/zsh-autosuggestions 196 | 197 | # k is a zsh script / plugin to make directory listings more readable, 198 | # adding a bit of color and some git status information on files and 199 | # directories. 200 | zgenom load supercrabtree/k 201 | 202 | # Be compatible with the old settings files for now 203 | if [[ -f ~/.zsh-quickstart-use-bullet-train ]] || [[ $(_zqs-get-setting bullet-train false) == 'true' ]]; then 204 | # Bullet train prompt setup. 205 | zgenom load https://github.com/caiogondim/bullet-train.zsh 206 | else 207 | # p10k is faster and what I'm using now, so it is the new default 208 | zgenom load romkatv/powerlevel10k powerlevel10k 209 | warn-about-prompt-change 210 | fi 211 | 212 | # Save it all to init script. 213 | zgenom save 214 | } 215 | 216 | setup-zgen-repos() { 217 | ZQS_override_plugin_list='' 218 | # Check the old name for backward compatibility 219 | if [[ -r $HOME/.zgen-local-plugins ]]; then 220 | ZQS_override_plugin_list="$HOME/.zgen-local-plugins" 221 | fi 222 | # If they have both, the new name takes precedence 223 | if [[ -r $HOME/.zsh-quickstart-local-plugins ]]; then 224 | ZQS_override_plugin_list="$HOME/.zsh-quickstart-local-plugins" 225 | fi 226 | 227 | if [[ -r "$ZQS_override_plugin_list" ]]; then 228 | echo "Loading local plugin list from $ZQS_override_plugin_list" 229 | source "$ZQS_override_plugin_list" 230 | unset ZQS_override_plugin_list 231 | else 232 | load-starter-plugin-list 233 | fi 234 | } 235 | 236 | # This comes from https://stackoverflow.com/questions/17878684/best-way-to-get-file-modified-time-in-seconds 237 | # This works on both Linux with GNU fileutils and macOS with BSD stat. 238 | 239 | # Naturally BSD/macOS and Linux can't share the same options to stat. 240 | if [[ $(uname | grep -ci -e Darwin -e BSD) = 1 ]]; then 241 | 242 | # macOS version. 243 | get_file_modification_time() { 244 | modified_time=$(stat -f %m "$1" 2> /dev/null) || modified_time=0 245 | echo "${modified_time}" 246 | } 247 | 248 | elif [[ $(uname | grep -ci Linux) = 1 ]]; then 249 | 250 | # Linux version. 251 | get_file_modification_time() { 252 | modified_time=$(stat -c %Y "$1" 2> /dev/null) || modified_time=0 253 | echo "${modified_time}" 254 | } 255 | fi 256 | 257 | # check if there's an init.zsh file for zgen and generate one if not. 258 | if ! zgenom saved; then 259 | setup-zgen-repos 260 | fi 261 | 262 | # Our installation instructions get the user to make a symlink 263 | # from ~/.zgen-setup to wherever they checked out the zsh-quickstart-kit 264 | # repository. 265 | # 266 | # Unfortunately, stat will return the modification time of the 267 | # symlink instead of the target file, so construct a full path to hand off 268 | # to stat so it returns the modification time of the actual .zgen-setup file. 269 | if [[ -f ~/.zgen-setup ]]; then 270 | REAL_ZGEN_SETUP=~/.zgen-setup 271 | fi 272 | if [[ -L ~/.zgen-setup ]]; then 273 | REAL_ZGEN_SETUP="$(readlink ~/.zgen-setup)" 274 | fi 275 | 276 | # If you don't want my standard starter set of plugins, create a file named 277 | # .zsh-quickstart-local-plugins and add your zgenom load commands there. Don't forget to 278 | # run `zgenom save` at the end of your .zsh-quickstart-local-plugins file. 279 | # 280 | # Warning: .zgen-local-plugins REPLACES the starter list setup, it doesn't 281 | # add to it. 282 | # 283 | # Use readlink in case the user is symlinking from another repo checkout, so 284 | # they can use a personal dotfiles repository cleanly. 285 | if [[ -f ~/.zgen-local-plugins ]]; then 286 | REAL_ZGEN_SETUP=~/.zgen-local-plugins 287 | fi 288 | if [[ -L ~/.zgen-local-plugins ]]; then 289 | REAL_ZGEN_SETUP="${HOME}/$(readlink ~/.zgen-local-plugins)" 290 | fi 291 | # Old file still works for backward compatibility, but we want the new file 292 | # to take precedence when both exist. 293 | if [[ -f ~/.zsh-quickstart-local-plugins ]]; then 294 | REAL_ZGEN_SETUP=~/.zsh-quickstart-local-plugins 295 | fi 296 | if [[ -L ~/.zsh-quickstart-local-plugins ]]; then 297 | REAL_ZGEN_SETUP="${HOME}/$(readlink ~/.zsh-quickstart-local-plugins)" 298 | fi 299 | 300 | # If .zgen-setup is newer than init.zsh, regenerate init.zsh 301 | if [ $(get_file_modification_time ${REAL_ZGEN_SETUP}) -gt $(get_file_modification_time ~/.zgenom/init.zsh) ]; then 302 | echo "$(basename ${REAL_ZGEN_SETUP}) ($REAL_ZGEN_SETUP) updated; creating a new init.zsh from plugin list in ${REAL_ZGEN_SETUP}" 303 | setup-zgen-repos 304 | elif [ -d ~/.zshrc.add-plugins.d ]; then 305 | init_timestamp=$(get_file_modification_time ~/.zgenom/init.zsh) 306 | plugins_dir_timestamp=$(get_file_modification_time ~/.zshrc.add-plugins.d) 307 | if [ "$plugins_dir_timestamp" -gt "$init_timestamp" ]; then 308 | need_update="true" 309 | fi 310 | 311 | if [[ -n "$("ls" -A ~/.zshrc.add-plugins.d)" ]] && [[ -z $need_update ]]; then 312 | for file in ~/.zshrc.add-plugins.d/*; do 313 | if [[ $(get_file_modification_time "${file}") -gt ${init_timestamp} ]]; then 314 | need_update="true" 315 | break 316 | fi 317 | done 318 | fi 319 | 320 | if [[ -n $need_update ]]; then 321 | echo "Some files in ~/.zshrc.add-plugins.d updated; creating a new init.zsh from plugin list in ${REAL_ZGEN_SETUP} and plugins dir" 322 | setup-zgen-repos 323 | fi 324 | unset init_timestamp 325 | unset plugins_dir_timestamp 326 | unset need_update 327 | fi 328 | 329 | unset REAL_ZGEN_SETUP 330 | -------------------------------------------------------------------------------- /zsh/.zsh_aliases: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env zsh 2 | # 3 | # Only including a shebang to trigger editors to use shell syntax highlighting 4 | # 5 | # Copyright 2006-2022 Joseph Block 6 | # 7 | # BSD licensed, see LICENSE.txt in this repository. 8 | # 9 | # If you want to customize these, the best thing to do is override them 10 | # with a shell fragment in ~/.zshrc.d. Files there are automatically sourced 11 | # by the quickstart kit, so if you do that, you don't have to maintain your 12 | # own fork of the quickstart kit. 13 | 14 | if [[ -d ~/gocode ]]; then 15 | export GOPATH=~/gocode 16 | fi 17 | 18 | # Yes, these tests are ugly. They do however, work. 19 | if [[ "$(uname -s)" == "Darwin" ]]; then 20 | # do macOS specific things 21 | alias top="TERM=vt100 top" 22 | else 23 | alias cputop="top -o cpu" 24 | alias l-d="ls -lad" 25 | alias l="ls -lah" 26 | alias ll="ls -lah | less" 27 | fi 28 | 29 | if [[ "$(uname -s)" == "Linux" ]]; then 30 | # we're on linux 31 | alias l-d="ls -lFad" 32 | alias l="ls -laF" 33 | alias ll="ls -lFa | TERM=vt100 less" 34 | fi 35 | 36 | export CVS_RSH=ssh 37 | 38 | # shellcheck disable=SC2142 39 | alias historysummary="history | awk '{a[\$2]++} END{for(i in a){printf \"%5d\t%s\n\",a[i],i}}' | sort -rn | head" 40 | 41 | if [ -x /bin/vim ]; then 42 | alias vi="/bin/vim" 43 | alias vim="/bin/vim" 44 | export EDITOR="/bin/vim" 45 | fi 46 | 47 | if [ -x /usr/bin/vim ]; then 48 | alias vi="/usr/bin/vim" 49 | alias vim="/usr/bin/vim" 50 | export EDITOR="/usr/bin/vim" 51 | fi 52 | 53 | # MacPorts has a newer vim than Apple ships 54 | if [ -x /opt/local/bin/vim ]; then 55 | alias vim="/opt/local/bin/vim" 56 | alias vi="/opt/local/bin/vim" 57 | export EDITOR="/opt/local/bin/vim" 58 | fi 59 | 60 | # So does brew 61 | if can_haz brew; then 62 | brew_prefix="$(brew --prefix)/bin" 63 | if [[ -x "$brew_prefix/vim" ]]; then 64 | alias vim="$brew_prefix/vim" 65 | alias vi="$brew_prefix/vim" 66 | export EDITOR="$brew_prefix/vim" 67 | fi 68 | unset brew_prefix 69 | fi 70 | 71 | # Clearly, I really like vim. 72 | 73 | export VISUAL=${EDITOR} 74 | 75 | # Clean up files that have the wrong line endings 76 | alias mac2unix="tr '\015' '\012'" 77 | alias unix2mac="tr '\012' '\015'" 78 | 79 | # A couple of different external IP lookups depending on which is down. 80 | alias external_ip="curl -s icanhazip.com" 81 | alias myip="dig +short myip.opendns.com @resolver1.opendns.com" 82 | 83 | # Show laptop's IP addresses 84 | # shellcheck disable=2139 85 | alias ips="ifconfig -a | perl -nle'/(\d+\.\d+\.\d+\.\d+)/ && print $1'" 86 | 87 | alias reattach="screen -r" 88 | 89 | # SSH stuff 90 | # Pass our credentials by default 91 | alias ssh='ssh -A' 92 | alias sshA='ssh -A' 93 | alias ssh-A='ssh -A' 94 | alias ssh-unkeyed='/usr/bin/ssh' 95 | alias ssh_unkeyed='/usr/bin/ssh' 96 | 97 | alias scp-no-hostchecks='scp -o UserKnownHostsFile=/dev/null -o GlobalKnownHostsFile=/dev/null -o StrictHostKeyChecking=no' 98 | alias ssh-no-hostchecks='ssh -A -o UserKnownHostsFile=/dev/null -o GlobalKnownHostsFile=/dev/null -o StrictHostKeyChecking=no' 99 | alias scp_no_hostchecks='scp -o UserKnownHostsFile=/dev/null -o GlobalKnownHostsFile=/dev/null -o StrictHostKeyChecking=no' 100 | alias ssh_no_hostchecks='ssh -A -o UserKnownHostsFile=/dev/null -o GlobalKnownHostsFile=/dev/null -o StrictHostKeyChecking=no' 101 | 102 | # Set up even more shortcuts because I am that lazy a typist. 103 | alias nh-scp=scp-no-hostchecks 104 | alias nh-ssh=ssh-no-hostchecks 105 | alias nh_scp=scp-no-hostchecks 106 | alias nh_ssh=ssh-no-hostchecks 107 | alias nhscp=scp-no-hostchecks 108 | alias nhssh=ssh-no-hostchecks 109 | 110 | # Strip color codes from commands that insist on spewing them so we can 111 | # pipe them into files cleanly. 112 | alias stripcolors='sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[mGK]//g"' 113 | 114 | # On the rare occasions I don't want to continue an interrupted download 115 | # I can always delete the incomplete fragment explicitly. I usually just 116 | # want to complete it. 117 | alias wget="wget -c" 118 | 119 | # Dump the last 20 history entries to make !number more convenient to use. 120 | alias zh="fc -l -d -D" 121 | 122 | # My typical tyops. 123 | alias gerp='grep' 124 | alias grep-i='grep -i' 125 | alias grep='GREP_COLORS="1;37;41" LANG=C grep --color=auto' 126 | alias grepi='grep -i' 127 | alias knfie='knife' 128 | alias maek='make' 129 | alias psax='ps ax' 130 | alias pswax='ps wax' 131 | alias psxa='ps ax' 132 | alias raek='rake' 133 | alias tartvf='tar tvf' 134 | alias tartvzf='tar tvzf' 135 | alias tarxvf='tar xvf' 136 | alias tarxvjf='tar xvjf' 137 | 138 | # Deal with various stupidities. 139 | 140 | # Thanks so much for breaking ldapsearch, fink 141 | if [ -x /sw/bin/ldapsearch ];then 142 | # At least the stale version Apple ships actually works. 143 | alias ldapsearch=/usr/bin/ldapsearch 144 | fi 145 | 146 | # Use brew versions if present 147 | if can_haz brew; then 148 | brew_prefix=$(brew --prefix) 149 | if [ -x "${brew_prefix}/bin/mysql/bin/mysql" ]; then 150 | alias mysql="${brew_prefix}/mysql/bin/mysql" 151 | fi 152 | 153 | if [ -x "${brew_prefix}/bin/mysql/bin/mysqladmin" ]; then 154 | alias mysqladmin="${brew_prefix}/mysql/bin/mysqladmin" 155 | fi 156 | fi 157 | 158 | # Help the lazy typists again. 159 | alias ..="cd .." 160 | alias ...="cd ../.." 161 | 162 | # Honor old .zsh_aliases.local customizations, but print depecation warning. 163 | if [ -f ~/.zsh_aliases.local ]; then 164 | # shellcheck disable=SC1090 165 | source ~/.zsh_aliases.local 166 | echo ".zsh_aliases.local is deprecated and will stop working after June 1st, 2022." 167 | echo "Make entries in ~/.zshrc.d instead. See https://github.com/unixorn/zsh-quickstart-kit#zshrcd for more details." 168 | fi 169 | -------------------------------------------------------------------------------- /zsh/.zsh_functions: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | # 3 | # Only including a shebang to trigger editors shell syntax highlighting 4 | # 5 | # Copyright 2006-2022 Joseph Block 6 | # 7 | # BSD licensed, see LICENSE.txt 8 | # 9 | # If you want to customize these, the best thing to do is override them 10 | # with a shell fragment in ~/.zshrc.d, then you don't have to maintain 11 | # your own fork of the quickstart kit 12 | 13 | function exists() { 14 | if (( $+commands[$1] )); then return 0; else return 1; fi 15 | } 16 | 17 | # from cads@ooyala.com 18 | function ff() { 19 | find . -type f -iname '*'$@'*' -ls 20 | } 21 | 22 | function hgrep-full() { 23 | if can_haz egrep; then 24 | history | egrep --color -i "$@" 25 | else 26 | history | grep -i "$@" 27 | fi 28 | } 29 | 30 | # hgrep-full is easier to type, leaving hgrep_full for backwards compatibility 31 | function hgrep_full() { 32 | echo "hgrep_full is deprecated, use hgrep-full" 33 | hgrep-full "$@" 34 | } 35 | 36 | function envgrep() { 37 | printenv | grep -i "$@" 38 | } 39 | 40 | # From Dan Ryan's blog - http://danryan.co/using-antigen-for-zsh.html 41 | function man() { 42 | env \ 43 | LESS_TERMCAP_mb=$(printf "\e[1;31m") \ 44 | LESS_TERMCAP_md=$(printf "\e[1;31m") \ 45 | LESS_TERMCAP_me=$(printf "\e[0m") \ 46 | LESS_TERMCAP_se=$(printf "\e[0m") \ 47 | LESS_TERMCAP_so=$(printf "\e[1;44;33m") \ 48 | LESS_TERMCAP_ue=$(printf "\e[0m") \ 49 | LESS_TERMCAP_us=$(printf "\e[1;32m") \ 50 | man "$@" 51 | } 52 | 53 | if ! can_haz watch; then 54 | # From commandlinefu.com 55 | function watch () { 56 | t="$1" 57 | shift 58 | while test : 59 | do 60 | clear 61 | date=$(date) 62 | echo -e "Every $ts: $@ \t\t\t\t $date" 63 | $@ 64 | sleep "$t" 65 | done 66 | } 67 | fi 68 | 69 | # scp file to machine you're sshing into this machine from 70 | function mecp() { 71 | scp "$@" ${SSH_CLIENT%% *}:~/Downloads/; 72 | } 73 | 74 | function calc() { 75 | awk "BEGIN{ print $* }" ; 76 | } 77 | 78 | function get-nr-jobs() { 79 | jobs | wc -l 80 | } 81 | alias get_nr_jobs="get-nr-jobs" 82 | 83 | function get_load() { 84 | uptime | awk '{print $11}' | tr ',' ' ' 85 | } 86 | 87 | function mtr-url() { 88 | if can_haz mtr; then 89 | host=$(ruby -ruri -e "puts (URI.parse('$1').host or '$1')") 90 | sudo mtr -t "$host" 91 | else 92 | echo 'Cannot find mtr in your PATH - install it and try again' 93 | fi 94 | } 95 | alias mtr_url="mtr-url" 96 | 97 | function fix_tmux_ssh_agent() { 98 | if can_haz tmux; then 99 | for key in SSH_AUTH_SOCK SSH_CONNECTION SSH_CLIENT; do 100 | if (tmux show-environment | grep "^${key}" > /dev/null); then 101 | value=$(tmux show-environment | grep "^${key}" | sed -e "s/^[A-Z_]*=//") 102 | export ${key}="${value}" 103 | fi 104 | done 105 | else 106 | echo "Can't find tmux in your PATH. Install it and try again." 107 | fi 108 | } 109 | 110 | function scan24() { 111 | if can_haz nmap; then 112 | # Probe a /24 for hosts 113 | nmap -sP ${1}/24 114 | else 115 | echo "Can't find nmap in your PATH - install it and try again." 116 | fi 117 | } 118 | 119 | if ! can_haz nj; then 120 | # Netjoin - Block until a network connection is obtained. 121 | # Originally from https://github.com/bamos/dotfiles/blob/master/.funcs 122 | function nj() { 123 | while true; do 124 | ping -c 1 8.8.8.8 &> /dev/null && break 125 | sleep 1 126 | done 127 | } 128 | fi 129 | 130 | # lists zombie processes 131 | function zombie() { 132 | ps aux | awk '{if ($8=="Z") { print $2 }}' 133 | } 134 | alias zombies=zombie 135 | 136 | # get the content type of an http resource 137 | # from https://github.com/jleclanche/dotfiles/blob/master/.zshrc 138 | function htmime() { 139 | if [[ -z $1 ]]; then 140 | print "USAGE: htmime " 141 | return 1 142 | fi 143 | if can_haz curl; then 144 | mime=$(curl -sIX HEAD $1 | sed -nr "s/Content-Type: (.+)/\1/p") 145 | else 146 | echo "Can't find curl in your PATH" 147 | fi 148 | print $mime 149 | } 150 | 151 | # Start an HTTP server from a directory, optionally specifying the port 152 | function httpserver() { 153 | local port="${1:-8000}"; 154 | sleep 1 && open "http://localhost:${port}/" & 155 | # Set the default Content-Type to `text/plain` instead of `application/octet-stream` 156 | # And serve everything as UTF-8 (although not technically correct, this doesn’t break anything for binary files) 157 | python -c $'import SimpleHTTPServer;\nmap = SimpleHTTPServer.SimpleHTTPRequestHandler.extensions_map;\nmap[""] = "text/plain";\nfor key, value in map.items():\n\tmap[key] = value + ";charset=UTF-8";\nSimpleHTTPServer.test();' "$port"; 158 | } 159 | 160 | # Honor old .zsh_functions.local customizations, but print depecation warning. 161 | if [ -f ~/.zsh_functions.local ]; then 162 | source .zsh_functions.local 163 | echo ".zsh_functions.local is deprecated and will stop working after June 1st, 2022." 164 | echo "Make entries in ~/.zshrc.d instead. See https://github.com/unixorn/zsh-quickstart-kit#zshrcd for more details." 165 | fi 166 | -------------------------------------------------------------------------------- /zsh/.zshrc: -------------------------------------------------------------------------------- 1 | # Copyright 2006-2024 Joseph Block 2 | # 3 | # BSD licensed, see LICENSE.txt 4 | # 5 | # Set this to use case-sensitive completion 6 | # CASE_SENSITIVE="true" 7 | # 8 | # Uncomment following line if you want to disable colors in ls 9 | # DISABLE_LS_COLORS="true" 10 | # 11 | # Uncomment following line if you want to disable autosetting terminal title. 12 | # DISABLE_AUTO_TITLE="true" 13 | # 14 | # Version 1.0.0 15 | # 16 | # If you want to change settings that are in this file, the easiest way 17 | # to do it is by adding a file to ~/.zshrc.d or ~/.zshrc.pre-plugins.d that 18 | # redefines the settings. 19 | # 20 | # All files in there will be sourced, and keeping your customizations 21 | # there will keep you from having to maintain a separate fork of the 22 | # quickstart kit. 23 | if [[ -f ~/.zqs-zprof-enabled ]]; then 24 | zmodload zsh/zprof 25 | fi 26 | 27 | # Check if a command exists 28 | function can_haz() { 29 | which "$@" > /dev/null 2>&1 30 | } 31 | 32 | function zqs-debug() { 33 | if [[ -f ~/.zqs-debug-mode ]]; then 34 | echo $@ 35 | fi 36 | } 37 | 38 | # Fix weirdness with intellij 39 | if [[ -z "${INTELLIJ_ENVIRONMENT_READER}" ]]; then 40 | export POWERLEVEL9K_INSTANT_PROMPT='quiet' 41 | fi 42 | 43 | # Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc. 44 | # Initialization code that may require console input (password prompts, [y/n] 45 | # confirmations, etc.) must go above this block; everything else may go below. 46 | if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then 47 | source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" 48 | fi 49 | 50 | # Valid font modes: 51 | # flat, awesome-patched, awesome-fontconfig, nerdfont-complete, nerdfont-fontconfig 52 | if [[ -r ~/.powerlevel9k_font_mode ]]; then 53 | POWERLEVEL9K_MODE=$(head -1 ~/.powerlevel9k_font_mode) 54 | fi 55 | 56 | # Unset COMPLETION_WAITING_DOTS in a file in ~/.zshrc.d if you want red dots to be displayed while waiting for completion 57 | export COMPLETION_WAITING_DOTS="true" 58 | 59 | # Provide a unified way for the quickstart to get/set settings. 60 | if [[ -f ~/.zqs-settings-path ]]; then 61 | _ZQS_SETTINGS_DIR=$(cat ~/.zqs-settings-path) 62 | else 63 | _ZQS_SETTINGS_DIR="${HOME}/.zqs-settings" 64 | fi 65 | export _ZQS_SETTINGS_DIR 66 | 67 | # _zqs-* functions are internal tooling for the quickstart. Modifying or unsetting 68 | # them is likely to break things badly. 69 | 70 | _zqs-trigger-init-rebuild() { 71 | rm -f ~/.zgen/init.zsh 72 | rm -f ~/.zgenom/init.zsh 73 | } 74 | 75 | # We need to load shell fragment files often enough to make it a function 76 | function load-shell-fragments() { 77 | if [[ -z $1 ]]; then 78 | echo "You must give load-shell-fragments a directory path" 79 | else 80 | if [[ -d "$1" ]]; then 81 | if [ -n "$(/bin/ls -A $1)" ]; then 82 | for _zqs_fragment in $(/bin/ls -A $1) 83 | do 84 | if [ -r $1/$_zqs_fragment ]; then 85 | source $1/$_zqs_fragment 86 | fi 87 | done 88 | unset _zqs_fragment 89 | fi 90 | else 91 | echo "$1 is not a directory" 92 | fi 93 | fi 94 | } 95 | 96 | # Settings names have to be valid file names, and we're not doing any parsing here. 97 | _zqs-get-setting() { 98 | # If there is a $2, we return that as the default value if there's 99 | # no settings file. 100 | local sfile="${_ZQS_SETTINGS_DIR}/${1}" 101 | if [[ -f "$sfile" ]]; then 102 | svalue=$(cat "$sfile") 103 | else 104 | if [[ $# -eq 2 ]]; then 105 | svalue=$2 106 | else 107 | svalue='' 108 | fi 109 | fi 110 | echo "$svalue" 111 | } 112 | 113 | _zqs-set-setting() { 114 | if [[ $# -eq 2 ]]; then 115 | mkdir -p "$_ZQS_SETTINGS_DIR" 116 | echo "$2" > "${_ZQS_SETTINGS_DIR}/$1" 117 | else 118 | echo "Usage: _zqs-set-setting-value SETTINGNAME VALUE" 119 | fi 120 | } 121 | 122 | _zqs-delete-setting(){ 123 | # We want to keep output clean when settings are cleared internally, so 124 | # use a separate function when called by a human we can display a warning 125 | # if the setting doesn't exist. 126 | local sfile="${_ZQS_SETTINGS_DIR}/${1}" 127 | if [[ -f "$sfile" ]]; then 128 | rm -f "$sfile" 129 | else 130 | echo "There is no settings file for ${1}" 131 | fi 132 | } 133 | 134 | _zqs-purge-setting() { 135 | local sfile="${_ZQS_SETTINGS_DIR}/${1}" 136 | rm -f "$sfile" 137 | } 138 | 139 | # Convert the old settings files into new style settings 140 | function _zqs-update-stale-settings-files() { 141 | # Convert .zqs-additional-plugins to new format 142 | if [[ -f ~/.zqs-additional-plugins ]]; then 143 | mkdir -p ~/.zshrc.add-plugins.d 144 | sed -e 's/^./zgenom load &/' ~/.zqs-additional-plugins >> ~/.zshrc.add-plugins.d/0000-transferred-plugins 145 | rm -f ~/.zqs-additional-plugins 146 | echo "Plugins from .zqs-additional-plugins were moved to .zshrc.add-plugins.d/0000-transferred-plugins with a format change" 147 | fi 148 | if [[ -f ~/.zsh-quickstart-use-bullet-train ]]; then 149 | _zqs-set-setting bullet-train true 150 | rm -f ~/.zsh-quickstart-use-bullet-train 151 | echo "Converted old ~/.zsh-quickstart-use-bullet-train to new settings system" 152 | fi 153 | if [[ -f ~/.zsh-quickstart-no-omz ]]; then 154 | _zqs-set-setting load-omz-plugins false 155 | rm -f ~/.zsh-quickstart-no-omz 156 | echo "Converted old ~/.zsh-quickstart-no-omz to new settings system" 157 | fi 158 | if [[ -f ~/.zsh-quickstart-no-zmv ]]; then 159 | _zqs-set-setting no-zmv true 160 | rm -f ~/.zsh-quickstart-no-zmv 161 | echo "Converted old ~/.zsh-quickstart-no-zmv to new settings system" 162 | fi 163 | # Don't break existing user setups, but transition to a zqs setting to reduce 164 | # pollution in the user's environment. 165 | if [[ -z "ZSH_QUICKSTART_SKIP_TRAPINT" ]]; then 166 | echo "'ZSH_QUICKSTART_SKIP_TRAPINT' is deprecated in favor of running 'zqs disable-control-c-decorator' to write a settings knob." 167 | zqs-quickstart-disable-control-c-decorator 168 | fi 169 | } 170 | 171 | _zqs-update-stale-settings-files 172 | 173 | # Add some quickstart feature toggle functions 174 | function zsh-quickstart-select-bullet-train() { 175 | _zqs-set-setting bullet-train true 176 | _zqs-set-setting powerlevel10k false 177 | _zqs-trigger-init-rebuild 178 | } 179 | 180 | function zsh-quickstart-select-powerlevel10k() { 181 | rm -f ~/.zsh-quickstart-use-bullet-train 182 | _zqs-set-setting powerlevel10k true 183 | _zqs-set-setting bullet-train false 184 | _zqs-trigger-init-rebuild 185 | } 186 | 187 | function zsh-quickstart-disable-1password-ssh-agent() { 188 | _zqs-set-setting use-1password-ssh-agent false 189 | } 190 | function zsh-quickstart-enable-1password-ssh-agent() { 191 | _zqs-set-setting use-1password-ssh-agent true 192 | } 193 | 194 | # Binary feature settings functions should always be named 195 | # zsh-quickstart-disable-FEATURE and zsh-quickstart-enable-FEATURE 196 | 197 | function zsh-quickstart-disable-bindkey-handling() { 198 | _zqs-set-setting handle-bindkeys false 199 | } 200 | 201 | function zsh-quickstart-enable-bindkey-handling() { 202 | _zqs-set-setting handle-bindkeys true 203 | } 204 | 205 | function zqs-quickstart-disable-control-c-decorator() { 206 | _zqs-set-setting control-c-decorator false 207 | echo "Disabled the control-c decorator in future zsh sessions." 208 | echo "You can re-enable the quickstart's control-c decorator by running 'zqs enable-control-c-decorator'" 209 | } 210 | 211 | function zqs-quickstart-enable-control-c-decorator() { 212 | echo "The control-c decorator is enabled for future zsh sessions." 213 | echo "You can disable the quickstart's control-c decorator by running 'zqs disable-control-c-decorator'" 214 | _zqs-set-setting control-c-decorator true 215 | } 216 | 217 | function _zqs-enable-zmv-autoloading() { 218 | _zqs-set-setting no-zmv false 219 | } 220 | 221 | function _zqs-disable-zmv-autoloading() { 222 | _zqs-set-setting no-zmv true 223 | } 224 | 225 | function zsh-quickstart-disable-omz-plugins() { 226 | rm -f ~/.zsh-quickstart-no-omz 227 | _zqs-set-setting load-omz-plugins false 228 | _zqs-trigger-init-rebuild 229 | } 230 | 231 | function zsh-quickstart-enable-omz-plugins() { 232 | rm -f ~/.zsh-quickstart-no-omz 233 | _zqs-set-setting load-omz-plugins true 234 | _zqs-trigger-init-rebuild 235 | } 236 | 237 | function zsh-quickstart-set-ssh-askpass-require() { 238 | export SSH_ASKPASS_REQUIRE=never 239 | } 240 | 241 | function zsh-quickstart-enable-ssh-askpass-require() { 242 | _zqs-set-setting enable-ssh-askpass-require true 243 | } 244 | 245 | function zsh-quickstart-disable-ssh-askpass-require() { 246 | _zqs-set-setting enable-ssh-askpass-require false 247 | zsh-quickstart-check-for-ssh-askpass 248 | } 249 | 250 | function _zqs-enable-diff-so-fancy() { 251 | _zqs-set-setting diff-so-fancy true 252 | } 253 | 254 | function _zqs-disable-diff-so-fancy() { 255 | _zqs-set-setting diff-so-fancy false 256 | } 257 | 258 | function zsh-quickstart-check-for-ssh-askpass() { 259 | if ! can_haz ssh-askpass; then 260 | echo "If you disable the ssh-askpass-require feature, you'll" 261 | echo "need to install ssh-askpass for the quickstart to prompt," 262 | echo "for your ssh key/s passphrase on shell startup." 263 | echo "This is the default behavior for ssh-add:" 264 | echo $(tput setaf 2)"https://www.man7.org/linux/man-pages/man1/ssh-add.1.html#ENVIRONMENT"$(tput sgr0) 265 | fi 266 | } 267 | # Correct spelling for commands 268 | setopt correct 269 | 270 | # turn off the infernal correctall for filenames 271 | unsetopt correctall 272 | 273 | # Base PATH 274 | PATH="$PATH:/sbin:/usr/sbin:/bin:/usr/bin" 275 | 276 | # If you need to add extra directories to $PATH that are not checked for 277 | # here, add a file in ~/.zshrc.d - then you won't have to maintain a 278 | # fork of the kit. 279 | 280 | # Conditional PATH additions 281 | for path_candidate in /Applications/Xcode.app/Contents/Developer/usr/bin \ 282 | /opt/homebrew/bin \ 283 | /opt/homebrew/sbin \ 284 | /home/linuxbrew/.linuxbrew/bin \ 285 | /home/linuxbrew/.linuxbrew/sbin \ 286 | /opt/local/bin \ 287 | /opt/local/sbin \ 288 | /usr/local/bin \ 289 | /usr/local/sbin \ 290 | ~/.cabal/bin \ 291 | ~/.cargo/bin \ 292 | ~/.linuxbrew/bin \ 293 | ~/.linuxbrew/sbin \ 294 | ~/.rbenv/bin \ 295 | ~/bin \ 296 | ~/src/gocode/bin \ 297 | ~/gocode 298 | do 299 | if [[ -d "${path_candidate}" ]]; then 300 | path+=("${path_candidate}") 301 | fi 302 | done 303 | export PATH 304 | 305 | # We will dedupe $PATH after loading ~/.zshrc.d/* so that any duplicates 306 | # added there get deduped too. 307 | 308 | # Deal with brew if it's installed. Note - brew can be installed outside 309 | # of /usr/local, so use brew --prefix to find its bin and sbin directories. 310 | if can_haz brew; then 311 | BREW_PREFIX=$(brew --prefix) 312 | if [[ -d "${BREW_PREFIX}/bin" ]]; then 313 | export PATH="$PATH:${BREW_PREFIX}/bin" 314 | fi 315 | if [[ -d "${BREW_PREFIX}/sbin" ]]; then 316 | export PATH="$PATH:${BREW_PREFIX}/sbin" 317 | fi 318 | fi 319 | 320 | # Yes, these are a pain to customize. Fortunately, Geoff Greer made an online 321 | # tool that makes it easy to customize your color scheme and keep them in sync 322 | # across Linux and OS X/*BSD at http://geoff.greer.fm/lscolors/ 323 | 324 | if [[ -z "$LSCOLORS" ]]; then 325 | export LSCOLORS='Exfxcxdxbxegedabagacad' 326 | fi 327 | if [[ -z "$LS_COLORS" ]]; then 328 | export LS_COLORS='di=1;34;40:ln=35;40:so=32;40:pi=33;40:ex=31;40:bd=34;46:cd=34;43:su=0;41:sg=0;46:tw=0;42:ow=0;43:' 329 | fi 330 | 331 | onepassword-agent-check() { 332 | # 1password ssh agent support 333 | zqs-debug "Checking for 1password" 334 | if [[ $(_zqs-get-setting use-1password-ssh-agent true) == 'true' ]]; then 335 | if [[ "$(uname -s)" == "Darwin" ]]; then 336 | local ONE_P_SOCK=~/Library/Group\ Containers/2BUA8C4S2C.com.1password/t/agent.sock 337 | fi 338 | if [[ "$(uname -s)" == "Linux" ]]; then 339 | local ONE_P_SOCK=~/.1password/agent.sock 340 | fi 341 | zqs-debug "ONE_P_SOCK=$ONE_P_SOCK" 342 | if [[ -r "$ONE_P_SOCK" ]];then 343 | export SSH_AUTH_SOCK="$ONE_P_SOCK" 344 | else 345 | echo "Quickstart is set to use 1Password's ssh agent, but $ONE_P_SOCK isn't readable!" 346 | fi 347 | zqs-debug "Set SSH_AUTH_SOCK to $SSH_AUTH_SOCK" 348 | fi 349 | } 350 | 351 | load-our-ssh-keys() { 352 | # setup ssh-agent for 1password only if it's installed 353 | if can_haz op; then 354 | onepassword-agent-check 355 | fi 356 | # If keychain is installed let it take care of ssh-agent, else do it manually 357 | if can_haz keychain; then 358 | eval `keychain -q --eval` 359 | else 360 | if [ -z "$SSH_AUTH_SOCK" ]; then 361 | # If user has keychain installed, let it take care of ssh-agent, else do it manually 362 | # Check for a currently running instance of the agent 363 | RUNNING_AGENT="$(ps -ax | grep 'ssh-agent -s' | grep -v grep | wc -l | tr -d '[:space:]')" 364 | if [ "$RUNNING_AGENT" = "0" ]; then 365 | if [ ! -d ~/.ssh ] ; then 366 | mkdir -p ~/.ssh 367 | fi 368 | # Launch a new instance of the agent 369 | ssh-agent -s &> ~/.ssh/ssh-agent 370 | fi 371 | eval $(cat ~/.ssh/ssh-agent) 372 | fi 373 | fi 374 | 375 | local key_manager=ssh-add 376 | 377 | if can_haz keychain; then 378 | key_manager=keychain 379 | fi 380 | 381 | # Fun with SSH 382 | if [ $($key_manager -l | grep -c "The agent has no identities." ) -eq 1 ]; then 383 | if [[ "$(uname -s)" == "Darwin" ]]; then 384 | # macOS allows us to store ssh key pass phrases in the keychain, so try 385 | # to load ssh keys using pass phrases stored in the macOS keychain. 386 | # 387 | # You can use ssh-add -K /path/to/key to store pass phrases into 388 | # the macOS keychain 389 | 390 | # macOS Monterey deprecates the -K and -A flags. They have been replaced 391 | # by the --apple-use-keychain and --apple-load-keychain flags. 392 | 393 | # check if Monterey or higher 394 | # https://scriptingosx.com/2020/09/macos-version-big-sur-update/ 395 | if [[ $(sw_vers -productVersion | cut -d '.' -f 1) -ge "12" ]]; then 396 | # Load all ssh keys that have pass phrases stored in macOS keychain using new flags 397 | ssh-add --apple-load-keychain 398 | else 399 | ssh-add -qA 400 | fi 401 | fi 402 | 403 | for key in $(find ~/.ssh -type f -a \( -name '*id_rsa' -o -name '*id_dsa' -o -name '*id_ecdsa' -o -name '*id_ed25519' \)) 404 | do 405 | if [ -f ${key} -a $(ssh-add -l | grep -F -c "$(ssh-keygen -l -f $key | awk '{print $2}')" ) -eq 0 ]; then 406 | $key_manager -q ${key} 407 | fi 408 | done 409 | fi 410 | } 411 | 412 | if [[ -z "$SSH_CLIENT" ]] || can_haz keychain; then 413 | # We're not on a remote machine, so load keys 414 | if [[ "$(_zqs-get-setting enable-ssh-askpass-require)" == 'true' ]]; then 415 | zsh-quickstart-set-ssh-askpass-require 416 | fi 417 | load_ssh_keys="$(_zqs-get-setting load-ssh-keys true)" 418 | if [[ "$load_ssh_keys" != "false" ]]; then 419 | load-our-ssh-keys 420 | fi 421 | unset load_ssh_keys 422 | fi 423 | 424 | # Load helper functions before we load zgenom setup 425 | if [ -r ~/.zsh_functions ]; then 426 | source ~/.zsh_functions 427 | fi 428 | 429 | # Make it easy to prepend your own customizations that override 430 | # the quickstart kit's defaults by loading all files from the 431 | # ~/.zshrc.pre-plugins.d directory 432 | mkdir -p ~/.zshrc.pre-plugins.d 433 | load-shell-fragments ~/.zshrc.pre-plugins.d 434 | 435 | if [[ -d "$HOME/.zshrc.pre-plugins.$(uname).d" ]]; then 436 | load-shell-fragments "$HOME/.zshrc.pre-plugins.$(uname).d" 437 | fi 438 | 439 | # macOS doesn't have a python by default. This makes the omz python and 440 | # zsh-completion-generator plugins sad, so if there isn't a python, alias 441 | # it to python3 442 | if ! can_haz python; then 443 | if can_haz python3; then 444 | alias python=python3 445 | fi 446 | # Ugly hack for zsh-completion-generator - but only do it if the user 447 | # hasn't already set GENCOMPL_PY 448 | if [[ -z "$GENCOMPL_PY" ]]; then 449 | export GENCOMPL_PY='python3' 450 | export ZSH_COMPLETION_HACK='true' 451 | fi 452 | fi 453 | 454 | # Now that we have $PATH set up and ssh keys loaded, configure zgenom. 455 | # Start zgenom 456 | if [ -f ~/.zgen-setup ]; then 457 | source ~/.zgen-setup 458 | fi 459 | 460 | # Undo the hackery for issue 180 461 | # Don't unset GENCOMPL_PY if we didn't set it 462 | if [[ -n "$ZSH_COMPLETION_HACK" ]]; then 463 | unset GENCOMPL_PY 464 | unset ZSH_COMPLETION_HACK 465 | fi 466 | 467 | # Set some history options 468 | # 469 | # You can customize these by putting a file in ~/.zshrc.d with 470 | # different settings - those files are loaded later specifically to 471 | # make overriding these (and things set by plugins) easy without having 472 | # to maintain a fork. 473 | setopt append_history 474 | setopt extended_history 475 | setopt hist_expire_dups_first 476 | setopt hist_ignore_all_dups 477 | setopt hist_ignore_dups 478 | setopt hist_ignore_space 479 | setopt hist_reduce_blanks 480 | setopt hist_save_no_dups 481 | setopt hist_verify 482 | setopt INC_APPEND_HISTORY 483 | unsetopt HIST_BEEP 484 | 485 | # Share your history across all your terminal windows 486 | setopt share_history 487 | #setopt noclobber 488 | 489 | # Keep a ton of history. You can override these without editing .zshrc by 490 | # adding a file to ~/.zshrc.d that changes these variables. 491 | export HISTSIZE=100000 492 | export SAVEHIST=100000 493 | HISTFILE=~/.zsh_history 494 | 495 | # ZSH Man page referencing the history_ignore parameter - https://manpages.ubuntu.com/manpages/kinetic/en/man1/zshparam.1.html 496 | HISTORY_IGNORE="(cd ..|l[s]#( *)#|pwd *|exit *|date *|* --help)" 497 | 498 | # Set some options about directories 499 | setopt pushd_ignore_dups 500 | #setopt pushd_silent 501 | setopt AUTO_CD # If a command is issued that can’t be executed as a normal command, 502 | # and the command is the name of a directory, perform the cd command 503 | # to that directory. 504 | 505 | # Add some completions settings 506 | setopt ALWAYS_TO_END # Move cursor to the end of a completed word. 507 | setopt AUTO_LIST # Automatically list choices on ambiguous completion. 508 | setopt AUTO_MENU # Show completion menu on a successive tab press. 509 | setopt AUTO_PARAM_SLASH # If completed parameter is a directory, add a trailing slash. 510 | setopt COMPLETE_IN_WORD # Complete from both ends of a word. 511 | unsetopt MENU_COMPLETE # Do not autoselect the first completion entry. 512 | 513 | # Miscellaneous settings 514 | setopt INTERACTIVE_COMMENTS # Enable comments in interactive shell. 515 | 516 | setopt extended_glob # Enable more powerful glob features 517 | 518 | # Long running processes should return time after they complete. Specified 519 | # in seconds. 520 | REPORTTIME=${REPORTTIME:-2} 521 | 522 | TIMEFMT="%U user %S system %P cpu %*Es total" 523 | 524 | # How often to check for an update. If you want to override this, the 525 | # easiest way is to add a script fragment in ~/.zshrc.d that unsets 526 | # QUICKSTART_KIT_REFRESH_IN_DAYS. 527 | QUICKSTART_KIT_REFRESH_IN_DAYS=7 528 | 529 | # Disable Oh-My-ZSH's internal updating. Let it get updated when user 530 | # does a zgenom update. Closes #62. 531 | DISABLE_AUTO_UPDATE=true 532 | 533 | if [[ $(_zqs-get-setting handle-bindkeys true) == 'true' ]]; then 534 | # Expand aliases inline - see http://blog.patshead.com/2012/11/automatically-expaning-zsh-global-aliases---simplified.html 535 | globalias() { 536 | if [[ $LBUFFER =~ ' [A-Z0-9]+$' ]]; then 537 | zle _expand_alias 538 | zle expand-word 539 | fi 540 | zle self-insert 541 | } 542 | 543 | zle -N globalias 544 | 545 | bindkey " " globalias 546 | bindkey "^ " magic-space # control-space to bypass completion 547 | bindkey -M isearch " " magic-space # normal space during searches 548 | fi 549 | 550 | # Make it easier to customize the quickstart to your needs without 551 | # having to maintain your own fork. 552 | 553 | # Stuff that works on bash or zsh 554 | if [ -r ~/.sh_aliases ]; then 555 | source ~/.sh_aliases 556 | fi 557 | 558 | # Stuff only tested on zsh, or explicitly zsh-specific 559 | if [ -r ~/.zsh_aliases ]; then 560 | source ~/.zsh_aliases 561 | fi 562 | 563 | export LOCATE_PATH=/var/db/locate.database 564 | 565 | # Load AWS credentials when present 566 | if [ -f ~/.aws/aws_variables ]; then 567 | source ~/.aws/aws_variables 568 | fi 569 | 570 | # JAVA setup - needed for iam-* tools 571 | if [ -d /Library/Java/Home ];then 572 | export JAVA_HOME=/Library/Java/Home 573 | fi 574 | 575 | if [[ "$(uname -s)" == "Darwin" ]]; then 576 | # Load macOS-specific aliases 577 | # Apple renamed the OS, so use the macos one first 578 | [ -r ~/.macos_aliases ] && source ~/.macos_aliases 579 | if [ -d ~/.macos_aliases.d ]; then 580 | load-shell-fragments ~/.macos_aliases.d 581 | fi 582 | 583 | # Keep supporting the old name, but emit a deprecation warning 584 | [ -r ~/.osx_aliases ] && source ~/.osx_aliases 585 | if [ -d ~/.osx_aliases.d ]; then 586 | echo "Apple renamed the os to macos - the .osx_aliases.d directory is deprecated in favor of .macos_aliases.d" 587 | load-shell-fragments ~/.osx_aliases.d 588 | fi 589 | fi 590 | 591 | # deal with screen, if we're using it - courtesy MacOSXHints.com 592 | # Login greeting ------------------ 593 | if [ "$TERM" = "screen" -a ! "$SHOWED_SCREEN_MESSAGE" = "true" ]; then 594 | detached_screens=$(screen -list | grep Detached) 595 | if [ ! -z "$detached_screens" ]; then 596 | echo "+---------------------------------------+" 597 | echo "| Detached screens are available: |" 598 | echo "$detached_screens" 599 | echo "+---------------------------------------+" 600 | fi 601 | fi 602 | 603 | # These need to be done after $PATH is set up so we can find 604 | # grc and exa 605 | 606 | # Set up colorized ls when gls is present - it's installed by grc 607 | # shellcheck disable=SC2154 608 | if (( $+commands[gls] )); then 609 | alias ls="gls -F --color" 610 | alias l="gls -lAh --color" 611 | alias ll="gls -l --color" 612 | alias la='gls -A --color' 613 | fi 614 | 615 | # When present, use exa or eza (newest) instead of ls 616 | if can_haz eza; then 617 | ls_analog='eza' 618 | elif can_haz exa; then 619 | ls_analog='exa' 620 | fi 621 | 622 | if [ -v ls_analog ]; then 623 | if [[ "$($ls_analog --help | grep -c git)" == 0 ]]; then 624 | # Not every linux exa build has git support compiled in 625 | alias l="$ls_analog -al --icons --time-style=long-iso --group-directories-first --color-scale" 626 | else 627 | alias l="$ls_analog -al --icons --git --time-style=long-iso --group-directories-first --color-scale" 628 | fi 629 | alias ls="$ls_analog --group-directories-first" 630 | 631 | # Don't step on system-installed tree command 632 | if ! can_haz tree; then 633 | if [[ -z "$TREE_IGNORE" ]]; then 634 | TREE_IGNORE=".cache|cache|node_modules|vendor|.git" 635 | fi 636 | alias tree="$ls_analog --tree --ignore-glob='$TREE_IGNORE'" 637 | fi 638 | unset ls_analog 639 | fi 640 | 641 | # Speed up autocomplete, force prefix mapping 642 | zstyle ':completion:*' accept-exact '*(N)' 643 | zstyle ':completion:*' use-cache on 644 | zstyle ':completion:*' cache-path ~/.zsh/cache 645 | zstyle -e ':completion:*:default' list-colors 'reply=("${PREFIX:+=(#bi)($PREFIX:t)*==34=34}:${(s.:.)LS_COLORS}")'; 646 | 647 | # Load any custom zsh completions we've installed 648 | if [[ -d ~/.zsh-completions.d ]]; then 649 | load-shell-fragments ~/.zsh-completions.d 650 | fi 651 | if [[ -d ~/.zsh-completions ]]; then 652 | echo '~/.zsh_completions is deprecated in favor of ~/.zsh_completions.d' 653 | load-shell-fragments ~/.zsh-completions 654 | fi 655 | 656 | # Load zmv 657 | if [[ $(_zqs-get-setting no-zmv false) == 'false' ]]; then 658 | autoload -U zmv 659 | fi 660 | 661 | # Make it easy to append your own customizations that override the 662 | # quickstart's defaults by loading all files from the ~/.zshrc.d directory 663 | mkdir -p ~/.zshrc.d 664 | load-shell-fragments ~/.zshrc.d 665 | 666 | if [[ -d "$HOME/.zshrc.$(uname).d" ]]; then 667 | load-shell-fragments "$HOME/.zshrc.$(uname).d" 668 | fi 669 | 670 | # Load work-specific fragments when present 671 | if [[ -d "$HOME/.zshrc.work.d" ]]; then 672 | load-shell-fragments "$HOME/.zshrc.work.d" 673 | fi 674 | 675 | # If GOPATH is defined, add it to $PATH 676 | if [[ -n "$GOPATH" ]]; then 677 | if [[ -d "$GOPATH" ]]; then 678 | export PATH="$PATH:$GOPATH" 679 | fi 680 | fi 681 | 682 | # Now that .zshrc.d has been processed, we dedupe $PATH using a ZSH builtin 683 | # https://til.hashrocket.com/posts/7evpdebn7g-remove-duplicates-in-zsh-path 684 | typeset -aU path; 685 | 686 | # If desk is installed, load the Hook for desk activation 687 | [[ -n "$DESK_ENV" ]] && source "$DESK_ENV" 688 | 689 | # Do selfupdate checking. We do this after processing ~/.zshrc.d to make the 690 | # refresh check interval easier to customize. 691 | # 692 | # If they unset QUICKSTART_KIT_REFRESH_IN_DAYS in one of the fragments 693 | # in ~/.zshrc.d, then we don't do any selfupdate checking at all. 694 | 695 | _load-lastupdate-from-file() { 696 | local now=$(date +%s) 697 | if [[ -f "${1}" ]]; then 698 | local last_update=$(cat "${1}") 699 | else 700 | local last_update=0 701 | fi 702 | local interval="$(expr ${now} - ${last_update})" 703 | echo "${interval}" 704 | } 705 | 706 | _update-zsh-quickstart() { 707 | local _zshrc_loc=~/.zshrc 708 | if [[ ! -L "${_zshrc_loc}" ]]; then 709 | echo ".zshrc is not a symlink, skipping zsh-quickstart-kit update" 710 | else 711 | local _link_loc=${_zshrc_loc:A}; 712 | if [[ "${_link_loc/${HOME}}" == "${_link_loc}" ]]; then 713 | pushd $(dirname "${HOME}/${_zshrc_loc:A}"); 714 | else 715 | pushd $(dirname ${_link_loc}); 716 | fi; 717 | local gitroot=$(git rev-parse --show-toplevel) 718 | if [[ -f "${gitroot}/.gitignore" ]]; then 719 | if [[ $(grep -c zsh-quickstart-kit "${gitroot}/.gitignore") -ne 0 ]]; then 720 | # Cope with switch from master to main 721 | zqs_current_branch=$(git rev-parse --abbrev-ref HEAD) 722 | git fetch 723 | # Determine the repo default branch and switch to it unless we're in testing mode 724 | zqs_default_branch="$(git remote show origin | grep 'HEAD branch' | awk '{print $3}')" 725 | if [[ "$zqs_current_branch" == 'master' ]]; then 726 | echo "The ZSH Quickstart Kit has switched default branches to $zqs_default_branch" 727 | echo "Changing branches in your local checkout from $zqs_current_branch to $zqs_default_branch" 728 | git checkout "$zqs_default_branch" 729 | fi 730 | if [[ "$zqs_current_branch" != "$zqs_default_branch" ]]; then 731 | echo "Using $zqs_current_branch instead of $zqs_default_branch" 732 | fi 733 | echo "---- updating $zqs_current_branch ----" 734 | git pull 735 | date +%s >! ~/.zsh-quickstart-last-update 736 | unset zqs_default_branch 737 | unset zqs_current_branch 738 | fi 739 | else 740 | echo 'No quickstart marker found, is your quickstart directory a valid git checkout?' 741 | fi 742 | popd 743 | fi 744 | } 745 | 746 | _check-for-zsh-quickstart-update() { 747 | local day_seconds=$(expr 24 \* 60 \* 60) 748 | local refresh_seconds=$(expr "${day_seconds}" \* "${QUICKSTART_KIT_REFRESH_IN_DAYS}") 749 | local last_quickstart_update=$(_load-lastupdate-from-file ~/.zsh-quickstart-last-update) 750 | 751 | if [ ${last_quickstart_update} -gt ${refresh_seconds} ]; then 752 | echo "It has been $(expr ${last_quickstart_update} / ${day_seconds}) days since your zsh quickstart kit was updated" 753 | echo "Checking for zsh-quickstart-kit updates..." 754 | _update-zsh-quickstart 755 | fi 756 | } 757 | 758 | if [[ ! -z "$QUICKSTART_KIT_REFRESH_IN_DAYS" ]]; then 759 | _check-for-zsh-quickstart-update 760 | # unset QUICKSTART_KIT_REFRESH_IN_DAYS 761 | fi 762 | 763 | # Fix bracketed paste issue 764 | # Closes #73 765 | ZSH_AUTOSUGGEST_CLEAR_WIDGETS+=(bracketed-paste) 766 | 767 | # Load iTerm shell integrations if found. 768 | test -e "${HOME}/.iterm2_shell_integration.zsh" && source "${HOME}/.iterm2_shell_integration.zsh" 769 | 770 | # To customize your prompt, run `p10k configure` or edit ~/.p10k.zsh. 771 | if [[ ! -f ~/.p10k.zsh ]]; then 772 | echo "Run p10k configure or edit ~/.p10k.zsh to configure your prompt" 773 | else 774 | source ~/.p10k.zsh 775 | fi 776 | 777 | if [[ $(_zqs-get-setting list-ssh-keys true) == 'true' ]]; then 778 | echo 779 | echo "Current SSH Keys:" 780 | ssh-add -l 781 | echo 782 | fi 783 | 784 | if [[ $(_zqs-get-setting control-c-decorator 'true') == 'true' ]]; then 785 | # Original source: https://vinipsmaker.wordpress.com/2014/02/23/my-zsh-config/ 786 | # bash prints ^C when you're typing a command and control-c to cancel, so it 787 | # is easy to see it wasn't executed. By default, ZSH doesn't print the ^C. 788 | # We trap SIGINT to make it print the ^C. 789 | TRAPINT() { 790 | print -n -u2 '^C' 791 | return $((128+$1)) 792 | } 793 | fi 794 | 795 | if ! can_haz fzf; then 796 | echo "$?" 797 | echo "You'll need to install fzf or your history search will be broken." 798 | echo 799 | echo 800 | echo "Install instructions can be found at https://github.com/junegunn/fzf/" 801 | fi 802 | 803 | function zqs-help() { 804 | echo "The zqs command allows you to manipulate your ZSH quickstart." 805 | echo 806 | echo "Quickstart action commands:" 807 | echo "zqs check-for-updates - Update the quickstart kit if it has been longer than $QUICKSTART_KIT_REFRESH_IN_DAYS days since the last update." 808 | echo "zqs selfupdate - Force an immediate update of the quickstart kit" 809 | echo "zqs update - Update the quickstart kit and all your plugins" 810 | echo "zqs update-plugins - Update your plugins" 811 | echo "zqs cleanup - Cleanup unused plugins after removing them from the list" 812 | echo "" 813 | echo "Quickstart settings commands:" 814 | 815 | echo "zqs disable-1password-agent - New sessions will not use 1Password's ssh agent" 816 | echo "zqs enable-1password-agent - New sessions will use 1Password's ssh agent if present." 817 | 818 | echo "zqs disable-bindkey-handling - Set the quickstart to not touch any bindkey settings. Useful if you're using another plugin to handle it." 819 | echo "zqs enable-bindkey-handling - Set the quickstart to configure your bindkey settings. This is the default behavior." 820 | 821 | echo "zqs enable-control-c-decorator - Creates a TRAPINT function to display '^C' when you type control-c instead of being silent. Default behavior." 822 | echo "zqs disable-control-c-decorator - No longer creates a TRAPINT function to display '^C' when you type control-c." 823 | 824 | echo "zqs enable-diff-so-fancy - Load the diff-so-fancy ZSH plugin (defaults to true)" 825 | echo "zqs disable-diff-so-fancy - Don't load the diff-so-fancy ZSH plugin" 826 | 827 | echo "zqs disable-omz-plugins - Set the quickstart to not load oh-my-zsh plugins if you're using the standard plugin list" 828 | echo "zqs enable-omz-plugins - Set the quickstart to load oh-my-zsh plugins if you're using the standard plugin list" 829 | 830 | echo "zqs enable-ssh-askpass-require - Set the quickstart to prompt for your ssh passphrase on the command line." 831 | echo "zqs disable-ssh-askpass-require - Set the quickstart to prompt for your ssh passphrase via a gui program. This is the default behavior" 832 | 833 | echo "zqs disable-ssh-key-listing - Set the quickstart to not display all the loaded ssh keys" 834 | echo "zqs enable-ssh-key-listing - Set the quickstart to display all the loaded ssh keys. This is the default behavior." 835 | 836 | echo "zqs disable-ssh-key-loading - Set the quickstart to not load your ssh keys. Useful if you're storing them in a yubikey." 837 | echo "zqs enable-ssh-key-loading - Set the quickstart to load your ssh keys if they aren't already in an ssh agent. This is the default behavior." 838 | 839 | echo "zqs disable-zmv-autoloading - Set the quickstart to not run 'autoload -U zmv'. Useful if you're using another plugin to handle it." 840 | echo "zqs enable-zmv-autoloading - Set the quickstart to run 'autoload -U zmv'. This is the default behavior." 841 | 842 | echo "zqs delete-setting SETTINGNAME - Remove a zqs setting file" 843 | echo "zqs get-setting SETTINGNAME [optional default value] - load a zqs setting" 844 | echo "zqs set-setting SETTINGNAME value - Set an arbitrary zqs setting" 845 | } 846 | 847 | function zqs() { 848 | case "$1" in 849 | 'check-for-updates') 850 | _check-for-zsh-quickstart-update 851 | ;; 852 | 853 | # Internal commands 854 | 'cleanup') 855 | zgenom clean 856 | ;; 857 | 858 | 'delete-setting') 859 | shift 860 | _zqs-delete-setting $@ 861 | ;; 862 | 863 | 'get-setting') 864 | shift 865 | _zqs-get-setting $@ 866 | ;; 867 | 868 | 'selfupdate') 869 | _update-zsh-quickstart 870 | ;; 871 | 872 | 'set-setting') 873 | shift 874 | _zqs-set-setting $@ 875 | ;; 876 | 877 | 'update') 878 | _update-zsh-quickstart 879 | zgenom update 880 | ;; 881 | 882 | 'update-plugins') 883 | zgenom update 884 | ;; 885 | 886 | # Set/Unset settings 887 | 888 | 'disable-1password-agent') 889 | echo "Disabling 1password ssh-agent. New ZSH sessions will no longer use 1password's ssh agent." 890 | _zqs-set-setting use-1password-ssh-agent false 891 | ;; 892 | 'enable-1password-agent') 893 | echo "Enabling 1password ssh-agent. New ZSH sessions will use 1password's ssh agent." 894 | _zqs-set-setting use-1password-ssh-agent true 895 | ;; 896 | 897 | 'disable-bindkey-handling') 898 | zsh-quickstart-disable-bindkey-handling 899 | ;; 900 | 'enable-bindkey-handling') 901 | zsh-quickstart-enable-bindkey-handling 902 | ;; 903 | 904 | 'disable-control-c-decorator') 905 | zqs-quickstart-disable-control-c-decorator 906 | ;; 907 | 'enable-control-c-decorator') 908 | zqs-quickstart-enable-control-c-decorator 909 | ;; 910 | 'disable-debug-mode') 911 | rm -f ~/.zqs-debug-mode 912 | ;; 913 | 'enable-debug-mode') 914 | date > ~/.zqs-debug-mode 915 | ;; 916 | 917 | 'disable-diff-so-fancy') 918 | echo "Disabling diff-so-fancy plugin. New ZSH sessions will no longer use the plugin." 919 | _zqs-set-setting diff-so-fancy false 920 | ;; 921 | 'enable-diff-so-fancy') 922 | echo "Enabling diff-so-fancy plugin. It will be loaded the next time you start a ZSH session." 923 | _zqs-set-setting diff-so-fancy true 924 | ;; 925 | 926 | 'disable-zmv-autoloading') 927 | _zqs-disable-zmv-autoloading 928 | ;; 929 | 'enable-zmv-autoloading') 930 | _zqs-enable-zmv-autoloading 931 | ;; 932 | 933 | 'disable-omz-plugins') 934 | zsh-quickstart-disable-omz-plugins 935 | ;; 936 | 'enable-omz-plugins') 937 | zsh-quickstart-enable-omz-plugins 938 | ;; 939 | 940 | 'enable-ssh-askpass-require') 941 | zsh-quickstart-enable-ssh-askpass-require 942 | ;; 943 | 'disable-ssh-askpass-require') 944 | zsh-quickstart-disable-ssh-askpass-require 945 | ;; 946 | 947 | 'enable-ssh-key-listing') 948 | _zqs-set-setting list-ssh-keys true 949 | ;; 950 | 'disable-ssh-key-listing') 951 | _zqs-set-setting list-ssh-keys false 952 | ;; 953 | 954 | 'disable-ssh-key-loading') 955 | _zqs-set-setting load-ssh-keys false 956 | ;; 957 | 'enable-ssh-key-loading') 958 | _zqs-set-setting load-ssh-keys true 959 | ;; 960 | 961 | # Profiling checks happen before the settings code is loaded, so we 962 | # touch the actual file instead of reading via _zqs-get-setting 963 | 'disable-zsh-profiling') 964 | rm -f ~/.zqs-zprof-enabled 965 | echo "New ZSH sessions will no longer use profiling." 966 | ;; 967 | 'enable-zsh-profiling') 968 | touch ~/.zqs-zprof-enabled 969 | echo "New ZSH sessions will use profiling." 970 | ;; 971 | *) 972 | zqs-help 973 | ;; 974 | 975 | esac 976 | } 977 | 978 | if [[ -f ~/.zqs-zprof-enabled ]]; then 979 | zprof 980 | fi 981 | -------------------------------------------------------------------------------- /zsh/.zshrc.d/001-load-mise-if-present: -------------------------------------------------------------------------------- 1 | if [ -f ~/.local/bin/mise ]; then 2 | eval "$(~/.local/bin/mise activate zsh)" 3 | elif [ -f /opt/homebrew/bin/mise ]; then 4 | eval "$(/opt/homebrew/bin/mise activate zsh --shims)" 5 | elif [ -f /usr/local/bin/mise ]; then 6 | eval "$(/usr/local/bin/mise activate zsh)" 7 | fi 8 | --------------------------------------------------------------------------------