Created
May 14, 2021 23:27
-
-
Save luxus/840c680d3fe5356ce520556d3e0850ca to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/zsh | |
# {{@@ header() @@}} | |
# quck fix for tmux detach loosing ssh_socket | |
if [ ! -S ~/.ssh/ssh_auth_sock ] && [ -S "$SSH_AUTH_SOCK" ]; then | |
ln -sf $SSH_AUTH_SOCK ~/.ssh/ssh_auth_sock | |
fi | |
# | |
# Startup | |
# | |
# not running interactively then bail | |
[[ $- != *i* ]] && return | |
{%@@ if exists_in_path('keychain') @@%} | |
# use keychain to start ssh-agent | |
eval $(keychain --eval --quiet) | |
{%@@ endif @@%} | |
{%@@ if exists_in_path('sway-run') @@%} | |
# If running from tty1 start sway | |
if [ "$(tty)" = "/dev/tty1" ]; then | |
exec sway-run | |
fi | |
{%@@ endif @@%} | |
# | |
# zinit | |
# | |
if [[ ! -f $HOME/.zinit/bin/zinit.zsh ]]; then | |
print -P "%F{33}▓▒░ %F{220}Installing %F{33}DHARMA%F{220} Initiative Plugin Manager (%F{33}zdharma/zinit%F{220})…%f" | |
command mkdir -p "$HOME/.zinit" && command chmod g-rwX "$HOME/.zinit" | |
command git clone https://github.com/zdharma/zinit "$HOME/.zinit/bin" && \ | |
print -P "%F{33}▓▒░ %F{34}Installation successful.%f%b" || \ | |
print -P "%F{160}▓▒░ The clone has failed.%f%b" | |
fi | |
source "$HOME/.zinit/bin/zinit.zsh" | |
autoload -Uz _zinit | |
(( ${+_comps} )) && _comps[zinit]=_zinit | |
# Load a few important annexes, without Turbo | |
# (this is currently required for annexes) | |
zinit light-mode for \ | |
zinit-zsh/z-a-patch-dl \ | |
zinit-zsh/z-a-as-monitor \ | |
zinit-zsh/z-a-bin-gem-node \ | |
# | |
# Prompt | |
# | |
zinit lucid from'gh-r' as"command" for \ | |
atinit'export N_PREFIX="$HOME/n"; [[ :$PATH: == *":$N_PREFIX/bin:"* ]] || PATH+=":$N_PREFIX/bin"' \ | |
atload'eval "$(starship init zsh)"' \ | |
bpick'*unknown-linux*' \ | |
starship/starship | |
# | |
# Binaries | |
# | |
zinit wait"1a" lucid from"gh-r" as"null" for \ | |
sbin"**/fd" @sharkdp/fd \ | |
sbin"**/bat" @sharkdp/bat \ | |
sbin"pacaptr" rami3l/pacaptr \ | |
sbin"**/delta" dandavison/delta \ | |
sbin"fzf" bpick"*linux*.tar.gz" \ | |
junegunn/fzf \ | |
sbin"navi" atload'eval "$(navi widget zsh)"' \ | |
denisidoro/navi \ | |
sbin"**/zoxide" atload'eval "$(zoxide init zsh)"' \ | |
ajeetdsouza/zoxide \ | |
sbin"**/vivid" atload'export LS_COLORS="$(vivid generate molokai)"' \ | |
@sharkdp/vivid | |
# | |
# ZSH Plugins | |
# | |
zinit light yous/vanilli.sh # TODO do this by hand | |
zinit wait'0a' lucid for \ | |
zdharma/history-search-multi-word \ | |
atinit"ZINIT[COMPINIT_OPTS]=-C; zicompinit; zicdreplay" \ | |
zdharma/fast-syntax-highlighting \ | |
blockf \ | |
zsh-users/zsh-completions \ | |
atload"!_zsh_autosuggest_start" \ | |
zsh-users/zsh-autosuggestions | |
zinit wait'0b' lucid for \ | |
trigger-load'!fuck' atinit'zstyle ":prezto:module:thefuck" bindkey "no"' \ | |
laggardkernel/zsh-thefuck \ | |
trigger-load'!ga;!glo;!gi;!gd;!grh;!gcf;!gss;!gclean;!grb;!gcb;' \ | |
wfxr/forgit | |
# | |
# ZSH Function | |
# | |
# Get zsh to emit osc 7 escape sequences (for foot). This might be able to be | |
# moved to a zinit call instead | |
_urlencode() { | |
local length="${#1}" | |
for (( i = 0; i < length; i++ )); do | |
local c="${1:$i:1}" | |
case $c in | |
%) printf '%%%02X' "'$c" ;; | |
*) printf "%s" "$c" ;; | |
esac | |
done | |
} | |
osc7_cwd() { | |
printf '\e]7;file://%s%s\e\\' "$HOSTNAME" "$(_urlencode "$PWD")" | |
} | |
autoload -Uz add-zsh-hook | |
add-zsh-hook -Uz chpwd osc7_cwd | |
# | |
# Variables | |
# | |
ZLE_RPROMPT_INDENT=0 | |
export KEYTIMEOUT=1 | |
export MANPAGER="sh -c 'col -bx | bat -l man -p'" | |
export EDITOR=nvim | |
# | |
# Aliases | |
# | |
{%@@ if exists_in_path('pacman') == false @@%} | |
alias pacman='pacaptr' | |
{%@@ endif @@%} | |
alias mirrors='sudo reflector --score 100 --fastest 25 --sort rate --save /etc/pacman.d/mirrorlist --verbose' | |
alias colorpick='grim -g "$(slurp -p)" -t ppm - | convert - -format "%[hex:s]\n" info:-' | |
# general use exa | |
alias l='exa -lbF --git' # list, size, type, git | |
alias ll='exa -lbGF --git' # long list | |
alias llm='exa -lbGd --git --sort=modified' # long list, modified date sort | |
alias la='exa -lbhHigSa --time-style=long-iso --git --color-scale' # all list | |
alias lx='exa -lbhHigSa@ --time-style=long-iso --git --color-scale' # all + extended list | |
# specialty views exa | |
alias lS='exa -1' # one column, just names | |
alias lst='exa --tree --level=2' # tree | |
alias drop='dotdrop' | |
alias dropr='sudo dotdrop --cfg=/home/{{@@ username @@}}/.config/dotdrop/config-system.yaml' | |
alias dropsr='sudo -s eval $(grep -v "^#" {{@@ server_config @@}}/.env) dotdrop --cfg={{@@ server_config @@}}/config-system.yaml' | |
alias drops='eval $(grep -v "^#" {{@@ server_config @@}}/.env) dotdrop --cfg={{@@ server_config @@}}/config.yaml' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment