Add modular ZSH configuration
This commit is contained in:
parent
e897d1f9a1
commit
2da1d30e9e
4 changed files with 77 additions and 2 deletions
|
|
@ -105,5 +105,9 @@ zstyle ':completion:*:manuals' separate-sections true
|
||||||
zstyle ':completion:*:manuals.*' insert-sections true
|
zstyle ':completion:*:manuals.*' insert-sections true
|
||||||
zstyle ':completion:*:man:*' menu yes select
|
zstyle ':completion:*:man:*' menu yes select
|
||||||
|
|
||||||
alias vim='nvim'
|
# Load all files from the .zshrc.d folder.
|
||||||
alias devspace='podman run -it -v "$(pwd):/workspace" -e PUID="$(id -u)" -e PGID="$(id -g)" --uidmap="$(id -u)":0:1 --uidmap=0:1:"$(id -u)" --gidmap="$(id -g)":0:1 --gidmap=0:1:"$(id -g)"'
|
if [[ -d "${HOME}/.zshrc.d" ]]; then
|
||||||
|
for ext in "${HOME}"/.zshrc.d/*.sh; do
|
||||||
|
source "${ext}"
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
|
||||||
7
zsh/dot-zshrc.d/00-setup.sh
Normal file
7
zsh/dot-zshrc.d/00-setup.sh
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
export SPACES_DIR="${HOME}/spaces"
|
||||||
|
export WORKSPACE_DIR="${SPACES_DIR}/workspace"
|
||||||
|
|
||||||
|
mkdir -p "${SPACES_DIR}"
|
||||||
|
|
||||||
4
zsh/dot-zshrc.d/01-aliases.sh
Normal file
4
zsh/dot-zshrc.d/01-aliases.sh
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
alias vi="nvim"
|
||||||
|
alias vim="nvim"
|
||||||
60
zsh/dot-zshrc.d/10-workspace.sh
Normal file
60
zsh/dot-zshrc.d/10-workspace.sh
Normal file
|
|
@ -0,0 +1,60 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
alias cdw="cd ${WORKSPACE_DIR}"
|
||||||
|
|
||||||
|
function _get_projects() {
|
||||||
|
( cd -- "${WORKSPACE_DIR}" && find . -mindepth 3 -maxdepth 3 -type d | sed 's|^\./||' )
|
||||||
|
}
|
||||||
|
|
||||||
|
function cdp() {
|
||||||
|
if command -v fzf &>/dev/null; then
|
||||||
|
cd -- "${WORKSPACE_DIR}/$(_get_projects | fzf --query "$*")"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
local projects=( "${(@f)$( _get_projects )}" )
|
||||||
|
if [[ "$#" -gt 0 ]]; then
|
||||||
|
projects=( "${(@Mb)projects:#*${1}*}" )
|
||||||
|
fi
|
||||||
|
|
||||||
|
select project in "${projects[@]}"; do
|
||||||
|
cd -- "${WORKSPACE_DIR}/${project}"
|
||||||
|
break
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
function _cdp_comp() {
|
||||||
|
local projects=( "${(@f)$( _get_projects )}" )
|
||||||
|
|
||||||
|
compset -P '*\/'
|
||||||
|
_describe "${projects[@]}"
|
||||||
|
}
|
||||||
|
compdef _cdp_comp cdp
|
||||||
|
|
||||||
|
function clone() {
|
||||||
|
if [[ "$#" -lt 1 ]]; then
|
||||||
|
echo "[!] Missing URL to clone!" >&2
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
local url="$1"
|
||||||
|
local forge owner repo
|
||||||
|
if [[ "${url}" =~ ^ssh:\/\/[a-zA-Z0-9_]+@([a-zA-Z0-9_.]+):[0-9]+/([a-zA-Z0-9_]+)/([a-zA-Z0-9_]+)(.git)?$ ]]; then
|
||||||
|
forge="${match[1]:l}"
|
||||||
|
owner="${match[2]:l}"
|
||||||
|
repo="${match[3]:l}"
|
||||||
|
elif [[ "${url}" =~ ^[a-zA-Z0-9_]+@([a-zA-Z0-9_.]+):([a-zA-Z0-9_]+)\/([a-zA-Z0-9_]+)(.git)?$ ]]; then
|
||||||
|
forge="${match[1]:l}"
|
||||||
|
owner="${match[2]:l}"
|
||||||
|
repo="${match[3]:l}"
|
||||||
|
elif [[ "${url}" =~ ^https?:\/\/([a-zA-Z0-9_.]+)(:[0-9]+)?\/([a-zA-Z0-9_]+)/([a-zA-Z0-9_]+)(.git)?$ ]]; then
|
||||||
|
forge="${match[1]:l}"
|
||||||
|
owner="${match[3]:l}"
|
||||||
|
repo="${match[4]:l}"
|
||||||
|
else
|
||||||
|
echo "[!] Do not know how to handle ${url}!" >&2
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
git clone "${url}" "${WORKSPACE_DIR}/${forge}/${owner}/${repo}"
|
||||||
|
}
|
||||||
Loading…
Add table
Reference in a new issue