0
0
فهرست منبع

feat(zsh): add keybinds for copying things

Joe 7 ماه پیش
والد
کامیت
99f61581c6
1فایلهای تغییر یافته به همراه33 افزوده شده و 0 حذف شده
  1. 33 0
      .config/zsh/.zshrc

+ 33 - 0
.config/zsh/.zshrc

@@ -134,6 +134,39 @@ if command -v lazydocker &>/dev/null; then;
     alias lg="lazydocker"
 fi;
 
+################################################################################
+# Keybinds
+################################################################################
+
+# vi mode
+bindkey -v
+
+# Ctrl+Y copies buffer to clipboard
+cmd_to_clip () { pbcopy <<< $BUFFER }
+zle -N cmd_to_clip
+bindkey '^Y' cmd_to_clip
+
+# Ctrl+G copies git-tracked file contents in directory to the clipboard
+copy_dir_llm_style () {
+    git ls-files | column;
+    if read -s -q "choice?Total files: $( git ls-files | wc -l) | Press 'y' to copy contents"; then;
+        {
+            echo "Here is the contents of \`$(basename "$PWD")/\`:\n";
+            git ls-files -z |
+                while IFS= read -r -d $'\0' f; do
+                    echo "$f"; echo '```';
+                    cat "$f"; echo '```';
+                    echo;
+                done;
+        } | pbcopy
+        echo "\nCopied!"
+    else;
+        echo "\nQuit without copying anything"
+    fi
+}
+zle -N copy_dir_llm_style
+bindkey '^G' copy_dir_llm_style
+
 ################################################################################
 # fzf
 ################################################################################