feat: update prc/sprc + completions

This commit is contained in:
2024-07-11 15:58:45 +03:00
parent 967159756f
commit 8d4f6959e8
3 changed files with 30 additions and 3 deletions

View File

@@ -1,11 +1,11 @@
#compdef src rc
#compdef rc src
dfpath="$(wd path df)"
out=()
__read_dir() {
dir="$1"
res=($(find $1 -print | sed "s/${1//\//\\/}\///" | grep -i "\.z\?sh$"))
res=($(find $dir -print | sed "s/${dir//\//\\/}\///" | grep -i "\.z\?sh$" | sed -E 's/\.z?sh//g'))
for i in $res; do
out+=("$i")

18
completions/_srcp Executable file
View File

@@ -0,0 +1,18 @@
#compdef prc sprc
dfpath="$(wd path df)"
out=()
__read_dir() {
dir="$1"
res=($(find $dir -print | sed "s/${dir//\//\\/}\///" | grep -i "\.z\?sh$" | sed -E 's/\.plugin\.z?sh//g'))
for i in $res; do
out+=("$i")
done
}
cd "$dfpath/plugins"
__read_dir .
_describe 'dotfile' out

View File

@@ -105,6 +105,8 @@ rc() {
if [[ -f "$DOTFILES/$1.sh" ]]; then
file="$DOTFILES/$1.sh"
elif [[ -f "$DOTFILES/$1.zsh" ]]; then
file="$DOTFILES/$1.zsh"
else
file="$DOTFILES/$1"
fi
@@ -169,8 +171,14 @@ src() {
return 1
}
# same as rc, but for plugin files
prc() {
rc "plugins/$1.plugin"
return $?
}
# same as src, but for plugin files
srcp() {
sprc() {
src "plugins/$1.plugin"
return $?
}
@@ -362,6 +370,7 @@ autoload _docker-exec
autoload _docker-volume-path
autoload _prj
autoload _src
autoload _srcp
# reload entire shell
reload-zsh() {