summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Bobov <anton@bobov.name>2023-08-29 14:44:07 +0500
committerAnton Bobov <anton@bobov.name>2023-08-29 14:44:07 +0500
commit14325e1964c5939e5139297ce5897f929dc1e025 (patch)
treea39db488ee3aef27ca1c07e877fecc302bdf5554
parent7fb714fadb768401b251a7584d76f216acf5943a (diff)
Add scripts
-rwxr-xr-x2flac24
-rwxr-xr-xag-preview18
-rwxr-xr-xreword2
-rwxr-xr-xscreenshot-tool23
4 files changed, 67 insertions, 0 deletions
diff --git a/2flac b/2flac
new file mode 100755
index 0000000..3000f4c
--- /dev/null
+++ b/2flac
@@ -0,0 +1,24 @@
+#!/bin/bash
+# Convert APE (Monkey Audio Format) to FLAC using ffmpeg.
+
+set -euo pipefail
+
+usage() {
+ echo "Usage: $(basename "$0") [input file]..."
+ echo "Converts input files into FLAC format."
+ exit 0
+}
+
+main() {
+ if [ $# = 0 ]; then
+ usage
+ fi
+ for input in "$@"; do
+ if [ -f "$input" ]; then
+ output="${input%.*}.flac"
+ ffmpeg -loglevel error -hide_banner -i "$input" -acodec flac "$output"
+ fi
+ done
+}
+
+main "$@"
diff --git a/ag-preview b/ag-preview
new file mode 100755
index 0000000..e210682
--- /dev/null
+++ b/ag-preview
@@ -0,0 +1,18 @@
+#!/bin/bash
+# Based on https://github.com/junegunn/fzf/blob/master/ADVANCED.md#ripgrep-integration
+
+set -euo pipefail
+
+main() {
+ AG_PREFIX="ag --column --numbers --noheading --color --smart-case"
+ INITIAL_QUERY="${*:-}"
+ : | fzf --ansi --disabled --query "$INITIAL_QUERY" \
+ --bind "start:reload:$AG_PREFIX {q}" \
+ --bind "change:reload:sleep 0.1; $AG_PREFIX {q} || true" \
+ --delimiter : \
+ --preview 'bat --color=always {1} --highlight-line {2}' \
+ --preview-window 'up,60%,border-bottom,+{2}+3/3,~3' \
+ --bind 'enter:become(vim {1} +{2})'
+}
+
+main "$@"
diff --git a/reword b/reword
new file mode 100755
index 0000000..6b39c2f
--- /dev/null
+++ b/reword
@@ -0,0 +1,2 @@
+#!/bin/sh
+git commit --amend -m "$*"
diff --git a/screenshot-tool b/screenshot-tool
new file mode 100755
index 0000000..30017da
--- /dev/null
+++ b/screenshot-tool
@@ -0,0 +1,23 @@
+#!/bin/bash
+# Fix issue: window loose focus after flameshot
+
+set -euo pipefail
+
+flameshot_run() {
+ focused_window=$(xdotool getwindowfocus)
+ flameshot gui || true
+ if [ "$focused_window" != "$(xdotool getwindowfocus)" ]; then
+ xdotool windowactivate "$focused_window"
+ fi
+}
+
+main() {
+ if command -v flameshot >/dev/null 2>&1; then
+ flameshot_run "$@"
+ else
+ echo "No flameshot command found"
+ exit 1
+ fi
+}
+
+main "$@"