diff --git a/init.el b/init.el index 5c520a8..92c4f40 100644 --- a/init.el +++ b/init.el @@ -82,6 +82,26 @@ version 2022-06-09" ;; Disable line numbers for Treemacs (add-hook 'treemacs-mode-hook (lambda () (display-line-numbers-mode 0))) +;; Clipboard integration (Not work in terminal) +(setq select-enable-clipboard t) +(setq select-enable-primary t) + +;; Clipboard integration for terminal (Need xclip) +(when (not (display-graphic-p)) ;; Check if Emacs is running in the terminal + (defun my-copy-to-clipboard () + "Copy region to clipboard using xclip." + (interactive) + (if (use-region-p) + (let ((text (buffer-substring-no-properties (region-beginning) (region-end)))) + (with-temp-buffer + (insert text) + (call-process-region (point-min) (point-max) "xclip" nil 0 nil "-selection" "clipboard")) + (message "Copied to clipboard")) + (message "No region selected."))) + + (global-set-key (kbd "C-c M-w") 'my-copy-to-clipboard)) + + ;; For example, set the default tab width to 4 spaces (setq-default tab-width 4) ;; For Python mode, set the indentation style