summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.zsh/completion/_cdrepo11
-rw-r--r--.zsh/completion/_cr9
-rw-r--r--.zshrc19
3 files changed, 19 insertions, 20 deletions
diff --git a/.zsh/completion/_cdrepo b/.zsh/completion/_cdrepo
new file mode 100644
index 0000000..2f04ee1
--- /dev/null
+++ b/.zsh/completion/_cdrepo
@@ -0,0 +1,11 @@
+#compdef cdrepo
+
+# https://unix.stackexchange.com/a/240192
+# https://zsh.sourceforge.io/Doc/Release/Completion-System.html#Completion-Functions
+_cdrepo () {
+ _arguments \
+ '1:Repo place:(GitLab-repos GitHub-repos source)' \
+ "2:Repo:_files -W ~/Programming/${words[2]} -/"
+}
+
+_cdrepo "$@"
diff --git a/.zsh/completion/_cr b/.zsh/completion/_cr
deleted file mode 100644
index 8c5fb5d..0000000
--- a/.zsh/completion/_cr
+++ /dev/null
@@ -1,9 +0,0 @@
-#compdef cr
-
-_cr() {
- _arguments \
- '1:Repo place:(GitLab-repos GitHub-repos source)' \
- "2:Repo:_files -W ~/Programming/${words[2]} -/"
-}
-
-_cr "$@"
diff --git a/.zshrc b/.zshrc
index 577eba5..45695a7 100644
--- a/.zshrc
+++ b/.zshrc
@@ -53,6 +53,8 @@ device='desktop' # can be either "desktop" (default when empty), "server" or "an
autoload -U select-word-style
select-word-style bash
+ # autoloads completion files
+ # Note: remove all ~/.zcompdump files in case something doesn't autoload
autoload -U compinit
compinit
# }}}
@@ -174,9 +176,9 @@ device='desktop' # can be either "desktop" (default when empty), "server" or "an
fi
if [[ $device != "server" ]]; then
- alias cdg="cr GitHub-repos"
- alias cdl="cr GitLab-repos"
- alias cds="cr source"
+ alias cdg="cdrepo GitHub-repos"
+ alias cdl="cdrepo GitLab-repos"
+ alias cds="cdrepo source"
else
alias wudo="sudo -u www-data"
@@ -222,14 +224,9 @@ device='desktop' # can be either "desktop" (default when empty), "server" or "an
}
if [[ $device != "server" ]]; then
- cr () {
- case "$1" in
- l) cd '~/Programming/GitLab-repos/' ;;
- g) cd '~/Programming/GitHub-repos/' ;;
- s) cd '~/Programming/source/' ;;
- *) return 0 ;;
- esac
- [ -n "$1" ] && cd "$1" || return 0
+ cdrepo () {
+ cd "~/Programming/$1"
+ [ -n "$2" ] && cd "$2" || return 0
}
fi