1
0
mirror of https://github.com/bertptrs/vimconfig.git synced 2025-12-25 12:30:32 +01:00

Improve nix support.

This commit is contained in:
2020-09-08 09:57:10 +02:00
parent d22d6b83cd
commit 845d6253e6
3 changed files with 55 additions and 4 deletions

3
.gitmodules vendored
View File

@@ -40,3 +40,6 @@
[submodule "zsh/.config/zsh/plugins/zsh-you-should-use"]
path = zsh/.config/zsh/plugins/zsh-you-should-use
url = https://github.com/MichaelAquilina/zsh-you-should-use.git
[submodule "zsh/.config/zsh/plugins/nix-zsh-completions"]
path = zsh/.config/zsh/plugins/nix-zsh-completions
url = https://github.com/spwhitt/nix-zsh-completions.git

View File

@@ -45,6 +45,7 @@ unset keyfile
plugins=(
zsh-autosuggestions/zsh-autosuggestions.zsh
zsh-you-should-use/you-should-use.plugin.zsh
nix-zsh-completions/nix-zsh-completions.plugin.zsh
)
for plugin in "${plugins[@]}"; do
@@ -53,6 +54,8 @@ for plugin in "${plugins[@]}"; do
fi
done
fpath+=("$ZDOTDIR/plugins/nix-zsh-completions")
## Autosuggest plugin configuration
# Consider autocomplete in completion
@@ -74,6 +77,7 @@ alias :q='exit'
alias wget="wget --hsts-file=\"$XDG_CACHE_HOME/wget-hsts\""
alias makej="make -j$(nproc)"
alias sdc='sudo docker-compose'
alias nrc='nix run -c'
# Not an alias but useful nonetheless.
function pasters() {
@@ -130,10 +134,28 @@ zle -N history-incremental-search-backward-end history-search-end
[[ -n "${key[PageDown]}" ]] && bindkey "${key[PageDown]}" history-beginning-search-forward
bindkey '^R' history-incremental-search-backward-end
# Syntax highlighting, if available.
if [[ -f /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh ]]; then
source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
fi
# Load optional plugins if installed on the host system.
find_system_plugin() {
local plugin=$1
local plugin_dirs=(
/usr/share/zsh/plugins
/usr/share
)
local dir
for dir in "${plugin_dirs[@]}"; do
if [[ -f "$dir/$plugin/$plugin.zsh" ]]; then
echo "$dir/$plugin/$plugin.zsh"
return
fi
done
# Safe placeholder
echo /dev/null
}
source $(find_system_plugin zsh-syntax-highlighting)
# Home and end keys working
bindkey "${key[Home]}" beginning-of-line
@@ -235,3 +257,28 @@ add-zsh-hook chpwd chpwd_recent_dirs
if (( $+commands[lesspipe] )); then
eval "$(lesspipe)"
fi
############################
# Special SSH key handling #
############################
if [[ -f ~/.ssh/id_ed25519 ]]; then
# gnome-keyring doesn't handle ed25519 keys properly; try setting up an alternative agent.
export SSH_ENV="$HOME/.ssh/environment"
start_agent() {
echo "Initialising new SSH agent..."
/usr/bin/ssh-agent | sed 's/^echo/#echo/' > "${SSH_ENV}"
echo Succeeded
chmod 600 "${SSH_ENV}"
. "${SSH_ENV}" > /dev/null
/usr/bin/ssh-add ~/.ssh/google_compute_engine >/dev/null 2>&1
}
if [ -f "${SSH_ENV}" ]; then
. "${SSH_ENV}" > /dev/null
kill -0 "$SSH_AGENT_PID" 2>/dev/null || { start_agent; }
else
start_agent
fi
fi