Bläddra i källkod

dev: automated commit - 2025-12-30 14:20:54

Mariano Z. 1 månad sedan
förälder
incheckning
4a64aba955
3 ändrade filer med 29 tillägg och 22 borttagningar
  1. 5 9
      zsh/.config/zsh/alias.zsh
  2. 20 13
      zsh/.config/zsh/functions/git.zsh
  3. 4 0
      zsh/.config/zsh/keymap.zsh

+ 5 - 9
zsh/.config/zsh/alias.zsh

@@ -65,15 +65,6 @@ function vimwhich {
 }
 alias vw="vimwhich"
 
-# Clipboard operations - with auto-detection
-if [ "$XDG_SESSION_TYPE" = "wayland" ]; then
-  alias copy="wl-copy"
-  alias paste="wl-paste"
-else
-  alias copy="xclip -selection clipboard"
-  alias paste="xclip -selection clipboard -o"
-fi
-
 # Work related
 alias sstack='cd ~/Dev/stuzo/oc-docker-compose; docker-compose up postgres redis rabbitmq'
 
@@ -111,3 +102,8 @@ alias maint='sudo ~/.local/bin/maintenance.sh'
 alias maint-disable='touch ~/.local/share/arch_maintenance_disabled && echo "Maintenance reminders disabled"'
 alias maint-enable='rm -f ~/.local/share/arch_maintenance_disabled && echo "Maintenance reminders enabled"'
 alias maint-status='if [ -f ~/.local/share/arch_maintenance_disabled ]; then echo "Maintenance reminders: DISABLED"; else echo "Maintenance reminders: ENABLED"; fi'
+
+alias -g G='| grep'
+alias -g JQ='| jq'
+alias -g NE='2> /dev/null'
+alias -g C='| wl-copy'

+ 20 - 13
zsh/.config/zsh/functions/git.zsh

@@ -1,39 +1,38 @@
 #!/bin/zsh
-
-function dc() {
-  # Set up completion on first call
+_dc_git_commit_push() {
+  # Setup completion on first call
   if [[ -z "$_dc_completion_setup" ]]; then
     compdef _dc_completion dc 2>/dev/null
     _dc_completion_setup=1
   fi
 
+  # Help message
   if [[ "$1" == "-h" || "$1" == "--help" ]]; then
-    echo "Usage: dc [commit_message]"
-    echo "Quickly commit all changes and push to remote"
+    echo "Usage: ${0} [commit_message]"
+    echo "Quickly commit${2:+ all} changes and push to remote"
     echo "If no message provided, uses timestamp-based message"
     return 0
   fi
 
+  # Check if in git repo
   if ! git rev-parse --is-inside-work-tree &>/dev/null; then
     echo "Error: Not in a git repository" >&2
     return 1
   fi
 
+  # Check for changes
   if [[ -z $(git status --porcelain) ]]; then
     echo "No changes to commit"
     return 0
   fi
 
-  git add .
+  # Add all changes if requested
+  [[ -n "$2" ]] && git add .
 
-  local commit_msg
-  if [[ -n "$1" ]]; then
-    commit_msg="$1"
-  else
-    local timestamp=$(date +"%Y-%m-%d %H:%M:%S")
-    commit_msg="dev: automated commit - ${timestamp}"
-  fi
+  # Set commit message
+  local commit_msg="${1:-dev: automated commit - $(date +"%Y-%m-%d %H:%M:%S")}"
 
+  # Commit and push
   if git commit -m "$commit_msg" --no-gpg-sign; then
     if git push &>/dev/null; then
       echo "Committed and pushed successfully"
@@ -47,6 +46,14 @@ function dc() {
   fi
 }
 
+function dc() {
+  _dc_git_commit_push "$1"
+}
+
+function dca() {
+  _dc_git_commit_push "$1" "add"
+}
+
 function nu() {
   if [[ "$1" == "-h" || "$1" == "--help" ]]; then
     echo "Usage: nu [commit_message]"

+ 4 - 0
zsh/.config/zsh/keymap.zsh

@@ -89,3 +89,7 @@ zle -N edit-nixos-config
 bindkey -M viins '^xc' edit-nixos-config
 bindkey -M vicmd '^xc' edit-nixos-config
 
+# magic-space bind
+bindkey " " magic-space
+# undo
+bindkey "^u" undo