Reformat zshrc.

master
Icedream 2022-06-13 15:30:03 +02:00
parent 616bad2615
commit 528c88a5a5
Signed by: icedream
GPG Key ID: 468BBEEBB9EC6AEA
1 changed files with 15 additions and 24 deletions

View File

@ -41,21 +41,21 @@ section() {
if [ $ZSH_DEBUG -gt 0 ]; then
echo "${ZSH_DEBUG_SECTION_START_PREFIX}$(tput smso)$*$(tput rmso)"
fi
(( DEBUG_INDENT++ ))
((DEBUG_INDENT++))
}
section_end() {
if [ $ZSH_DEBUG -gt 0 ]; then
echo "$ZSH_DEBUG_SECTION_END_TEXT"
fi
(( DEBUG_INDENT-- ))
((DEBUG_INDENT--))
}
log() {
if [ $ZSH_DEBUG -gt 0 ]; then
indent=""
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"
done
fi
@ -169,8 +169,7 @@ section_end
# symfony cli
section "symfony cli"
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
fi
fi
@ -182,7 +181,6 @@ if [ $ZSH_THEFUCK -gt 0 ]; then
fi
section_end
# Default terminal
section "term"
if [ $ZSH_DEFAULT_TERM -gt 0 ] && [ -z "$TERM" ]; then
@ -225,17 +223,15 @@ section_end
section "ssh-based remote docker access"
ssh_docker() {
args=("$@")
control_path=$(sha1sum - <<< "${args[-1]}" | awk '{print $1}')
base_path=/var/tmp/ssh-docker/$(sha1sum - <<< "$1" | awk '{print $1}')
control_path=$(sha1sum - <<<"${args[-1]}" | awk '{print $1}')
base_path=/var/tmp/ssh-docker/$(sha1sum - <<<"$1" | awk '{print $1}')
control_path="${base_path}.control"
sock_path="${base_path}.sock"
if [ -f "${sock_path}" ]
then
if [ -f "${sock_path}" ]; then
echo "Socket path ${sock_path} already exists." >&2
return 1
fi
if [ -f "${control_path}" ]
then
if [ -f "${control_path}" ]; then
echo "Control path ${control_path} already exists." >&2
return 1
fi
@ -249,17 +245,15 @@ ssh_docker() {
}
ssh_docker_exit() {
args=("$@")
if [ "${#args}" -gt 0 ]
then
base_path=/var/tmp/ssh-docker/$(sha1sum - <<< "${args[-1]}" | awk '{print $1}')
if [ "${#args}" -gt 0 ]; then
base_path=/var/tmp/ssh-docker/$(sha1sum - <<<"${args[-1]}" | awk '{print $1}')
control_path="${base_path}.control"
sock_path="${base_path}.sock"
else
control_path="${DOCKER_SSH_CONTROL_PATH}"
sock_path="${DOCKER_SSH_SOCKET_PATH}"
fi
if [ -z "${control_path}" ]
then
if [ -z "${control_path}" ]; then
echo "No active Docker SSH forwarding found in environment." >&2
return 1
fi
@ -267,16 +261,14 @@ ssh_docker_exit() {
rm -f "${sock_path}" "${control_path}"
}
ssh_docker_cleanup() {
for socket in /var/tmp/ssh-docker/*.sock
do
if [ ! -e "$socket" ]
then
for socket in /var/tmp/ssh-docker/*.sock; do
if [ ! -e "$socket" ]; then
continue
fi
control="$(basename "$socket" .control).sock"
DOCKER_SSH_CONTROL_PATH="$control" \
DOCKER_SSH_SOCKET_PATH="$socket" \
ssh_docker_exit
DOCKER_SSH_SOCKET_PATH="$socket" \
ssh_docker_exit
done
}
export ssh_docker
@ -313,4 +305,3 @@ section_end
section "Environment variables"
log "$(export)"
section_end