aboutsummaryrefslogtreecommitdiff
path: root/.config/zsh/zsh-functions
diff options
context:
space:
mode:
authorMateja <mail@matejamaric.com>2021-06-20 22:01:05 +0200
committerMateja <mail@matejamaric.com>2021-06-20 22:01:05 +0200
commit5c68b137a6b1ecf59e4c89ac5ca9352c0ef3e849 (patch)
treec4b91179b698d74b2f8b0c7ea92266678e556f65 /.config/zsh/zsh-functions
parent740c3cc87b71c9f7a68f83f5c6a1434600f04220 (diff)
downloaddotfiles-5c68b137a6b1ecf59e4c89ac5ca9352c0ef3e849.tar.gz
dotfiles-5c68b137a6b1ecf59e4c89ac5ca9352c0ef3e849.zip
Added zsh configuration files.
Diffstat (limited to '.config/zsh/zsh-functions')
-rw-r--r--.config/zsh/zsh-functions31
1 files changed, 31 insertions, 0 deletions
diff --git a/.config/zsh/zsh-functions b/.config/zsh/zsh-functions
new file mode 100644
index 0000000..ede0039
--- /dev/null
+++ b/.config/zsh/zsh-functions
@@ -0,0 +1,31 @@
+# Function to source files if they exist
+function zsh_add_file() {
+ [ -f "$ZDOTDIR/$1" ] && source "$ZDOTDIR/$1"
+}
+
+function zsh_add_plugin() {
+ PLUGIN_NAME=$(echo $1 | cut -d "/" -f 2)
+ if [ -d "$ZDOTDIR/plugins/$PLUGIN_NAME" ]; then
+ # For plugins
+ zsh_add_file "plugins/$PLUGIN_NAME/$PLUGIN_NAME.plugin.zsh" || \
+ zsh_add_file "plugins/$PLUGIN_NAME/$PLUGIN_NAME.zsh"
+ else
+ git clone "https://github.com/$1.git" "$ZDOTDIR/plugins/$PLUGIN_NAME"
+ fi
+}
+
+function zsh_add_completion() {
+ PLUGIN_NAME=$(echo $1 | cut -d "/" -f 2)
+ if [ -d "$ZDOTDIR/plugins/$PLUGIN_NAME" ]; then
+ # For completions
+ completion_file_path=$(ls $ZDOTDIR/plugins/$PLUGIN_NAME/_*)
+ fpath+="$(dirname "${completion_file_path}")"
+ zsh_add_file "plugins/$PLUGIN_NAME/$PLUGIN_NAME.plugin.zsh"
+ else
+ git clone "https://github.com/$1.git" "$ZDOTDIR/plugins/$PLUGIN_NAME"
+ fpath+=$(ls $ZDOTDIR/plugins/$PLUGIN_NAME/_*)
+ [ -f $ZDOTDIR/.zccompdump ] && $ZDOTDIR/.zccompdump
+ fi
+ completion_file="$(basename "${completion_file_path}")"
+ if [ "$2" = true ] && compinit "${completion_file:1}"
+}