aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuchen Pei <id@ypei.org>2024-10-11 19:45:02 +1100
committerYuchen Pei <id@ypei.org>2024-10-11 20:22:33 +1100
commitb4068a7ad802f5a3b2bb014412e2f88ccf8384ea (patch)
tree93a309baf2ec5d532ca1e8953853a02bad468d54
parentcad78064b1cd76fc63b3c115a35e54dc6b91015c (diff)
[emacs] [bash] Several improvements
* emacs/.emacs.d/lisp/my/my-media-segment.el: Add index to filename formatting in `my-segment-media-file-1' * emacs/.emacs.d/lisp/my/my-utils.el: Add .spc to audio extensions * emacs/.emacs.d/lisp/my/my-ytdl.el: add command to download audio without tor * misc/.bashrc: pacman and systemd aliases; automate some arch aur make process; add pdf merge / extract functions using ghostscript
-rw-r--r--emacs/.emacs.d/lisp/my/my-media-segment.el6
-rw-r--r--emacs/.emacs.d/lisp/my/my-utils.el2
-rw-r--r--emacs/.emacs.d/lisp/my/my-ytdl.el5
-rw-r--r--misc/.bashrc29
4 files changed, 39 insertions, 3 deletions
diff --git a/emacs/.emacs.d/lisp/my/my-media-segment.el b/emacs/.emacs.d/lisp/my/my-media-segment.el
index 0cef817..f222316 100644
--- a/emacs/.emacs.d/lisp/my/my-media-segment.el
+++ b/emacs/.emacs.d/lisp/my/my-media-segment.el
@@ -63,6 +63,7 @@ Uses `my-media-segment-max-inflight' to limit number of inflight tasks."
(insert-file-contents desc-file-name)
(buffer-string))))
(total (length info))
+ (pad (1+ (floor (log10 total))))
(idx 0)
(thunk))
(dolist (media info)
@@ -74,8 +75,9 @@ Uses `my-media-segment-max-inflight' to limit number of inflight tasks."
(args (append (list "-ss" start)
(when end (list "-to" end))
(list "-i" (expand-file-name media-file-name)
- (format "%s/%s.%s" dir title
- (file-name-extension media-file-name))))))
+ (format
+ (format "%%s/%%0%dd-%%s.%%s" pad) dir idx title
+ (file-name-extension media-file-name))))))
(setq thunk
(lambda ()
(message "Cutting %s-%s to %s (%d/%d)..."
diff --git a/emacs/.emacs.d/lisp/my/my-utils.el b/emacs/.emacs.d/lisp/my/my-utils.el
index c64c9ac..bc200c2 100644
--- a/emacs/.emacs.d/lisp/my/my-utils.el
+++ b/emacs/.emacs.d/lisp/my/my-utils.el
@@ -321,7 +321,7 @@ Example: (format-time-string ... (my-time-from-epoch 1698582504))"
(defvar my-extension-types
'((audio . ("asf" "cue" "flac" "m4a" "m4r" "mid" "mp3" "ogg" "opus"
- "wav" "wma"))
+ "wav" "wma" "spc"))
(video . ("avi" "m4v" "mkv" "mp4" "mpg" "ogg" "ogv" "rmvb" "webm" "wmv"))))
;;; files
diff --git a/emacs/.emacs.d/lisp/my/my-ytdl.el b/emacs/.emacs.d/lisp/my/my-ytdl.el
index 721b299..9118493 100644
--- a/emacs/.emacs.d/lisp/my/my-ytdl.el
+++ b/emacs/.emacs.d/lisp/my/my-ytdl.el
@@ -87,6 +87,11 @@
(interactive "sURL(s): ")
(my-ytdl-internal urls 'audio))
+(defun my-ytdl-audio-no-tor (urls)
+ "Download audio with ytdl."
+ (interactive "sURL(s): ")
+ (my-ytdl-internal urls 'audio t))
+
;;; fixme: autoload
(defun my-ytdl-video-no-tor (urls)
"Download videos with ytdl."
diff --git a/misc/.bashrc b/misc/.bashrc
index 4f337ca..e964fbd 100644
--- a/misc/.bashrc
+++ b/misc/.bashrc
@@ -185,6 +185,7 @@ then
alias pQi="pacman -Qi" # local package details
alias pQl="pacman -Ql" # local package file lists
alias pQo="pacman -Qo" # which package owns this file
+ alias pQc="pacman -Qc" # show changelog
# Remove packages
alias pRs="sudo pacman -Rs" # remove package
@@ -195,8 +196,24 @@ then
# Clear cache
alias pcache1="sudo paccache -rk 1" # remove cache except last item
alias pcache0="sudo paccache -ruk0" # remove all cache
+
+ # make an aur package
+ paur () {
+ pkg_name="${1%.tar.gz}"
+ tar xvf "$pkg_name.tar.gz"
+ cd "$pkg_name"
+ makepkg
+ }
fi
+alias systart="sudo systemctl start"
+alias systop="sudo systemctl stop"
+alias sysnow="sudo systemctl enable --now"
+alias sysdis="sudo systemctl disable"
+alias systat="systemctl status"
+alias sysres="sudo systemctl restart"
+alias sysrelo="sudo systemctl reload"
+
# from ~/.bashrc_local, more aliases
if [[ $(type -t my_local_aliases) == function ]]; then
my_local_aliases
@@ -253,3 +270,15 @@ export CVS_RSH="ssh"
if [[ $(type -t my_local_export) == function ]]; then
my_local_export
fi
+
+# ghostscript, extract pages into a new file
+# gs-extract 4 11 page-4-thru-11.pdf original.pdf
+gs-extract() {
+ gs -sDEVICE=pdfwrite -dNOPAUSE -dBATCH -dSAFER -dFirstPage=$1 -dLastPage=$2 \
+ -sOutputFile=$3 $4
+}
+
+# ghostscript, merge files: gs-merge merged.pdf 1.pdf 2.pdf
+gs-merge() {
+ gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=$*
+}