Compare commits

..

No commits in common. "528c88a5a5dd7c4203d38dc3c46ed125b1cd0487" and "1808d841a781aeea2d777cbd738b5d25bd10cef5" have entirely different histories.

1 changed files with 25 additions and 21 deletions

View File

@ -41,21 +41,21 @@ section() {
if [ $ZSH_DEBUG -gt 0 ]; then if [ $ZSH_DEBUG -gt 0 ]; then
echo "${ZSH_DEBUG_SECTION_START_PREFIX}$(tput smso)$*$(tput rmso)" echo "${ZSH_DEBUG_SECTION_START_PREFIX}$(tput smso)$*$(tput rmso)"
fi fi
((DEBUG_INDENT++)) (( DEBUG_INDENT++ ))
} }
section_end() { section_end() {
if [ $ZSH_DEBUG -gt 0 ]; then if [ $ZSH_DEBUG -gt 0 ]; then
echo "$ZSH_DEBUG_SECTION_END_TEXT" echo "$ZSH_DEBUG_SECTION_END_TEXT"
fi fi
((DEBUG_INDENT--)) (( DEBUG_INDENT-- ))
} }
log() { log() {
if [ $ZSH_DEBUG -gt 0 ]; then if [ $ZSH_DEBUG -gt 0 ]; then
indent="" indent=""
if [ $DEBUG_INDENT -gt 0 ]; then if [ $DEBUG_INDENT -gt 0 ]; then
for i in $(seq 0 $((DEBUG_INDENT - 1))); do for i in $(seq 0 $(( DEBUG_INDENT-1 )) ); do
indent+="$ZSH_DEBUG_INDENT" indent+="$ZSH_DEBUG_INDENT"
done done
fi fi
@ -69,13 +69,8 @@ log() {
section "compat: bash completion" section "compat: bash completion"
if [ $ZSH_COMPAT_BASH_COMPLETION -gt 0 ] || [ $ZSH_PIPX -gt 0 ]; then if [ $ZSH_COMPAT_BASH_COMPLETION -gt 0 ] || [ $ZSH_PIPX -gt 0 ]; then
log "Enabling compatibility for bash completion scripts..." log "Enabling compatibility for bash completion scripts..."
autoload -Uz bashcompinit compinit autoload -U bashcompinit
bashcompinit bashcompinit
compinit
zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|=*' 'l:|=* r:|=*'
fpath=(/usr/local/share/zsh-completions $fpath)
fi fi
section_end section_end
@ -169,7 +164,8 @@ section_end
# symfony cli # symfony cli
section "symfony cli" section "symfony cli"
if [ $ZSH_SYMFONY_CLI -gt 0 ]; then if [ $ZSH_SYMFONY_CLI -gt 0 ]; then
if [ -n "$(command -v symfony)" ]; then if [ -n "$(command -v symfony)" ]
then
complete -C "$(command -v symfony) self:autocomplete" symfony complete -C "$(command -v symfony) self:autocomplete" symfony
fi fi
fi fi
@ -181,6 +177,7 @@ if [ $ZSH_THEFUCK -gt 0 ]; then
fi fi
section_end section_end
# Default terminal # Default terminal
section "term" section "term"
if [ $ZSH_DEFAULT_TERM -gt 0 ] && [ -z "$TERM" ]; then if [ $ZSH_DEFAULT_TERM -gt 0 ] && [ -z "$TERM" ]; then
@ -223,15 +220,17 @@ section_end
section "ssh-based remote docker access" section "ssh-based remote docker access"
ssh_docker() { ssh_docker() {
args=("$@") args=("$@")
control_path=$(sha1sum - <<<"${args[-1]}" | awk '{print $1}') control_path=$(sha1sum - <<< "${args[-1]}" | awk '{print $1}')
base_path=/var/tmp/ssh-docker/$(sha1sum - <<<"$1" | awk '{print $1}') base_path=/var/tmp/ssh-docker/$(sha1sum - <<< "$1" | awk '{print $1}')
control_path="${base_path}.control" control_path="${base_path}.control"
sock_path="${base_path}.sock" sock_path="${base_path}.sock"
if [ -f "${sock_path}" ]; then if [ -f "${sock_path}" ]
then
echo "Socket path ${sock_path} already exists." >&2 echo "Socket path ${sock_path} already exists." >&2
return 1 return 1
fi fi
if [ -f "${control_path}" ]; then if [ -f "${control_path}" ]
then
echo "Control path ${control_path} already exists." >&2 echo "Control path ${control_path} already exists." >&2
return 1 return 1
fi fi
@ -245,15 +244,17 @@ ssh_docker() {
} }
ssh_docker_exit() { ssh_docker_exit() {
args=("$@") args=("$@")
if [ "${#args}" -gt 0 ]; then if [ "${#args}" -gt 0 ]
base_path=/var/tmp/ssh-docker/$(sha1sum - <<<"${args[-1]}" | awk '{print $1}') then
base_path=/var/tmp/ssh-docker/$(sha1sum - <<< "${args[-1]}" | awk '{print $1}')
control_path="${base_path}.control" control_path="${base_path}.control"
sock_path="${base_path}.sock" sock_path="${base_path}.sock"
else else
control_path="${DOCKER_SSH_CONTROL_PATH}" control_path="${DOCKER_SSH_CONTROL_PATH}"
sock_path="${DOCKER_SSH_SOCKET_PATH}" sock_path="${DOCKER_SSH_SOCKET_PATH}"
fi fi
if [ -z "${control_path}" ]; then if [ -z "${control_path}" ]
then
echo "No active Docker SSH forwarding found in environment." >&2 echo "No active Docker SSH forwarding found in environment." >&2
return 1 return 1
fi fi
@ -261,8 +262,10 @@ ssh_docker_exit() {
rm -f "${sock_path}" "${control_path}" rm -f "${sock_path}" "${control_path}"
} }
ssh_docker_cleanup() { ssh_docker_cleanup() {
for socket in /var/tmp/ssh-docker/*.sock; do for socket in /var/tmp/ssh-docker/*.sock
if [ ! -e "$socket" ]; then do
if [ ! -e "$socket" ]
then
continue continue
fi fi
control="$(basename "$socket" .control).sock" control="$(basename "$socket" .control).sock"
@ -305,3 +308,4 @@ section_end
section "Environment variables" section "Environment variables"
log "$(export)" log "$(export)"
section_end section_end