dotfiles

regexghost dotfiles and scripts
git clone https://git.regexghost.com/dotfiles.git
Log | Files | Refs | README

commit d7734cf705f5b3c3a252ef383734e22adf135e7a
parent c43beee41b781cdbaec869eb5dc2324cdd8d12b8
Author: regexghost <dev@regexghost.com>
Date:   Thu, 18 Jun 2026 17:10:21 +0100

stopped tracking bash files, string-trunc.c and relevant bar changes

Diffstat:
Mdotfiles/.kshrc | 12++++++------
Mlists/dotfiles | 2--
Mpanel-scripts/lemonbar-bar.sh | 2+-
Mterminal-scripts/Makefile | 2++
Aterminal-scripts/string-trunc.c | 41+++++++++++++++++++++++++++++++++++++++++
5 files changed, 50 insertions(+), 9 deletions(-)

diff --git a/dotfiles/.kshrc b/dotfiles/.kshrc @@ -1,4 +1,4 @@ -# regexghost's .bashrc file +# regexghost's .kshrc file # Hopefully in a coherent order PROMPT_COMMAND= @@ -79,7 +79,7 @@ alias balance='aacgain -r -m 1 *.m4a' alias vol='pactl get-sink-volume @DEFAULT_SINK@ | head -n 1 | cut -d "/" -f 2 | sed "s/ //g"' alias clearlogs='sudo journalctl --vacuum-time=2d' alias q='exit' -alias reload='. ~/.bashrc' +alias reload='. ~/.kshrc' alias pong='ping -c 2 -W 2' alias wp='feh --bg-fill --no-fehbg ~/.config/regexghost/wallpaper.jpg' @@ -171,10 +171,10 @@ trash-empty() { } # Only use this if the history in the current terminal is suddenly way shorter than it should be -restorebashhistory () { +restorehistory () { history | sed 's/^[ ]*[0-9]*[ ]*//g' > /tmp/new_history - cat "$HOME/Downloads/.bash_history_backup" /tmp/new_history > /tmp/all_history - mv /tmp/all_history "$HOME/.bash_history" + cat "$HOME/Downloads/.history_backup" /tmp/new_history > /tmp/all_history + mv /tmp/all_history "$HOME/.history" } cal () { @@ -292,7 +292,7 @@ alias edit-bookmarks='${VISUAL:${EDITOR:-vi}} ~/.local/share/regexghost/script-d export HISTSIZE=80000 export HISTFILESIZE=80000 -export HISTFILE="$HOME/.bash_history" +export HISTFILE="$HOME/.history" export HISTCONTROL=ignoreboth:erasedups export MICRO_TRUECOLOR=1 diff --git a/lists/dotfiles b/lists/dotfiles @@ -20,9 +20,7 @@ ~/.config/boomer/config ~/.config/alacritty/alacritty.toml ~/.inputrc -~/.bash_profile ~/.profile -~/.bashrc ~/.kshrc ~/.xinitrc ~/.config/vim/vimrc diff --git a/panel-scripts/lemonbar-bar.sh b/panel-scripts/lemonbar-bar.sh @@ -101,7 +101,7 @@ update_streams () { update_music () { state="$(mocp -M "$XDG_CONFIG_HOME/moc" -i)" - song="$(echo "$state" | grep -e "SongTitle" -e "Artist" | tac | paste -sd "-" | sed 's/-Artist: / - /g' | sed 's/^SongTitle: //g; s/"//g' | head -c 16 | sed 's/ $//g')" + song="$(echo "$state" | grep -e "SongTitle" -e "Artist" | tac | paste -sd "-" | sed 's/-Artist: / - /g' | sed 's/^SongTitle: //g; s/"//g' | string-trunc 16 ".." | sed 's/ $//g')" pause="$(echo "$state" | grep -e "State" | cut -d " " -f 2)" if [ "$song" = "" ]; then music="${music_stopped_colour} N/A${COLOUR_RESET}" diff --git a/terminal-scripts/Makefile b/terminal-scripts/Makefile @@ -27,3 +27,5 @@ normal: cp opus-soundtrack.sh ${BIN}/opus-soundtrack cp opus-single.sh ${BIN}/opus-single cp webm_to_m4a.sh ${BIN}/webm_to_m4a + gcc string-trunc.c -o string-trunc + mv string-trunc ${BIN}/string-trunc diff --git a/terminal-scripts/string-trunc.c b/terminal-scripts/string-trunc.c @@ -0,0 +1,41 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> + +int main(int argc, char* argv[]) { + if (argc != 3) { + printf("Usage: string-trunc <length> <suffix>\n"); + return 1; + } + + int length = atoi(argv[1]); + if (length == 0) { + printf("Usage: string-trunc <length> <suffix>\n"); + return 1; + } + char* suffix = argv[2]; + + char buffer[length+5]; + memset(buffer, 0, sizeof(buffer)); + + while(fgets(buffer, sizeof(buffer), stdin) != NULL) { + + // https://stackoverflow.com/questions/59847042/how-to-read-only-first-n-characters-from-each-line-in-c-language/59847195#59847195 + char* p = strchr(buffer, '\n'); + if (!p) { + fscanf(stdin, "%*[^\n]\n"); + } else { + *p = '\0'; + } + + if (strlen(buffer) >= length) { + char truncated[length+5]; + memset(truncated, 0, sizeof(truncated)); + strncpy(truncated, buffer, length-strlen(suffix)); + printf("%s%s\n", truncated, suffix); + } else { + printf("%s\n", buffer); + } + } +}