mirror of
https://github.com/ivuorinen/dotfiles.git
synced 2026-01-26 03:04:06 +00:00
chore(shell): documentation, cleanup
This commit is contained in:
@@ -19,7 +19,7 @@ indent_size = 1
|
||||
indent_size = 1
|
||||
indent_style = tab
|
||||
|
||||
[local/bin/*]
|
||||
[{local/bin/*,**/*.sh,**/zshrc}]
|
||||
shell_variant = bash # --language-variant
|
||||
binary_next_line = true
|
||||
switch_case_indent = true # --case-indent
|
||||
|
||||
@@ -5,3 +5,22 @@
|
||||
external-sources=true
|
||||
includeAllWorkspaceSymbols=true
|
||||
|
||||
# SC2039: In POSIX sh, 'local' is undefined.
|
||||
# https://github.com/koalaman/shellcheck/wiki/SC2039
|
||||
disable=SC2039
|
||||
|
||||
# SC2166: Prefer [ p ] || [ q ] as [ p -o q ] is not well defined.
|
||||
# https://github.com/koalaman/shellcheck/wiki/SC2166
|
||||
disable=SC2166
|
||||
|
||||
# SC2154: Variable is referenced but not assigned
|
||||
# https://github.com/koalaman/shellcheck/wiki/SC2154
|
||||
disable=SC2154
|
||||
|
||||
# SC1091: Not following <file>
|
||||
# https://github.com/koalaman/shellcheck/wiki/SC1091
|
||||
disable=SC1091
|
||||
|
||||
# SC2174: When used with -p, -m only applies to the deepest directory.
|
||||
# https://github.com/koalaman/shellcheck/wiki/SC2174
|
||||
disable=SC2174
|
||||
|
||||
24
base/vuerc
24
base/vuerc
@@ -1,24 +0,0 @@
|
||||
{
|
||||
"useTaobaoRegistry": false,
|
||||
"presets": {
|
||||
"v2-router-vuex-scss-prettier": {
|
||||
"useConfigFiles": false,
|
||||
"plugins": {
|
||||
"@vue/cli-plugin-babel": {},
|
||||
"@vue/cli-plugin-router": {
|
||||
"historyMode": false
|
||||
},
|
||||
"@vue/cli-plugin-vuex": {},
|
||||
"@vue/cli-plugin-eslint": {
|
||||
"config": "prettier",
|
||||
"lintOn": [
|
||||
"save"
|
||||
]
|
||||
}
|
||||
},
|
||||
"vueVersion": "2",
|
||||
"cssPreprocessor": "dart-sass"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
25
base/zshrc
25
base/zshrc
@@ -1,10 +1,3 @@
|
||||
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
|
||||
# Initialization code that may require console input (password prompts, [y/n]
|
||||
# confirmations, etc.) must go above this block; everything else may go below.
|
||||
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
|
||||
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
|
||||
fi
|
||||
|
||||
# this is my zsh config. there are many like it, but this one is mine.
|
||||
# shellcheck shell=bash
|
||||
|
||||
@@ -20,10 +13,19 @@ function x-load-configs()
|
||||
{
|
||||
# Load the shell dotfiles, and then some:
|
||||
for file in $DOTFILES/config/{exports,alias,functions}; do
|
||||
HOST="$(hostname -s)"
|
||||
# global (exports|alias|functions) file for all hosts
|
||||
# shellcheck source=../config/exports
|
||||
[ -r "$file" ] && source "$file"
|
||||
# global secret file, git ignored
|
||||
# shellcheck source=../config/exports-secret
|
||||
[ -r "$file-secret" ] && source "$file-secret"
|
||||
[ -r "$file-$HOSTNAME" ] && source "$file-$HOSTNAME"
|
||||
[ -r "$file-$HOSTNAME-secret" ] && source "$file-$HOSTNAME-secret"
|
||||
# host specific (exports|alias|functions) file
|
||||
# shellcheck source=../config/exports
|
||||
[ -r "$file-$HOST" ] && source "$file-$HOST"
|
||||
# host specific (exports|alias|functions) file, git ignored
|
||||
# shellcheck source=../config/exports
|
||||
[ -r "$file-$HOST-secret" ] && source "$file-$HOST-secret"
|
||||
done
|
||||
}
|
||||
x-load-configs
|
||||
@@ -32,7 +34,6 @@ export HISTFILE="$XDG_STATE_HOME"/zsh/history
|
||||
|
||||
autoload -U colors zsh/terminfo
|
||||
colors
|
||||
setopt correct
|
||||
|
||||
export ZSH_CUSTOM_COMPLETION_PATH="$XDG_CONFIG_HOME/zsh/completion"
|
||||
x-dc "$ZSH_CUSTOM_COMPLETION_PATH"
|
||||
@@ -48,11 +49,9 @@ fi
|
||||
|
||||
compinit -d "$XDG_CACHE_HOME"/zsh/zcompdump-"$ZSH_VERSION"
|
||||
|
||||
# Import ssh keys in keychain
|
||||
ssh-add -A 2>/dev/null;
|
||||
|
||||
# Try to load antigen, if present
|
||||
ANTIGEN_ZSH_PATH="$XDG_BIN_HOME/antigen.zsh"
|
||||
# shellcheck source=../../.local/bin/antigen.zsh
|
||||
[[ -f "$ANTIGEN_ZSH_PATH" ]] && source "$ANTIGEN_ZSH_PATH"
|
||||
|
||||
# antigen is present
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
# shellcheck shell=zsh
|
||||
# shellcheck shell=bash
|
||||
# vim: filetype=zsh
|
||||
|
||||
export DOTFILES="$HOME/.dotfiles"
|
||||
|
||||
@@ -67,6 +67,9 @@ x-default-antigen-bundles()
|
||||
export ZSH_TMUX_AUTOQUIT=false
|
||||
export ZSH_TMUX_DEFAULT_SESSION_NAME=main
|
||||
|
||||
# Add keychain to ssh-agent args when on macOS
|
||||
have brew && zstyle :omz:plugins:ssh-agent ssh-add-args --apple-load-keychain
|
||||
|
||||
# these should be always available
|
||||
antigen bundle tmux
|
||||
antigen bundle colored-man-pages
|
||||
|
||||
@@ -1,177 +0,0 @@
|
||||
#compdef _git-profile git-profile
|
||||
|
||||
# zsh completion for git-profile -*- shell-script -*-
|
||||
|
||||
__git-profile_debug()
|
||||
{
|
||||
local file="$BASH_COMP_DEBUG_FILE"
|
||||
if [[ -n ${file} ]]; then
|
||||
echo "$*" >> "${file}"
|
||||
fi
|
||||
}
|
||||
|
||||
_git-profile()
|
||||
{
|
||||
local shellCompDirectiveError=1
|
||||
local shellCompDirectiveNoSpace=2
|
||||
local shellCompDirectiveNoFileComp=4
|
||||
local shellCompDirectiveFilterFileExt=8
|
||||
local shellCompDirectiveFilterDirs=16
|
||||
|
||||
local lastParam lastChar flagPrefix requestComp out directive comp lastComp noSpace
|
||||
local -a completions
|
||||
|
||||
__git-profile_debug "\n========= starting completion logic =========="
|
||||
__git-profile_debug "CURRENT: ${CURRENT}, words[*]: ${words[*]}"
|
||||
|
||||
# The user could have moved the cursor backwards on the command-line.
|
||||
# We need to trigger completion from the $CURRENT location, so we need
|
||||
# to truncate the command-line ($words) up to the $CURRENT location.
|
||||
# (We cannot use $CURSOR as its value does not work when a command is an alias.)
|
||||
words=("${=words[1,CURRENT]}")
|
||||
__git-profile_debug "Truncated words[*]: ${words[*]},"
|
||||
|
||||
lastParam=${words[-1]}
|
||||
lastChar=${lastParam[-1]}
|
||||
__git-profile_debug "lastParam: ${lastParam}, lastChar: ${lastChar}"
|
||||
|
||||
# For zsh, when completing a flag with an = (e.g., git-profile -n=<TAB>)
|
||||
# completions must be prefixed with the flag
|
||||
setopt local_options BASH_REMATCH
|
||||
if [[ "${lastParam}" =~ '-.*=' ]]; then
|
||||
# We are dealing with a flag with an =
|
||||
flagPrefix="-P ${BASH_REMATCH}"
|
||||
fi
|
||||
|
||||
# Prepare the command to obtain completions
|
||||
requestComp="${words[1]} __complete ${words[2,-1]}"
|
||||
if [ "${lastChar}" = "" ]; then
|
||||
# If the last parameter is complete (there is a space following it)
|
||||
# We add an extra empty parameter so we can indicate this to the go completion code.
|
||||
__git-profile_debug "Adding extra empty parameter"
|
||||
requestComp="${requestComp} \"\""
|
||||
fi
|
||||
|
||||
__git-profile_debug "About to call: eval ${requestComp}"
|
||||
|
||||
# Use eval to handle any environment variables and such
|
||||
out=$(eval ${requestComp} 2>/dev/null)
|
||||
__git-profile_debug "completion output: ${out}"
|
||||
|
||||
# Extract the directive integer following a : from the last line
|
||||
local lastLine
|
||||
while IFS='\n' read -r line; do
|
||||
lastLine=${line}
|
||||
done < <(printf "%s\n" "${out[@]}")
|
||||
__git-profile_debug "last line: ${lastLine}"
|
||||
|
||||
if [ "${lastLine[1]}" = : ]; then
|
||||
directive=${lastLine[2,-1]}
|
||||
# Remove the directive including the : and the newline
|
||||
local suffix
|
||||
(( suffix=${#lastLine}+2))
|
||||
out=${out[1,-$suffix]}
|
||||
else
|
||||
# There is no directive specified. Leave $out as is.
|
||||
__git-profile_debug "No directive found. Setting do default"
|
||||
directive=0
|
||||
fi
|
||||
|
||||
__git-profile_debug "directive: ${directive}"
|
||||
__git-profile_debug "completions: ${out}"
|
||||
__git-profile_debug "flagPrefix: ${flagPrefix}"
|
||||
|
||||
if [ $((directive & shellCompDirectiveError)) -ne 0 ]; then
|
||||
__git-profile_debug "Completion received error. Ignoring completions."
|
||||
return
|
||||
fi
|
||||
|
||||
while IFS='\n' read -r comp; do
|
||||
if [ -n "$comp" ]; then
|
||||
# If requested, completions are returned with a description.
|
||||
# The description is preceded by a TAB character.
|
||||
# For zsh's _describe, we need to use a : instead of a TAB.
|
||||
# We first need to escape any : as part of the completion itself.
|
||||
comp=${comp//:/\\:}
|
||||
|
||||
local tab=$(printf '\t')
|
||||
comp=${comp//$tab/:}
|
||||
|
||||
__git-profile_debug "Adding completion: ${comp}"
|
||||
completions+=${comp}
|
||||
lastComp=$comp
|
||||
fi
|
||||
done < <(printf "%s\n" "${out[@]}")
|
||||
|
||||
if [ $((directive & shellCompDirectiveNoSpace)) -ne 0 ]; then
|
||||
__git-profile_debug "Activating nospace."
|
||||
noSpace="-S ''"
|
||||
fi
|
||||
|
||||
if [ $((directive & shellCompDirectiveFilterFileExt)) -ne 0 ]; then
|
||||
# File extension filtering
|
||||
local filteringCmd
|
||||
filteringCmd='_files'
|
||||
for filter in ${completions[@]}; do
|
||||
if [ ${filter[1]} != '*' ]; then
|
||||
# zsh requires a glob pattern to do file filtering
|
||||
filter="\*.$filter"
|
||||
fi
|
||||
filteringCmd+=" -g $filter"
|
||||
done
|
||||
filteringCmd+=" ${flagPrefix}"
|
||||
|
||||
__git-profile_debug "File filtering command: $filteringCmd"
|
||||
_arguments '*:filename:'"$filteringCmd"
|
||||
elif [ $((directive & shellCompDirectiveFilterDirs)) -ne 0 ]; then
|
||||
# File completion for directories only
|
||||
local subdir
|
||||
subdir="${completions[1]}"
|
||||
if [ -n "$subdir" ]; then
|
||||
__git-profile_debug "Listing directories in $subdir"
|
||||
pushd "${subdir}" >/dev/null 2>&1
|
||||
else
|
||||
__git-profile_debug "Listing directories in ."
|
||||
fi
|
||||
|
||||
local result
|
||||
_arguments '*:dirname:_files -/'" ${flagPrefix}"
|
||||
result=$?
|
||||
if [ -n "$subdir" ]; then
|
||||
popd >/dev/null 2>&1
|
||||
fi
|
||||
return $result
|
||||
else
|
||||
__git-profile_debug "Calling _describe"
|
||||
if eval _describe "completions" completions $flagPrefix $noSpace; then
|
||||
__git-profile_debug "_describe found some completions"
|
||||
|
||||
# Return the success of having called _describe
|
||||
return 0
|
||||
else
|
||||
__git-profile_debug "_describe did not find completions."
|
||||
__git-profile_debug "Checking if we should do file completion."
|
||||
if [ $((directive & shellCompDirectiveNoFileComp)) -ne 0 ]; then
|
||||
__git-profile_debug "deactivating file completion"
|
||||
|
||||
# We must return an error code here to let zsh know that there were no
|
||||
# completions found by _describe; this is what will trigger other
|
||||
# matching algorithms to attempt to find completions.
|
||||
# For example zsh can match letters in the middle of words.
|
||||
return 1
|
||||
else
|
||||
# Perform file completion
|
||||
__git-profile_debug "Activating file completion"
|
||||
|
||||
# We must return the result of this command, so it must be the
|
||||
# last command, or else we must store its result to return it.
|
||||
_arguments '*:filename:_files'" ${flagPrefix}"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# don't run the completion function when being source-ed or eval-ed
|
||||
if [ "$funcstack[1]" = "_git-profile" ]; then
|
||||
_git-profile
|
||||
fi
|
||||
@@ -12,10 +12,15 @@ function x-load-configs()
|
||||
HOST="$(hostname -s)"
|
||||
# Load the shell dotfiles, and then some:
|
||||
for file in $DOTFILES/config/{exports,alias,functions}; do
|
||||
[ -r "$file" ] && source "$file"
|
||||
[ -r "$file-secret" ] && source "$file-secret"
|
||||
[ -r "$file-$HOST" ] && source "$file-$HOST"
|
||||
[ -r "$file-$HOST-secret" ] && source "$file-$HOST-secret"
|
||||
# global (exports|alias|functions) file for all hosts
|
||||
# shellcheck source=../../../config/exports
|
||||
[ -r "$file" ] && source "$file"
|
||||
# shellcheck source=../../../config/exports
|
||||
[ -r "$file-secret" ] && source "$file-secret"
|
||||
# shellcheck source=../../../config/exports
|
||||
[ -r "$file-$HOST" ] && source "$file-$HOST"
|
||||
# shellcheck source=../../../config/exports
|
||||
[ -r "$file-$HOST-secret" ] && source "$file-$HOST-secret"
|
||||
done
|
||||
}
|
||||
x-load-configs
|
||||
@@ -25,14 +30,16 @@ export LC_ALL=fi_FI.utf8
|
||||
|
||||
export RVM_PATH="$HOME/.rvm"
|
||||
export PATH="$RVM_PATH/bin:$PATH"
|
||||
# shellcheck source=$HOME/.rvm/scripts/rvm
|
||||
[[ -s "$RVM_PATH/scripts/rvm" ]] && source "$RVM_PATH/scripts/rvm" # Load RVM into a shell session *as a function*
|
||||
|
||||
# Try to load antigen, if present
|
||||
ANTIGEN_ZSH_PATH="$XDG_BIN_HOME/antigen.zsh"
|
||||
# shellcheck source=$HOME/.local/bin/antigen.zsh
|
||||
[[ -f "$ANTIGEN_ZSH_PATH" ]] && source "$ANTIGEN_ZSH_PATH"
|
||||
|
||||
# If antigen was loaded
|
||||
if command -v antigen &> /dev/null; then
|
||||
if command -v antigen &>/dev/null; then
|
||||
antigen use oh-my-zsh
|
||||
|
||||
# config/functions
|
||||
@@ -48,4 +55,5 @@ alias nano='nano -wS -$'
|
||||
alias gpg=gpg2
|
||||
|
||||
ACME_PATH="$HOME/.acme.sh"
|
||||
# shellcheck source=$HOME/.acme.sh/acme.sh.env
|
||||
[[ -s "$ACME_PATH/acme.sh.env" ]] && . "$ACME_PATH/acme.sh.env"
|
||||
|
||||
Reference in New Issue
Block a user