summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbin/extra/gdbcore57
-rw-r--r--config/common/mpv/input.conf3
-rw-r--r--config/essentials/shell/functions.sh9
-rw-r--r--config/essentials/zsh/comp.zsh2
4 files changed, 62 insertions, 9 deletions
diff --git a/bin/extra/gdbcore b/bin/extra/gdbcore
new file mode 100755
index 0000000..24c058a
--- /dev/null
+++ b/bin/extra/gdbcore
@@ -0,0 +1,57 @@
+#!/bin/sh
+
+# Open the latest core file for program with gdb
+# RETURN VALUES
+# 0 - success
+# 1 - if the program was not found or not executable
+# 2 - if the user did aborted
+# 3 - zstd failed
+# 4 - wrong usage
+
+if [ "$#" -lt 1 ]; then
+ >&2 printf 'usage: fcore <program>\n'
+fi
+
+prog="$1"
+if [ ! -x "$prog" ]; then
+ prog="$(which "$prog" 2>/dev/null)"
+ [ -x "$prog" ] || exit 1
+fi
+
+# Directory where corefiles are located
+coredir=/var/lib/systemd/coredump
+# Temporary file listing core files location, later used as location for the corefile
+tmp="$(mktemp)"
+
+find "$coredir" -name "core.${prog##*/}*" -printf '%f %TF %TT\n' > "$tmp"
+
+choice="$(sed \
+ -e 's/\.[0-9]\+$//' \
+ -e 's/^core\.//' \
+ -e 's/\.[0-9]\+\.[0-9a-f]\+\.[0-9]\+\.[0-9]\+\.zst / /' \
+ "$tmp" |
+ awk '{print NR ".", "[" $3,$2"]", $1}' |
+ sort -k 2 -k 3 -r |
+ fzf -0 --with-nth=2..)"
+if [ -z "$choice" ]; then
+ rm "$tmp"
+ exit 2
+fi
+
+nr="${choice%%.*}"
+line="$(sed -n "${nr}p" "$tmp")"
+corefile="$coredir"/"${line%% *}"
+
+if [ ! -f "$corefile" ]; then
+ rm -f "$tmp"
+ exit 1
+fi
+
+if ! zstd -d "$corefile" -f -o "$tmp" 2>/dev/null; then
+ rm -f "$tmp"
+ exit 3
+fi
+
+gdb "$prog" "$tmp"
+
+rm -f "$tmp"
diff --git a/config/common/mpv/input.conf b/config/common/mpv/input.conf
index 1999437..d51ff2f 100644
--- a/config/common/mpv/input.conf
+++ b/config/common/mpv/input.conf
@@ -206,7 +206,8 @@ j add volume -5
k add volume 5
# Subtitles
-S cycle sub # switch subtitle track up-order
+S cycle sub
+s screenshot video
ctrl+s cycle sub-visibility # Toggle subtitles
# Cycle audio tracks
diff --git a/config/essentials/shell/functions.sh b/config/essentials/shell/functions.sh
index 46f2a7e..d564a1f 100644
--- a/config/essentials/shell/functions.sh
+++ b/config/essentials/shell/functions.sh
@@ -68,12 +68,8 @@ sms() { ssh -t phone sendmsg "$1" "'$2'"; }
trcp() { scp "$1" db:/media/basilisk/downloads/transmission/torrents/; }
rln() { ln -s "$(readlink -f "$1")" "$2"; }
getgit() { git clone git@db:"$1"; }
-
esc() { eval "$EDITOR '$(which $1)'"; }
-if [ $SHELL = "/bin/zsh" ]
-then
- compdef esc="which"
-fi
+gccg() { gcc -g -Wall -pedantic -std=c99 -o ${1%.c} $@; }
delfile() { curl -s "${2:-https://upfast.cronyakatsuki.xyz/delete/$1}"; }
upfile() { curl -s -F "file=@\"$1\"" "${2:-https://0x0.st}"; }
@@ -400,6 +396,3 @@ ssh() {
/usr/bin/ssh $@
}
-gccg() {
- gcc -g -Wall -pedantic -std=c99 -o ${1%.c} $@
-}
diff --git a/config/essentials/zsh/comp.zsh b/config/essentials/zsh/comp.zsh
index 19440e0..999025f 100644
--- a/config/essentials/zsh/comp.zsh
+++ b/config/essentials/zsh/comp.zsh
@@ -86,3 +86,5 @@ _go_flag_complete() {
compdef _gnu_generic cpp sqlplus apropos
compdef _gnu_generic air
compdef _go_flag_complete wbr
+compdef esc="which"
+compdef gdbcore="which"