diff options
author | Raymaekers Luca <raymaekers.luca@gmail.com> | 2024-11-02 22:34:00 +0100 |
---|---|---|
committer | Raymaekers Luca <raymaekers.luca@gmail.com> | 2024-11-02 22:34:00 +0100 |
commit | ddbb985e96c9bb76dd7844654d4175be3cd65d45 (patch) | |
tree | 2b7b08958ae82bff667a5492226f8b8a4440aa18 | |
parent | 156db94321161105f5522d621d48de77d1a46857 (diff) |
checkpoint
-rwxr-xr-x | bin/common/ask | 1 | ||||
-rwxr-xr-x | bin/extra/gdbcore | 15 | ||||
-rwxr-xr-x | bin/guiscripts/vrec | 86 | ||||
-rwxr-xr-x | config/common/tmux/tmux.conf | 12 | ||||
-rw-r--r-- | config/essentials/starship.toml | 21 | ||||
-rw-r--r-- | config/essentials/zsh/.zshrc | 9 | ||||
-rw-r--r-- | config/essentials/zsh/comp.zsh | 1 | ||||
-rw-r--r-- | config/essentials/zsh/prompt.zsh | 2 | ||||
-rw-r--r-- | config/essentials/zsh/widgets.zsh | 15 | ||||
-rw-r--r-- | config/old/starship/starship.toml | 134 |
10 files changed, 223 insertions, 73 deletions
diff --git a/bin/common/ask b/bin/common/ask index 95530f5..386a1f2 100755 --- a/bin/common/ask +++ b/bin/common/ask @@ -1,4 +1,5 @@ #!/bin/sh which tgpt >/dev/null || exit 1 [ "${inp:=$@}" ] || inp="$(cat /dev/stdin)" +>&2 printf 'inp: %s\n' "$inp" tgpt "$inp" diff --git a/bin/extra/gdbcore b/bin/extra/gdbcore index 69b1a64..667db3e 100755 --- a/bin/extra/gdbcore +++ b/bin/extra/gdbcore @@ -9,7 +9,12 @@ # 4 - wrong usage if [ "$#" -lt 1 ]; then - >&2 printf 'usage: gdbcore <program>\n' + >&2 printf 'usage: gdbcore [-r] <program>\n' +fi + +if [ "$1" = "-r" ]; then + recent=1 + shift fi prog="$1" @@ -24,11 +29,11 @@ coredir=/var/lib/systemd/coredump tmp="$(mktemp)" -if [ "$2" = "-r" ]; then - recent="$(find "$coredir" -name "core.${prog##*/}*" -printf '%Ts %f\n' | +if [ "$recent" ]; then + file="$(find "$coredir" -name "core.${prog##*/}*" -printf '%Ts %f\n' | sort -n -r | head -n 1 | cut -f 2- -d' ')" - corefile="$coredir"/"$recent" + corefile="$coredir"/"$file" else find "$coredir" -name "core.${prog##*/}*" -printf '%f %TF %TT\n' > "$tmp" @@ -61,6 +66,6 @@ if ! zstd -d "$corefile" -f -o "$tmp" 2>/dev/null; then exit 3 fi -gdb "$prog" "$tmp" +gdb -q "$prog" "$tmp" rm -f "$tmp" diff --git a/bin/guiscripts/vrec b/bin/guiscripts/vrec index a383f33..4d3f8db 100755 --- a/bin/guiscripts/vrec +++ b/bin/guiscripts/vrec @@ -1,22 +1,33 @@ #!/bin/sh -# record - record an area of the screen - -lock="/tmp/record.lock" - -# dependencies: ffmpeg, hacksaw (part), xwininfo & lsw (window), xdotool (active) -# optional: +# Quick video capture with dmenu +# +# dependencies: +# - ffmpeg # - hacksaw: part -# - xwininfo, lsw, commander: window # - xdotool: active # - xdg-user-dir +# - dmenu +# - clipp +# +# Usage: +# vrec [command] [dir] +# - if you do not provide a command it will launch dmenu. +# - if you provide command and dir it will save the recording in dir +# Commands: +# - active: capture the active window +# - part: select a part of the screen to record +# - stop: stop an active recording +# - full: record your full screen +# - last: copy the latest recording's path to the clipboard +# - audio: one of the prior recording commands but with sound +# Recording: +# there is a lock file -audio= - -# $1: width -# $2: height -# $3: x -# $4: y +# $1: x +# $2: y +# $3: width +# $4: height # $5: output dir # $6: output name record_cmd() @@ -28,8 +39,9 @@ record_cmd() else touch "$lock" fi + printf '%s\n' "$5/$6.mp4" - herbe "started recording." # use notification to know when recording started + herbe "vrec" "started recording." # use notification to know when recording started w=$(($3 + $3 % 2)) h=$(($4 + $4 % 2)) ffmpeg $audio \ @@ -43,62 +55,56 @@ record_cmd() -pix_fmt yuv420p \ -crf 20 \ "$5/$6.mp4" - printf '%s\n' "$5/$6.mp4" rm -f "$lock" - herbe "stopped recording." & + herbe "vrec" "stopped recording." & } +lock="/tmp/record.lock" +# Get recording directory if [ -d "$1" ] then dir="$1" shift else - dir="$(which xdg-user-dir > /dev/null 2>&1 && xdg-user-dir VIDEOS)" - [ "$dir" ] && dir="$dir/records" || dir="$HOME/vids/records" + dir="$(xdg-user-dir VIDEOS)" + [ -d "$dir" ] && dir="$dir/records" || dir="$HOME" fi -mkdir -p "$dir" - +# Set audio variable if [ "$1" = "-a" ] then audio="-f pulse -ac 2 -i default" shift fi +output="$(date +%F_%H-%M-%S)" -if [ "$1" = "-l" ] -then - find vids/records/ -type f | sort | tail -n 1 - exit +if [ -z "${option:="$1"}" ]; then + option="$(printf 'active\npart\nstop\nfull\naudio\nlast\n' | dmenu -c)" fi +[ "$option" ] || exit 1 -current=$(date +%F_%H-%M-%S) - -[ "$1" ] && option="$1" || option="$(printf 'active\nwindow\npart\nstop\nfull\naudio' | commander -c)" case "$option" in active) record_cmd $(xwininfo -id "$(xdotool getactivewindow)" | - sed -e '/Absolute\|Width:\|Height:/!d;s/.*:\s*//' | tr '\n' ' ') $dir $current + sed '/Absolute\|Width:\|Height:/!d;s/.*:\s*//' | tr '\n' ' ') "$dir" "$output" ;; - - window) - winid="$(lsw | commander -cxl | cut -d' ' -f1)" - [ "$winid" ] || exit 1 - values="$(xwininfo -id "$winid" | sed -e '/Absolute\|Width:\|Height:/!d;s/.*:\s*//' | tr '\n' ' ')" - [ "$values" ] || exit 1 - record_cmd $values $dir $current - ;; - part) hacksaw | { IFS=+x read -r w h x y - record_cmd $w $h $x $y $dir $current + [ "$x" ] || exit 1 # quit on ESC + record_cmd $x $y $w $h "$dir" "$output" } ;; stop) pid="$(pgrep ffmpeg | xargs ps | grep 'x11grab' | awk '{print $1}')" [ "$pid" ] && kill "$pid" rm -f "$lock" + herbe "vrec" "stopped recording." & + ;; + last) + file="$(find "$dir" -type f -iname '*.mp4' -printf '%Ts %p\n' | sort -n -r | head -n 1 | cut -f 2- -d' ')" + printf '%s' "$file" | clipp ;; - full) record_cmd 0 0 1920 1080 $dir $current ;; + full) record_cmd 0 0 1920 1080 "$dir" "$output" ;; audio) $0 -a; exit ;; - help|*) >&2 printf 'record [dir] (active|window|part|stop|full)\n' ;; + help|*) >&2 printf 'record [dir] (active|part|stop|full|last|audio)\n' ;; esac diff --git a/config/common/tmux/tmux.conf b/config/common/tmux/tmux.conf index 9b09e44..76906e1 100755 --- a/config/common/tmux/tmux.conf +++ b/config/common/tmux/tmux.conf @@ -50,13 +50,13 @@ bind C-R respawn-pane -k bind v split-window -h -c "#{pane_current_path}" bind s split-window -v -c "#{pane_current_path}" # Swapping left and right a la vim -bind -n M-H swap-pane -U -bind -n M-L swap-pane -D +bind -r H swap-pane -U +bind -r L swap-pane -D ## Resizing panes -bind -r M-H resize-pane -L 5 -bind -r M-J resize-pane -D 5 -bind -r M-K resize-pane -U 5 -bind -r M-L resize-pane -R 5 +bind -n M-H resize-pane -L 5 +bind -n M-J resize-pane -D 5 +bind -n M-K resize-pane -U 5 +bind -n M-L resize-pane -R 5 # Join and break windows bind j command-prompt -1p "Take window:" "join-pane -s %%" bind J command-prompt -1p "Send to window:" "join-pane -t \:%% ; select-window -l" diff --git a/config/essentials/starship.toml b/config/essentials/starship.toml index efcaf48..c782766 100644 --- a/config/essentials/starship.toml +++ b/config/essentials/starship.toml @@ -3,23 +3,18 @@ # Inserts a blank line between shell prompts add_newline = false # format = ' ${custom.upds}' -format = ' [\[$username@$hostname\]](bg:#000000) $all' -right_format = """$status""" +format = '$directory($git_branch$git_state$git_status$status)$character' +right_format = """""" [character] -format = ' \$ ' +format = '\$ ' -[username] -style_root = "bold red" -style_user = "bold purple" -format = "[$user]($style bg:#000000)" -show_always = true -disabled = false +[git_branch] +format = '[$branch(:$remote_branch)]($style) ' +style = 'bold purple' -[hostname] -ssh_only = false -style = "bold cyan bg:#000000" -format = "[$hostname]($style)" +[git_status] +format = '[$all_status$ahead_behind]($style) ' [directory] truncation_length = 4 diff --git a/config/essentials/zsh/.zshrc b/config/essentials/zsh/.zshrc index e474366..85f213d 100644 --- a/config/essentials/zsh/.zshrc +++ b/config/essentials/zsh/.zshrc @@ -115,14 +115,7 @@ add-zsh-hook -Uz preexec () { print -n "\e]0;$1\a\033[0m"; } add-zsh-hook -Uz precmd set_wt (){ print -Pn "\e]0;%n@%m on %~\a"; } ## automatic ls after cd -add-zsh-hook -Uz chpwd (){ [ "$PWD" = "$HOME" ] || ls -A; } - -bottom_margin() { - TBUFFER="$BUFFER" - BUFFER="\n\n\n" - BUFFER="\n\n\n $TBUFFER" -} -add-zsh-hook -Uz precmd bottom_margin +# add-zsh-hook -Uz chpwd (){ [ "$PWD" = "$HOME" ] || ls -A; } ### Variables ## Run menuscripts with fzf diff --git a/config/essentials/zsh/comp.zsh b/config/essentials/zsh/comp.zsh index f0af913..7a53337 100644 --- a/config/essentials/zsh/comp.zsh +++ b/config/essentials/zsh/comp.zsh @@ -88,3 +88,4 @@ compdef _gnu_generic air compdef _go_flag_complete wbr compdef esc="which" compdef gdbcore="which" +compdef pkgfile="which" diff --git a/config/essentials/zsh/prompt.zsh b/config/essentials/zsh/prompt.zsh index 5364401..bf272b8 100644 --- a/config/essentials/zsh/prompt.zsh +++ b/config/essentials/zsh/prompt.zsh @@ -13,4 +13,4 @@ parse_git_branch() { } parse_git_status() { git status --short 2> /dev/null | head -n1 | awk '{print $1 " "}' -}
\ No newline at end of file +} diff --git a/config/essentials/zsh/widgets.zsh b/config/essentials/zsh/widgets.zsh index 71d33cf..985ad2b 100644 --- a/config/essentials/zsh/widgets.zsh +++ b/config/essentials/zsh/widgets.zsh @@ -14,4 +14,19 @@ insert-last-command-output() { zle -N insert-last-command-output bindkey "^Xl" insert-last-command-output + +toggle_prompt() { + local new_prompt=' $ ' + if [ "$PS1" = "$new_prompt" ]; then + eval "$(starship init zsh)" + else + PS1="$new_prompt" + fi + zle clear-screen +} +zle -N toggle_prompt +bindkey '\ep' toggle_prompt + + bindkey -s "^f" "tmux-sessionizer\n" + diff --git a/config/old/starship/starship.toml b/config/old/starship/starship.toml index e70d49d..36388ff 100644 --- a/config/old/starship/starship.toml +++ b/config/old/starship/starship.toml @@ -22,3 +22,137 @@ style = "red" symbol = " " format = '[\[$symbol$status\]]($style) ' disabled = false + + + +[bun] +format = "via [$symbol]($style)" + +[buf] +format = "via [$symbol]($style)" + +[cmake] +format = "via [$symbol]($style)" + +[cobol] +format = "via [$symbol]($style)" + +[crystal] +format = "via [$symbol]($style)" + +[daml] +format = "via [$symbol]($style)" + +[dart] +format = "via [$symbol]($style)" + +[deno] +format = "via [$symbol]($style)" + +[dotnet] +format = "[$symbol(🎯 $tfm )]($style)" + +[elixir] +format = 'via [$symbol]($style)' + +[elm] +format = 'via [$symbol]($style)' + +[erlang] +format = 'via [$symbol]($style)' + +[fennel] +format = 'via [$symbol]($style)' + +[gleam] +format = 'via [$symbol]($style)' + +[golang] +format = 'via [$symbol]($style)' + +[gradle] +format = 'via [$symbol]($style)' + +[haxe] +format = 'via [$symbol]($style)' + +[helm] +format = 'via [$symbol]($style)' + +[java] +format = 'via [$symbol]($style)' + +[julia] +format = 'via [$symbol]($style)' + +[kotlin] +format = 'via [$symbol]($style)' + +[lua] +format = 'via [$symbol]($style)' + +[meson] +format = 'via [$symbol]($style)' + +[nim] +format = 'via [$symbol]($style)' + +[nodejs] +format = 'via [$symbol]($style)' + +[ocaml] +format = 'via [$symbol(\($switch_indicator$switch_name\) )]($style)' + +[opa] +format = 'via [$symbol]($style)' + +[perl] +format = 'via [$symbol]($style)' + +[php] +format = 'via [$symbol]($style)' + +[pulumi] +format = 'via [$symbol$stack]($style)' + +[purescript] +format = 'via [$symbol]($style)' + +[python] +format = 'via [$symbol]($style)' + +[quarto] +format = 'via [$symbol]($style)' + +[raku] +format = 'via [$symbol]($style)' + +[red] +format = 'via [$symbol]($style)' + +[rlang] +format = 'via [$symbol]($style)' + +[ruby] +format = 'via [$symbol]($style)' + +[rust] +format = 'via [$symbol]($style)' + +[solidity] +format = 'via [$symbol]($style)' + +[typst] +format = 'via [$symbol]($style)' + +[swift] +format = 'via [$symbol]($style)' + +[vagrant] +format = 'via [$symbol]($style)' + +[vlang] +format = 'via [$symbol]($style)' + +[zig] +format = 'via [$symbol]($style)' |