Skip to content

Instantly share code, notes, and snippets.

View andiogenes's full-sized avatar

Anton Zavyalov andiogenes

View GitHub Profile
@andiogenes
andiogenes / dired-do-copy-ace-window.el
Created September 26, 2025 10:08
Dired - Copy file to the directory of window selected by AceWindow
;; Dired - Copy file to the directory of window selected by AceWindow
(defun arx/dired-do-copy-ace-window ()
(interactive)
(when-let ((dst-dir (aw-select
"Copy file to the directory of other window"
(lambda (w)
(with-selected-window w
default-directory))))
(src-file (or (dired-get-subdir) (dired-get-filename)))
(_ (y-or-n-p (format "Copy %s to %s?" src-file dst-dir))))
@andiogenes
andiogenes / term-emulator-here.el
Last active August 28, 2025 03:46
Start terminal emulator in current directory.
(defun term-emulator-here ()
"Start terminal emulator in current directory."
(interactive)
(let* ((term-emulator "alacritty")
(display-buffer-alist '(("\\*Async Shell Command\\*.*" display-buffer-no-window)))
(command term-emulator))
(async-shell-command command)))
@andiogenes
andiogenes / dired-copy-full-filename-as-kill.el
Created August 8, 2025 11:04
Copy full path of file with W in Dired
;; Copy full path of file with W
(defun arx/dired-copy-full-filename-as-kill ()
(interactive)
(let ((name (or (dired-get-subdir) (dired-get-filename))))
(kill-new name)
(message "%s" name)))
(keymap-set dired-mode-map "W" 'arx/dired-copy-full-filename-as-kill)
@andiogenes
andiogenes / .zshrc
Created June 26, 2025 09:25
oh-my-zsh prompt with exit code on the right side of line and background jobs count on the left
ZSH_THEME="robbyrussell"
# https://zenbro.github.io/2015/07/23/show-exit-code-of-last-command-in-zsh.html
function check_last_exit_code() {
local LAST_EXIT_CODE=$?
if [[ $LAST_EXIT_CODE -ne 0 ]]; then
local EXIT_CODE_PROMPT=' '
EXIT_CODE_PROMPT+="%{$fg[red]%}%{$reset_color%}"
EXIT_CODE_PROMPT+="%{$fg_bold[red]%}$LAST_EXIT_CODE%{$reset_color%}"
EXIT_CODE_PROMPT+="%{$fg[red]%}%{$reset_color%}"
@andiogenes
andiogenes / terminal-x-copy-paste.el
Last active August 14, 2025 05:49
Idea: Killing/yanking text from X clipboard
;; Exchange between `emacs -nw` and X clipboard
(defun x-select-text (text)
"Send TEXT to X11's clipboard."
(let ((process-connection-type nil))
(let ((proc (start-process "xsel" "*Messages*" "xsel" "-i" "-b")))
(process-send-string proc text)
(process-send-eof proc))))
(defun x-selection-value ()
"Get X11' clipboard string to insert it into in `kill-buffer`."
(defvar window-stack '())
(defun push-window-configuration ()
(interactive)
(push (current-window-configuration) window-stack))
(defun pop-window-configuration ()
(interactive)
(let ((val (pop window-stack)))
(and val (set-window-configuration val))))
@andiogenes
andiogenes / shell-here.el
Created March 20, 2025 05:17
Open shell in directory corresponding to buffer
(defun shell-here ()
"Create new shell rooted at default-directory and open it in
new window if there is no other shells associated with
default-directory, open existing shell otherwise."
(interactive)
(let* ((buffer-dir (directory-file-name (expand-file-name default-directory)))
(shell-buffer-name (concat "*shell*<" buffer-dir "/>")))
(shell shell-buffer-name)))
@andiogenes
andiogenes / foo.scala
Created February 18, 2025 07:44
Comments section of TASTy file
/** ScalaDoc for `object foo`. */
object foo {
/** This ScalaDoc will be listed. */
def foo = 42
// This comment won't be listed
def bar = 43
/** Multi-
* -line
@andiogenes
andiogenes / du-example.md
Created February 5, 2025 07:14
Пример того, как может выглядеть такое надмножество языка

Just a bit of syntactic sugar for Go's composition and methods.

Example

// Base class Foo
type foo class {
  (f) Test() {
    fmt.Println("foo!")
  }
}
@andiogenes
andiogenes / unroll.scala
Created July 12, 2024 04:04
Recursive inline in Scala 3
inline def unroll(inline times: Int)(inline action: Int => Unit): Unit =
if (times > 0)
action(times)
unroll(times - 1)(action)
unroll(4)(println)