166 lines
6.0 KiB
Plaintext
166 lines
6.0 KiB
Plaintext
# User run commands file for interactive zsh(1) shells.
|
|
|
|
#
|
|
# Copyright (C) 2019, 2022 VHS <vhsdev@tutanota.com>
|
|
#
|
|
# This file is part of Archuro.
|
|
#
|
|
# Archuro is free software: you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published
|
|
# by the Free Software Foundation, either version 3 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# Archuro is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
#
|
|
|
|
# =========================================================================== #
|
|
# Performance profiling
|
|
# =================================================================== #
|
|
|
|
# Uncomment to use profiling module
|
|
# $ zprof
|
|
# zmodload zsh/zprof
|
|
|
|
# Test shell startup speed over 10 invocations
|
|
# $ for i in $(seq 1 10); do /usr/bin/time zsh -i -c exit; done
|
|
# @see https://carlosbecker.com/posts/speeding-up-zsh/
|
|
|
|
# =========================================================================== #
|
|
# Emulate Bourne shell and load its profile settings
|
|
# =================================================================== #
|
|
|
|
# Read profile settings. By default macOS Catalina (v10.15) ships with Z shell
|
|
# as the default shell so we start by checking the current shell and emulating
|
|
# sh in the Z shell case and use a more portable, POSIX-compliant profile.
|
|
# @see https://support.apple.com/en-us/HT208050
|
|
[[ -e ~/.profile ]] && emulate sh -c 'source ~/.profile'
|
|
|
|
# =========================================================================== #
|
|
# Command completions
|
|
# =================================================================== #
|
|
|
|
# Enable advanced tab-completion with improved completion appearance
|
|
# @see https://wiki.gentoo.org/wiki/Zsh/Guide
|
|
autoload -Uz compinit; compinit
|
|
zstyle ':completion:*:descriptions' format '%U%B%d%b%u'
|
|
zstyle ':completion:*:warnings' format '%BSorry, no matches for: %d%b'
|
|
|
|
# =========================================================================== #
|
|
# Auto suggestions (Enable manaually)
|
|
# =================================================================== #
|
|
|
|
# Zsh Augosuggestions
|
|
# Requires manual install
|
|
# https://github.com/zsh-users/zsh-autosuggestions
|
|
[ -f ~/.zsh/zsh-autosuggestions/zsh-autosuggestions.zsh ] && \
|
|
source ~/.zsh/zsh-autosuggestions/zsh-autosuggestions.zsh
|
|
|
|
# Check for color support and set color bit
|
|
# @see https://unix.stackexchange.com/a/198949/111911
|
|
color=0
|
|
if tput Co > /dev/null 2>&1; then
|
|
test "`tput Co`" -gt 2 && color=1
|
|
elif tput colors > /dev/null 2>&1; then
|
|
test "`tput colors`" -gt 2 && color=1
|
|
fi
|
|
|
|
# =========================================================================== #
|
|
# Do not record commands with a preceding space
|
|
# =================================================================== #
|
|
|
|
setopt histignorespace
|
|
|
|
# =========================================================================== #
|
|
# History search (@see also stow/dot-bashrc)
|
|
# =================================================================== #
|
|
|
|
# NOT WORKING!
|
|
|
|
# By doing this, only the past commands matching the current line up to the
|
|
# current cursor position will be shown when Up or Down keys are pressed.
|
|
# @see https://wiki.archlinux.org/index.php/Zsh
|
|
|
|
autoload -Uz up-line-or-beginning-search down-line-or-beginning-search
|
|
zle -N up-line-or-beginning-search
|
|
zle -N down-line-or-beginning-search
|
|
|
|
[[ -n "${key[Up]}" ]] && bindkey -- "${key[Up]}" up-line-or-beginning-search
|
|
[[ -n "${key[Down]}" ]] && bindkey -- "${key[Down]}" down-line-or-beginning-search
|
|
|
|
# =========================================================================== #
|
|
# Colorize output of less and more - @see also zshenv
|
|
# =================================================================== #
|
|
|
|
alias less="less -R"
|
|
alias more="more -R"
|
|
|
|
# =========================================================================== #
|
|
# Platform-specific modifications
|
|
# =================================================================== #
|
|
|
|
if [[ "$OSTYPE" == linux-gnu* ]]; then
|
|
alias ls='ls --color=auto' # Colorize output of ls
|
|
fi
|
|
|
|
# =========================================================================== #
|
|
# Application-specific settings
|
|
# =================================================================== #
|
|
|
|
# Use GPG-agent for SSH authentication
|
|
# https://gregrs-uk.github.io/2018-08-06/gpg-key-ssh-mac-debian/
|
|
export GPG_TTY=$(tty)
|
|
export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket)
|
|
gpgconf --launch gpg-agent
|
|
|
|
# Enable Starship prompt
|
|
# @see https://starship.rs/
|
|
eval "$(starship init zsh)"
|
|
|
|
# Enable Fast Node Manager
|
|
# @see https://github.com/Schniz/fnm
|
|
# Changes Node based on project with .node-version file
|
|
eval "$(fnm env --use-on-cd)"
|
|
|
|
# rupa/z - Jump to any visited directory using the frecency algorithm
|
|
# $ z desk && pwd
|
|
# # => /Users/username/Desktop
|
|
[[ -r /usr/local/bin/z.sh ]] && . /usr/local/bin/z.sh
|
|
|
|
# Run Arch Linux when Hyper is opened given requirements
|
|
# @requires [command] docker
|
|
# @requires [command] archuro
|
|
# [[ "$TERM_PROGRAM" == "Hyper" ]] && [[ -x "$(command -v archuro)" ]] && \
|
|
# [[ -x "$(command -v docker)" ]] && archuro tty
|
|
|
|
# Sort duplicates grouped by count descending
|
|
# @see [alias] gls
|
|
# $ git log --no-merges --pretty=format:"%ae" | stats
|
|
# # => 514 a@example.com
|
|
# # => 200 b@example.com
|
|
function stats {
|
|
sort | uniq -c | sort -r
|
|
}
|
|
|
|
# Print terminal color code swatches
|
|
# # => 000 001 002 003 004 005 006 007
|
|
# # => 008 009 010 011 012 013 014 015
|
|
# # => ...
|
|
# # => 248 249 250 251 252 253 254 255
|
|
function colors () {
|
|
if [[ color -eq 1 ]]; then
|
|
for i in {0..255}; do print -Pn "%${i}F${(l:3::0:)i}%f " ${${(M)$((i%8)):#7}:+$'\n'}; done
|
|
else
|
|
echo "Sorry, pardner. ${TERM:-"Your terminal"} doesn't support color display."
|
|
fi
|
|
}
|
|
|
|
|
|
export PNPM_HOME="/Users/jos/Library/pnpm"
|
|
export PATH="$PNPM_HOME:$PATH"
|