From: Andre Ramnitz Date: Sat, 27 Jan 2024 10:45:05 +0000 (+0100) Subject: bin: clean up X-Git-Tag: v0.2~220 X-Git-Url: https://git.ramnitz.eu/?a=commitdiff_plain;h=46029b8e5fabada252abef100b39665acb7b4057;p=dotfiles.git bin: clean up --- diff --git a/local/bin/_emergeworld b/local/bin/_emergeworld old mode 100644 new mode 100755 diff --git a/local/bin/cheatsheet b/local/bin/cheatsheet new file mode 100755 index 00000000..7bb6565e --- /dev/null +++ b/local/bin/cheatsheet @@ -0,0 +1,11 @@ +#!/bin/bash + +case "$1" in + bash) + bat ~/dotfiles/banner-bash.asc + ;; + *) + bat ~/dotfiles/banner.asc + ;; +esac + diff --git a/local/bin/debug_suspend.sh b/local/bin/debug_suspend.sh new file mode 100755 index 00000000..e8656ab8 --- /dev/null +++ b/local/bin/debug_suspend.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +sudo sh -c "sync && echo 1 > /sys/power/pm_trace && loginctl suspend" + diff --git a/local/bin/kcr-edit-search b/local/bin/kcr-edit-search deleted file mode 100755 index c5106494..00000000 --- a/local/bin/kcr-edit-search +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/sh - -# Open files from search results. -# -# Usage: -# -# kcr edit-search [input: :::] - -# Execute the following Kakoune commands. -# -# Input: ::: -# Output: ␤␤ -select_each_line='_' -select_search_fields='s^(.+?):(\d+):(\d+):(.+?)$' -save_selections='Z' -select_file_save_and_restore='1s"fZz' -select_line_save_and_restore='2s"faz' -select_column_save_and_restore='3s"faz' -select_data='"fz' -prepare_output='y%a' -delete_end_of_file='ged' - -kak -f "${select_each_line}${select_search_fields}${save_selections}${select_file_save_and_restore}${select_line_save_and_restore}${select_column_save_and_restore}${select_data}${prepare_output}${delete_end_of_file}" | - -while read file; read line; read column; do - kcr edit "$file" "+$line:$column" -done diff --git a/local/bin/kcr-fzf b/local/bin/kcr-fzf deleted file mode 100755 index 5af52593..00000000 --- a/local/bin/kcr-fzf +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -"kcr-fzf-$@" diff --git a/local/bin/kcr-fzf-buffers b/local/bin/kcr-fzf-buffers deleted file mode 100755 index 71efdfe6..00000000 --- a/local/bin/kcr-fzf-buffers +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/sh - -# Open buffers. -# -# Usage: -# -# kcr fzf buffers [patterns] - -# – fzf (https://github.com/junegunn/fzf) -# – bat (https://github.com/sharkdp/bat) - -kcr get --raw --value buflist | -grep -F "$*" | -fzf --preview 'kcr cat --raw {} | bat --file-name {} --style=numbers --color=always --line-range :500' --header='Select a buffer to open' --prompt='(b)>' | - -# Open buffers -while read name; do - kcr send buffer "$name" -done diff --git a/local/bin/kcr-fzf-files b/local/bin/kcr-fzf-files deleted file mode 100755 index 3253bb81..00000000 --- a/local/bin/kcr-fzf-files +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/sh - -# Open files. -# -# Usage: -# -# kcr fzf files [paths] - -# – fzf (https://github.com/junegunn/fzf) -# – fd (https://github.com/sharkdp/fd) -# – bat (https://github.com/sharkdp/bat) - -fd --type file . "$@" | -fzf --preview 'bat --style=numbers --color=always --line-range :500 {}' --header='Select a file to open' --prompt='(f)>' | - -# Open files -while read file; do - kcr edit "$file" -done diff --git a/local/bin/kcr-fzf-grep b/local/bin/kcr-fzf-grep deleted file mode 100755 index e3605c85..00000000 --- a/local/bin/kcr-fzf-grep +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/sh - -# Open files by content. -# -# Usage: -# -# kcr fzf grep [paths] - -# – fzf (https://github.com/junegunn/fzf) -# – ripgrep (https://github.com/BurntSushi/ripgrep) - -# Not pretty but robust. -# https://github.com/junegunn/fzf/issues/2581 -export PATHS_PATH=$(mktemp) -trap 'rm "$PATHS_PATH"' EXIT -for path do - echo "$path" >> "$PATHS_PATH" -done - -SHELL=sh fzf --phony --delimiter ':' --ansi --bind 'change:reload(while read path; do set -- "$@" "$path"; done < "$PATHS_PATH"; rg --color=always --column --with-filename --fixed-strings -- {q} "$@" || true),enter:execute(kcr edit {1} +{2}:{3})+abort' --preview 'highlight_line={2} line_range_begin=$((line = highlight_line - (FZF_PREVIEW_LINES / 4) && line < 1 ? 1 : line)) line_range_end=$((line_range_begin + FZF_PREVIEW_LINES)) && bat --style=numbers --color=always --line-range "$line_range_begin:$line_range_end" --highlight-line {2} {1} 2> /dev/null' --header='Select a file to open' --prompt='(g)>' diff --git a/local/bin/kcr-fzf-shell b/local/bin/kcr-fzf-shell deleted file mode 100755 index 33faa3a7..00000000 --- a/local/bin/kcr-fzf-shell +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/sh - -# Start an interactive shell. -# -# Usage: -# -# kcr fzf shell [command] [arguments] - -# – fzf (https://github.com/junegunn/fzf) - -set_environment() { - session=$1 client=${2#null} buffer_name=${3#null} working_directory=$4 -} - -# Run fzf with the session list -rows=$( - kcr list --raw | - fzf --header='Select a session to switch to' --prompt='(s)>' -) - -IFS=' -' -for row in $rows; do - IFS=' ' - set_environment $row - - # Start an interactive shell - KAKOUNE_SESSION=$session KAKOUNE_CLIENT=$client kcr shell "$@" -done diff --git a/local/bin/waybar_reload.sh b/local/bin/waybar_reload.sh new file mode 100755 index 00000000..cf8aba4e --- /dev/null +++ b/local/bin/waybar_reload.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +main() { + local CONFIG="$HOME/.config/waybar/config" + local STYLE="$HOME/.config//waybar/style.css" + + if [ $(pidof waybar) ]; + then + killall waybar + waybar -c "$CONFIG" -s "$STYLE" > /dev/null 2>&1 & + else + waybar -c "$CONFIG" -s "$STYLE" > /dev/null 2>&1 & + fi +} +main +