Compare commits
9
Commits
2f4de26581
..
server
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6fc74d4315 | ||
|
|
3e3fb7141e | ||
|
|
2afca7e6c3 | ||
|
|
0af702e3f3 | ||
|
|
06b0d9bc90 | ||
|
|
a44f109dc7 | ||
|
|
30d1e8c364 | ||
|
|
01222ba1da | ||
|
|
c9137564a1 |
@@ -3,3 +3,4 @@
|
||||
tags
|
||||
.DS_STORE
|
||||
__pycache__
|
||||
.env.local
|
||||
|
||||
@@ -26,5 +26,3 @@ else
|
||||
rm -rf $HOME/.config/nvim
|
||||
ln -Tsfv $PWD/nvim $HOME/.config/nvim
|
||||
fi
|
||||
|
||||
cat $PWD/ssh_tty | sudo tee /etc/sudoers.d/ssh_tty > /dev/null
|
||||
|
||||
+123
-4
@@ -19,9 +19,6 @@ if empty(glob(data_dir . '/autoload/plug.vim'))
|
||||
endif
|
||||
call plug#begin()
|
||||
|
||||
" Warn about plugin updates
|
||||
Plug 'semanser/vim-outdated-plugins'
|
||||
|
||||
" Powerline replacement
|
||||
Plug 'vim-airline/vim-airline'
|
||||
Plug 'vim-airline/vim-airline-themes'
|
||||
@@ -76,6 +73,129 @@ Plug 'fatih/vim-go'
|
||||
|
||||
call plug#end()
|
||||
|
||||
" Check for plugin updates after the editor is responsive.
|
||||
lua << EOF
|
||||
local function check_plugin_updates()
|
||||
local plugins = {}
|
||||
for name, plugin in pairs(vim.g.plugs or {}) do
|
||||
if vim.fn.isdirectory(plugin.dir) == 1 then
|
||||
table.insert(plugins, { name = name, dir = plugin.dir })
|
||||
end
|
||||
end
|
||||
table.sort(plugins, function(a, b) return a.name < b.name end)
|
||||
|
||||
local next_plugin = 1
|
||||
local active = 0
|
||||
local finished = 0
|
||||
local failures = 0
|
||||
local updates = {}
|
||||
local concurrency = 2
|
||||
|
||||
local function git_command(args)
|
||||
local command = { 'ionice', '-c', '3', 'nice', '-n', '10', 'git' }
|
||||
vim.list_extend(command, args)
|
||||
return command
|
||||
end
|
||||
|
||||
local function set_airline_status(message)
|
||||
vim.g.plugin_update_status = message
|
||||
local marker = '%{get(g:,"plugin_update_status","")}'
|
||||
local warning = vim.g.airline_section_warning or ''
|
||||
if not string.find(warning, 'plugin_update_status', 1, true) then
|
||||
vim.g.airline_section_warning = warning .. ' ' .. marker
|
||||
end
|
||||
if vim.fn.exists(':AirlineRefresh') == 2 then
|
||||
vim.cmd('AirlineRefresh')
|
||||
end
|
||||
end
|
||||
|
||||
local function report()
|
||||
if #updates > 0 then
|
||||
set_airline_status(string.format('[updates: %d]', #updates))
|
||||
local message = string.format(
|
||||
'%d plugin update%s available: %s',
|
||||
#updates,
|
||||
#updates == 1 and '' or 's',
|
||||
table.concat(updates, ', ')
|
||||
)
|
||||
if failures > 0 then
|
||||
message = message .. string.format(' (%d check%s failed)', failures, failures == 1 and '' or 's')
|
||||
end
|
||||
vim.notify(message, failures > 0 and vim.log.levels.WARN or vim.log.levels.INFO)
|
||||
elseif failures > 0 then
|
||||
set_airline_status('[update check failed]')
|
||||
vim.notify(
|
||||
string.format('Plugin update check incomplete: %d check%s failed', failures, failures == 1 and '' or 's'),
|
||||
vim.log.levels.WARN
|
||||
)
|
||||
else
|
||||
set_airline_status('')
|
||||
vim.notify('All plugins up-to-date', vim.log.levels.INFO)
|
||||
end
|
||||
end
|
||||
|
||||
local pump
|
||||
local function complete_one()
|
||||
active = active - 1
|
||||
finished = finished + 1
|
||||
if finished == #plugins then
|
||||
report()
|
||||
else
|
||||
pump()
|
||||
end
|
||||
end
|
||||
|
||||
local function check_one(plugin)
|
||||
active = active + 1
|
||||
vim.system(
|
||||
git_command({ '-C', plugin.dir, 'fetch', '--quiet', '--no-tags', 'origin' }),
|
||||
{ text = true, timeout = 20000 },
|
||||
vim.schedule_wrap(function(fetch_result)
|
||||
if fetch_result.code ~= 0 then
|
||||
failures = failures + 1
|
||||
complete_one()
|
||||
return
|
||||
end
|
||||
|
||||
vim.system(
|
||||
git_command({ '-C', plugin.dir, 'rev-list', '--count', 'HEAD..@{upstream}' }),
|
||||
{ text = true, timeout = 5000 },
|
||||
vim.schedule_wrap(function(count_result)
|
||||
local count = tonumber(vim.trim(count_result.stdout or ''))
|
||||
if count_result.code ~= 0 or count == nil then
|
||||
failures = failures + 1
|
||||
elseif count > 0 then
|
||||
table.insert(updates, plugin.name)
|
||||
end
|
||||
complete_one()
|
||||
end)
|
||||
)
|
||||
end)
|
||||
)
|
||||
end
|
||||
|
||||
pump = function()
|
||||
while active < concurrency and next_plugin <= #plugins do
|
||||
local plugin = plugins[next_plugin]
|
||||
next_plugin = next_plugin + 1
|
||||
check_one(plugin)
|
||||
end
|
||||
end
|
||||
|
||||
if #plugins > 0 then
|
||||
pump()
|
||||
end
|
||||
end
|
||||
|
||||
vim.api.nvim_create_autocmd('VimEnter', {
|
||||
group = vim.api.nvim_create_augroup('plugin_update_check', { clear = true }),
|
||||
once = true,
|
||||
callback = function()
|
||||
vim.defer_fn(check_plugin_updates, 1500)
|
||||
end,
|
||||
})
|
||||
EOF
|
||||
|
||||
" Run PlugInstall if there are missing plugins
|
||||
autocmd VimEnter * if len(filter(values(g:plugs), '!isdirectory(v:val.dir)'))
|
||||
\| PlugInstall --sync | source $MYVIMRC
|
||||
@@ -278,4 +398,3 @@ if filereadable(expand("~/python-envs/neovim/bin/python3"))
|
||||
else
|
||||
let g:python3_host_prog="/usr/bin/python3"
|
||||
endif
|
||||
|
||||
|
||||
@@ -1,64 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Usage: yank [FILE...]
|
||||
#
|
||||
# Copies the contents of the given files (or stdin if no files are given) to
|
||||
# the terminal that runs this program. If this program is run inside tmux(1),
|
||||
# then it also copies the given contents into tmux's current clipboard buffer.
|
||||
# If this program is run inside X11, then it also copies to the X11 clipboard.
|
||||
#
|
||||
# This is achieved by writing an OSC 52 escape sequence to the said terminal.
|
||||
# The maximum length of an OSC 52 escape sequence is 100_000 bytes, of which
|
||||
# 7 bytes are occupied by a "\033]52;c;" header, 1 byte by a "\a" footer, and
|
||||
# 99_992 bytes by the base64-encoded result of 74_994 bytes of copyable text.
|
||||
#
|
||||
# In other words, this program can only copy up to 74_994 bytes of its input.
|
||||
# However, in such cases, this program tries to bypass the input length limit
|
||||
# by copying directly to the X11 clipboard if a $DISPLAY server is available;
|
||||
# otherwise, it emits a warning (on stderr) about the number of bytes dropped.
|
||||
#
|
||||
# See http://en.wikipedia.org/wiki/Base64 for the 4*ceil(n/3) length formula.
|
||||
# See http://sourceforge.net/p/tmux/mailman/message/32221257 for copy limits.
|
||||
# See http://sourceforge.net/p/tmux/tmux-code/ci/a0295b4c2f6 for DCS in tmux.
|
||||
#
|
||||
# Written in 2014 by Suraj N. Kurapati and documented at http://goo.gl/NwYqfW
|
||||
|
||||
buf=$( cat "$@" )
|
||||
|
||||
|
||||
# Create the OSC52 escape string.
|
||||
len=$( printf %s "$buf" | wc -c ) max=74994
|
||||
test $len -gt $max && echo "$0: input is $(( len - max )) bytes too long" >&2
|
||||
esc="\033]52;c;$( printf %s "$buf" | head -c $max | base64 | tr -d '\r\n' )\a"
|
||||
test -n "$TMUX" && esc="\033Ptmux;\033$esc\033\\"
|
||||
|
||||
# Output the string to waiting terminals
|
||||
printf "$esc"
|
||||
|
||||
# Attempt to push to the raw SSH_TTY if that exists.
|
||||
test -n "$SSH_TTY" && printf "$esc" > $SSH_TTY
|
||||
|
||||
if [ -n "$TMUX" ]; then
|
||||
#push the OSC52 esc string to the clients directly.
|
||||
# tmux_clients=$(tmux list-clients -F "#{client_tty}")
|
||||
# readarray -t tmux_clients <<<"$tmux_clients"
|
||||
# for c in ${tmux_clients[@]}; do
|
||||
# printf "$esc" > $c
|
||||
# done
|
||||
#
|
||||
# And add it directly to the TMUX copy buffer.
|
||||
test -n "$TMUX" && tmux set-buffer "$buf"
|
||||
fi
|
||||
|
||||
# copy to X11 if possible...
|
||||
test -n "$DISPLAY" && command -v xsel > /dev/null && command -v xclip > /dev/null \
|
||||
&& printf %s "$buf" | { xsel -ib || xclip -sel c ;} && exit
|
||||
|
||||
# copy to pbcopy on MacOS
|
||||
command -v pbcopy > /dev/null && printf %s "$buf" | pbcopy
|
||||
|
||||
# Copy to remote pbcopy daemon, if attached
|
||||
if $(nc -z localhost 5556); then
|
||||
printf %s "$buf" | nc localhost 5556
|
||||
|
||||
fi
|
||||
+24
-152
@@ -1,18 +1,16 @@
|
||||
export PATH="/snap/bin:$HOME/.local/bin:$HOME/dotfiles/scripts:$PATH"
|
||||
export XDG_CONFIG_HOME="$HOME/.config" # Fix nvim bug
|
||||
|
||||
export PATH="/snap/bin:$HOME/.local/bin:$PATH"
|
||||
export XDG_CONFIG_HOME="$HOME/.config"
|
||||
|
||||
[[ -z $SSH_AUTH_SOCK ]] || export FORWARD_SOCK=$SSH_AUTH_SOCK
|
||||
|
||||
[[ -f ~/.zsh/.powerline_config ]] && source ~/.zsh/.powerline_config
|
||||
|
||||
if [[ -f ~/.zsh/.shared_config ]] && [[ "$SUDO_USER" != "fabian" ]] ; then
|
||||
if [[ -f ~/.zsh/.shared_config && "$SUDO_USER" != "fabian" ]]; then
|
||||
shared_config=1
|
||||
else
|
||||
shared_config=0
|
||||
fi
|
||||
|
||||
# Workaround for HOME directory in sudo nvim (caused by snap)
|
||||
# Work around snap's HOME handling for root.
|
||||
if [[ "$USER" == "root" ]]; then
|
||||
if [[ ! -e /home/root ]]; then
|
||||
ln -s /root/ /home/root
|
||||
@@ -20,182 +18,56 @@ if [[ "$USER" == "root" ]]; then
|
||||
ln -s /root/.config /home/root/.config
|
||||
fi
|
||||
fi
|
||||
[[ -f ~/.zsh/.shared_config ]] && touch ~/.config/nvim/.shared_config
|
||||
|
||||
if [[ -f ~/.zsh/.shared_config ]] ; then
|
||||
touch ~/.config/nvim/.shared_config
|
||||
fi
|
||||
source "${ZDOTDIR:-$HOME}/.zsh/lib/updates.zsh"
|
||||
|
||||
# On shell start, bring ~/dotfiles up to date by fast-forwarding the CURRENT
|
||||
# branch to its upstream only. Never rebase or stash in the background: if the
|
||||
# branch diverged or local edits block it, warn and leave it for a manual pull.
|
||||
# Per-branch, so `server` on each device fast-forwards to origin/server.
|
||||
update_dotfiles() {
|
||||
local repo="$HOME/dotfiles"
|
||||
# Bound the network call so a stalled fetch can't wedge this backgrounded
|
||||
# (&!) job into a days-long orphan holding unreaped children. `timeout` is
|
||||
# absent on macOS, so only use it when present. Disable ssh multiplexing so
|
||||
# no daemonized mux master can inherit and keep our fds open past git's exit.
|
||||
local -a TO; (( $+commands[timeout] )) && TO=(timeout -k 5 15)
|
||||
GIT_SSH_COMMAND='ssh -o BatchMode=yes -o ConnectTimeout=5 -o ControlMaster=no -o ControlPath=none' \
|
||||
$TO git -C "$repo" fetch --quiet </dev/null 2>/dev/null || return
|
||||
git -C "$repo" rev-parse --abbrev-ref '@{u}' >/dev/null 2>&1 || return # no upstream
|
||||
git -C "$repo" merge-base --is-ancestor '@{u}' HEAD 2>/dev/null && return # already current
|
||||
git -C "$repo" merge --ff-only --quiet '@{u}' 2>/dev/null \
|
||||
|| print -u2 "⚠ dotfiles: $(git -C "$repo" symbolic-ref --short HEAD) can't fast-forward to @{u} — run: git -C ~/dotfiles pull"
|
||||
}
|
||||
|
||||
update_dotfiles &!
|
||||
|
||||
if [ "$shared_config" -eq 0 ]; then
|
||||
if (( ! shared_config )); then
|
||||
export GIT_AUTHOR_NAME="Fabian Ising"
|
||||
export GIT_AUTHOR_EMAIL="f.ising@fh-muenster.de"
|
||||
export GIT_COMMITTER_NAME=$GIT_AUTHOR_NAME
|
||||
export GIT_COMMITTER_EMAIL=$GIT_AUTHOR_EMAIL
|
||||
fi
|
||||
|
||||
# On shell start, check the security tools repo for upstream updates and print a
|
||||
# one-line notice if the checkout is behind. Notify only (never auto-pull). This
|
||||
# stays read-only so it works even when the repo lives in root-owned /opt/tools:
|
||||
# - `safe.directory=*` sidesteps git's "dubious ownership" refusal on a repo
|
||||
# owned by root, which would otherwise fail every git command.
|
||||
# - `ls-remote` queries the remote without writing into .git (a normal user
|
||||
# can't write a root-owned .git, so `fetch` would fail there).
|
||||
# Uses the first candidate that is a git checkout; covers global and per-user layouts.
|
||||
check_tools_repo() {
|
||||
local repo branch remote mergeref remote_sha local_sha cmd
|
||||
# See update_dotfiles: bound the network probe (timeout, absent on macOS) and
|
||||
# disable ssh multiplexing so a stalled ls-remote can't orphan this &! job.
|
||||
local -a TO; (( $+commands[timeout] )) && TO=(timeout -k 5 10)
|
||||
for repo in /opt/tools "$HOME/tools" "$HOME/tools/tools-repo"; do
|
||||
local -a g=(git -c 'safe.directory=*' -C "$repo")
|
||||
$g rev-parse --is-inside-work-tree >/dev/null 2>&1 || continue
|
||||
branch=$($g symbolic-ref --short HEAD 2>/dev/null) || return
|
||||
remote=$($g config "branch.$branch.remote" 2>/dev/null) || return # no upstream
|
||||
mergeref=$($g config "branch.$branch.merge" 2>/dev/null) || return
|
||||
remote_sha=$(GIT_SSH_COMMAND='ssh -o BatchMode=yes -o ConnectTimeout=5 -o ControlMaster=no -o ControlPath=none' \
|
||||
$TO $g ls-remote "$remote" "$mergeref" </dev/null 2>/dev/null | awk '{print $1}')
|
||||
local_sha=$($g rev-parse HEAD 2>/dev/null)
|
||||
[[ -n "$remote_sha" && -n "$local_sha" ]] || return # remote unreachable
|
||||
[[ "$remote_sha" == "$local_sha" ]] && return # already current
|
||||
$g merge-base --is-ancestor "$remote_sha" HEAD 2>/dev/null && return # remote is an ancestor: ahead/equal (also true if we lack the object -> falls through to "behind")
|
||||
[[ -w "$repo/.git" ]] && cmd="git -C $repo pull" || cmd="sudo git -C $repo pull"
|
||||
print -u2 "⬆ tools: updates available in $repo — run: $cmd"
|
||||
return
|
||||
done
|
||||
}
|
||||
check_tools_repo &!
|
||||
# Completions for tools installed under ~/.local (e.g. tools-repo's safe*
|
||||
# wrappers). Must precede antidote, whose completion plugin runs compinit.
|
||||
fpath=("$HOME/.local/share/zsh/site-functions" $fpath)
|
||||
|
||||
# Load Antidote
|
||||
mkdir -p ${ZDOTDIR:-~}/.cache/zsh
|
||||
static_file=${ZDOTDIR:-~}/.cache/zsh/.zsh_plugins.zsh
|
||||
if [ $shared_config -eq 0 ]; then
|
||||
plugins_txt=${ZDOTDIR:-~}/.zsh/.zsh_plugins.txt
|
||||
# Vi mode
|
||||
static_file=${ZDOTDIR:-$HOME}/.cache/zsh/.zsh_plugins.zsh
|
||||
if (( ! shared_config )); then
|
||||
plugins_txt=${ZDOTDIR:-$HOME}/.zsh/.zsh_plugins.txt
|
||||
bindkey -v
|
||||
VI_MODE_SET_CURSOR=true
|
||||
else
|
||||
plugins_txt=${ZDOTDIR:-~}/.zsh/.zsh_plugins_shared.txt
|
||||
static_file=${ZDOTDIR:-~}/.cache/zsh/.zsh_shared_plugins.zsh
|
||||
fi
|
||||
# clone antidote if necessary
|
||||
if ! [[ -e ${ZDOTDIR:-~}/.antidote ]]; then
|
||||
git clone https://github.com/mattmc3/antidote.git ${ZDOTDIR:-~}/.antidote
|
||||
plugins_txt=${ZDOTDIR:-$HOME}/.zsh/.zsh_plugins_shared.txt
|
||||
static_file=${ZDOTDIR:-$HOME}/.cache/zsh/.zsh_shared_plugins.zsh
|
||||
fi
|
||||
source "${ZDOTDIR:-$HOME}/.zsh/lib/antidote.zsh"
|
||||
|
||||
#zstyle ':omz:plugins:docker' legacy-completion yes
|
||||
zstyle ':completion:*:ssh:*' hosts off
|
||||
zstyle ':completion:*:scp:*' hosts off
|
||||
|
||||
# Run rehash for external commands
|
||||
zstyle ":completion:*:commands" rehash 1
|
||||
# source antidote and load plugins from `${ZDOTDIR:-~}/.zsh_plugins.txt`
|
||||
source ${ZDOTDIR:-~}/.antidote/antidote.zsh
|
||||
antidote load ${plugins_txt} ${static_file}
|
||||
export SSH_REAL_SOCK=$SSH_AUTH_SOCK
|
||||
[[ -z $FORWARD_SOCK ]] || export SSH_AUTH_SOCK=$FORWARD_SOCK
|
||||
|
||||
setopt interactivecomments
|
||||
source "${ZDOTDIR:-$HOME}/.zsh/lib/interactive.zsh"
|
||||
|
||||
# History options
|
||||
HISTSIZE=100000 # Set the amount of lines you want saved
|
||||
SAVEHIST=100000 # This is required to actually save them, needs to match with HISTSIZE
|
||||
setopt EXTENDED_HISTORY # Write the history file in the ":start:elapsed;command" format.
|
||||
setopt INC_APPEND_HISTORY # Write to the history file immediately, not when the shell exits.
|
||||
setopt SHARE_HISTORY # Share history between all sessions.
|
||||
setopt HIST_EXPIRE_DUPS_FIRST # Expire duplicate entries first when trimming history.
|
||||
setopt HIST_IGNORE_DUPS # Don\'t record an entry that was just recorded again.
|
||||
setopt HIST_IGNORE_ALL_DUPS # Delete old recorded entry if new entry is a duplicate.
|
||||
setopt HIST_FIND_NO_DUPS # Do not display a line previously found.
|
||||
setopt HIST_IGNORE_SPACE # Don\'t record an entry starting with a space.
|
||||
setopt HIST_SAVE_NO_DUPS # Don\'t write duplicate entries in the history file.
|
||||
setopt HIST_REDUCE_BLANKS # Remove superfluous blanks before recording entry.
|
||||
# Clear screen by ctrl+q
|
||||
bindkey '^q' clear-screen
|
||||
|
||||
(( $+commands[nvim] )) && alias vim=nvim
|
||||
alias sudo='sudo '
|
||||
alias cgrep="grep --color=always"
|
||||
alias cdiff="git diff --color-words --no-index"
|
||||
(( $+commands[nvim] )) && export EDITOR='nvim'
|
||||
(( $+commands[nvim] )) && export VISUAL='nvim'
|
||||
|
||||
# Allow access to all libvirt vms
|
||||
export LIBVIRT_DEFAULT_URI="qemu:///system"
|
||||
|
||||
alias ls="ls --color=always"
|
||||
|
||||
if [ "$shared_config" -eq 0 ]; then
|
||||
# Use safecp/safemv from the tools-repo when available
|
||||
if (( ! shared_config )); then
|
||||
(( $+commands[safecp] )) && alias cp=safecp
|
||||
(( $+commands[safemv] )) && alias mv=safemv
|
||||
(( $+commands[safescp] )) && alias scp=safescp
|
||||
fi
|
||||
|
||||
delzip() {
|
||||
unzip -Z -1 "$@" | xargs -I{} rm -rf {}
|
||||
}
|
||||
# mitmproxy
|
||||
export MITMPROXY_SSLKEYLOGFILE="~/.mitmproxy/sslkeylogfile.txt"
|
||||
|
||||
[[ -f ~/.zsh/.mac_config ]] && source ~/.zsh/.mac_config
|
||||
|
||||
# Workaround for async issues https://github.com/romkatv/powerlevel10k/issues/1554
|
||||
unset ZSH_AUTOSUGGEST_USE_ASYNC
|
||||
|
||||
# Powerlevel 10k
|
||||
# Remove padding on right side
|
||||
ZLE_RPROMPT_INDENT=0
|
||||
|
||||
# To customize prompt, run `p10k configure` or edit ~/dotfiles/zsh/.p10k.zsh.
|
||||
function load_p10k() {
|
||||
if zmodload zsh/terminfo && (( terminfo[colors] >= 256 )) && [ $shared_config -eq 0 ]; then
|
||||
[[ ! -f ~/dotfiles/zsh/.p10k.zsh ]] || source ~/dotfiles/zsh/.p10k.zsh
|
||||
if zmodload zsh/terminfo && (( terminfo[colors] >= 256 )) && (( ! shared_config )); then
|
||||
p10k_config=~/dotfiles/zsh/.p10k.zsh
|
||||
else
|
||||
[[ ! -f ~/dotfiles/zsh/.p10k_shared.zsh ]] || source ~/dotfiles/zsh/.p10k_shared.zsh
|
||||
p10k_config=~/dotfiles/zsh/.p10k_shared.zsh
|
||||
fi
|
||||
}
|
||||
load_p10k
|
||||
#
|
||||
# This speeds up pasting w/ autosuggest
|
||||
# https://github.com/zsh-users/zsh-autosuggestions/issues/238
|
||||
pasteinit() {
|
||||
OLD_SELF_INSERT=${${(s.:.)widgets[self-insert]}[2,3]}
|
||||
zle -N self-insert url-quote-magic # I wonder if you'd need `.url-quote-magic`?
|
||||
}
|
||||
|
||||
pastefinish() {
|
||||
zle -N self-insert $OLD_SELF_INSERT
|
||||
}
|
||||
zstyle :bracketed-paste-magic paste-init pasteinit
|
||||
zstyle :bracketed-paste-magic paste-finish pastefinish
|
||||
# https://github.com/zsh-users/zsh-autosuggestions/issues/351
|
||||
ZSH_AUTOSUGGEST_CLEAR_WIDGETS+=(bracketed-paste)
|
||||
|
||||
export LANG="en_US.UTF-8"
|
||||
export LC_CTYPE="en_US.UTF-8"
|
||||
export TIME_STYLE="long-iso"
|
||||
source "${ZDOTDIR:-$HOME}/.zsh/lib/prompt.zsh"
|
||||
|
||||
[[ -f ~/.zsh/.user_config ]] && source ~/.zsh/.user_config
|
||||
[[ -f ~/.zsh/.virtual_env_config.zsh ]] && source ~/.zsh/.virtual_env_config.zsh
|
||||
[[ -f ~/.zsh/.local_config ]] && source ~/.zsh/.local_config
|
||||
[[ -f ~/.zsh/.os_config.zsh ]] && source ~/.zsh/.os_config.zsh
|
||||
|
||||
typeset -U path PATH
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
# Callers set plugins_txt and static_file before sourcing this module.
|
||||
mkdir -p "${static_file:h}"
|
||||
if [[ ! -e ${ZDOTDIR:-$HOME}/.antidote ]]; then
|
||||
git clone https://github.com/mattmc3/antidote.git "${ZDOTDIR:-$HOME}/.antidote"
|
||||
fi
|
||||
|
||||
zstyle ':completion:*:ssh:*' hosts off
|
||||
zstyle ':completion:*:scp:*' hosts off
|
||||
zstyle ':completion:*:commands' rehash 1
|
||||
|
||||
source "${ZDOTDIR:-$HOME}/.antidote/antidote.zsh"
|
||||
antidote load "$plugins_txt" "$static_file"
|
||||
@@ -0,0 +1,43 @@
|
||||
setopt interactivecomments
|
||||
|
||||
HISTSIZE=100000
|
||||
SAVEHIST=100000
|
||||
setopt EXTENDED_HISTORY
|
||||
setopt INC_APPEND_HISTORY
|
||||
setopt SHARE_HISTORY
|
||||
setopt HIST_EXPIRE_DUPS_FIRST
|
||||
setopt HIST_IGNORE_DUPS
|
||||
setopt HIST_IGNORE_ALL_DUPS
|
||||
setopt HIST_FIND_NO_DUPS
|
||||
setopt HIST_IGNORE_SPACE
|
||||
setopt HIST_SAVE_NO_DUPS
|
||||
setopt HIST_REDUCE_BLANKS
|
||||
|
||||
bindkey '^q' clear-screen
|
||||
(( $+commands[nvim] )) && alias vim=nvim
|
||||
(( $+commands[nvim] )) && export EDITOR=nvim VISUAL=nvim
|
||||
alias sudo='sudo '
|
||||
alias ls='ls --color=always'
|
||||
alias cgrep='grep --color=always'
|
||||
alias cdiff='git diff --color-words --no-index'
|
||||
|
||||
delzip() {
|
||||
unzip -Z -1 "$@" | xargs -I{} rm -rf {}
|
||||
}
|
||||
export MITMPROXY_SSLKEYLOGFILE='~/.mitmproxy/sslkeylogfile.txt'
|
||||
|
||||
unset ZSH_AUTOSUGGEST_USE_ASYNC
|
||||
export LANG='en_US.UTF-8'
|
||||
export LC_CTYPE='en_US.UTF-8'
|
||||
export TIME_STYLE='long-iso'
|
||||
|
||||
pasteinit() {
|
||||
OLD_SELF_INSERT=${${(s.:.)widgets[self-insert]}[2,3]}
|
||||
zle -N self-insert url-quote-magic
|
||||
}
|
||||
pastefinish() {
|
||||
zle -N self-insert "$OLD_SELF_INSERT"
|
||||
}
|
||||
zstyle :bracketed-paste-magic paste-init pasteinit
|
||||
zstyle :bracketed-paste-magic paste-finish pastefinish
|
||||
ZSH_AUTOSUGGEST_CLEAR_WIDGETS+=(bracketed-paste)
|
||||
@@ -0,0 +1,3 @@
|
||||
# Callers select p10k_config before sourcing this module.
|
||||
ZLE_RPROMPT_INDENT=0
|
||||
[[ -z "$p10k_config" || ! -f "$p10k_config" ]] || source "$p10k_config"
|
||||
@@ -0,0 +1,67 @@
|
||||
# Background repository maintenance shared by desktop and server shells.
|
||||
|
||||
update_dotfiles() {
|
||||
local repo="$HOME/dotfiles"
|
||||
local cache_dir="${ZDOTDIR:-$HOME}/.cache/zsh"
|
||||
local notice_file="$cache_dir/dotfiles-update-notice"
|
||||
local notice_tmp="$notice_file.$$.tmp"
|
||||
local -a TO; (( $+commands[timeout] )) && TO=(timeout -k 5 15)
|
||||
GIT_SSH_COMMAND='ssh -o BatchMode=yes -o ConnectTimeout=5 -o ControlMaster=no -o ControlPath=none' \
|
||||
$TO git -C "$repo" fetch --quiet </dev/null 2>/dev/null || return
|
||||
git -C "$repo" rev-parse --abbrev-ref '@{u}' >/dev/null 2>&1 || return
|
||||
git -C "$repo" merge-base --is-ancestor '@{u}' HEAD 2>/dev/null && return
|
||||
if git -C "$repo" merge --ff-only --quiet '@{u}' 2>/dev/null; then
|
||||
local notice="⬆ dotfiles updated — run: exec zsh"
|
||||
mkdir -p "$cache_dir" || return
|
||||
print -r -- "$notice" >| "$notice_tmp" || return
|
||||
mv -f "$notice_tmp" "$notice_file"
|
||||
return
|
||||
fi
|
||||
local notice="⚠ dotfiles: $(git -C "$repo" symbolic-ref --short HEAD) can't fast-forward to @{u} — run: git -C ~/dotfiles pull"
|
||||
mkdir -p "$cache_dir" || return
|
||||
print -r -- "$notice" >| "$notice_tmp" || return
|
||||
mv -f "$notice_tmp" "$notice_file"
|
||||
}
|
||||
update_dotfiles &!
|
||||
|
||||
check_tools_repo() {
|
||||
local repo branch remote mergeref remote_sha local_sha cmd notice
|
||||
local cache_dir="${ZDOTDIR:-$HOME}/.cache/zsh"
|
||||
local notice_file="$cache_dir/tools-update-notice"
|
||||
local notice_tmp="$notice_file.$$.tmp"
|
||||
local -a TO; (( $+commands[timeout] )) && TO=(timeout -k 5 10)
|
||||
for repo in /opt/tools "$HOME/tools" "$HOME/tools/tools-repo"; do
|
||||
local -a g=(git -c 'safe.directory=*' -C "$repo")
|
||||
$g rev-parse --is-inside-work-tree >/dev/null 2>&1 || continue
|
||||
branch=$($g symbolic-ref --short HEAD 2>/dev/null) || return
|
||||
remote=$($g config "branch.$branch.remote" 2>/dev/null) || return
|
||||
mergeref=$($g config "branch.$branch.merge" 2>/dev/null) || return
|
||||
remote_sha=$(GIT_SSH_COMMAND='ssh -o BatchMode=yes -o ConnectTimeout=5 -o ControlMaster=no -o ControlPath=none' \
|
||||
$TO $g ls-remote "$remote" "$mergeref" </dev/null 2>/dev/null | awk '{print $1}')
|
||||
local_sha=$($g rev-parse HEAD 2>/dev/null)
|
||||
[[ -n "$remote_sha" && -n "$local_sha" ]] || return
|
||||
[[ "$remote_sha" == "$local_sha" ]] && return
|
||||
$g merge-base --is-ancestor "$remote_sha" HEAD 2>/dev/null && return
|
||||
[[ -w "$repo/.git" ]] && cmd="git -C $repo pull" || cmd="sudo git -C $repo pull"
|
||||
notice="⬆ tools: updates available in $repo — run: $cmd"
|
||||
mkdir -p "$cache_dir" || return
|
||||
print -r -- "$notice" >| "$notice_tmp" || return
|
||||
mv -f "$notice_tmp" "$notice_file"
|
||||
return
|
||||
done
|
||||
}
|
||||
check_tools_repo &!
|
||||
|
||||
show_update_notices() {
|
||||
local cache_dir="${ZDOTDIR:-$HOME}/.cache/zsh"
|
||||
local notice_file claimed_notice
|
||||
for notice_file in "$cache_dir"/{dotfiles,tools}-update-notice; do
|
||||
[[ -s "$notice_file" ]] || continue
|
||||
claimed_notice="$notice_file.$$.show"
|
||||
mv "$notice_file" "$claimed_notice" 2>/dev/null || continue
|
||||
command cat "$claimed_notice"
|
||||
command rm -f "$claimed_notice"
|
||||
done
|
||||
}
|
||||
autoload -Uz add-zsh-hook
|
||||
add-zsh-hook precmd show_update_notices
|
||||
Reference in New Issue
Block a user