git.sophuwu.com > bashprompt
added deb package compiler
	made config for deb pkg info for apt
	cross-compile with zig to arm64 and amd64
	automatically makes apt pkg info for each arch
sophuwu sophie@sophuwu.com
Thu, 05 Jun 2025 02:10:45 +0200
commit

79c0212077d72a25edbcc74ba18e63e991a2e46c

parent

49f54d5604159385f4639b5e65827f0d62544981

5 files changed, 154 insertions(+), 0 deletions(-)

jump to
A releaser/.gitignore

@@ -0,0 +1,1 @@

+build
A releaser/Makefile

@@ -0,0 +1,28 @@

+# Makefile for building the deb package +NAME = bash-rb-ps1 +# Versioning +# run `date '+%Y.%m.%d' to set the version` +VERSION = $(shell date '+%Y.%m.%d') + +START_DIR = $(shell pwd) +SRC_DIR = ../src +BUILD_DIR = ./build/$(VERSION) + +ifeq ($(shell command -v upx), ) +UPX = echo "UPX not found, skipping compression" +else +UPX = upx --lzma --best $(NAME) +endif + + +FLAGS = + +defualt: $(SRC_DIR)/ bash-rb-ps1.1 + mkdir -p $(BUILD_DIR) + cp -r $(SRC_DIR) $(BUILD_DIR) + sed -e 's/{{ Version }}/$(VERSION)/g' bash-rb-ps1.1 > ./$(BUILD_DIR)/bash-rb-ps1.1 + VERSION=$(VERSION) TARGET="amd64" ./zig-cpp.sh + VERSION=$(VERSION) TARGET="arm64" ./zig-cpp.sh + +clean: + @echo "unimplemented"
A releaser/bash-rb-ps1.1

@@ -0,0 +1,66 @@

+.TH BASH-RB-PS1 1 "{{ Version }}" "Version {{ Version }}" "User Commands" +.SH NAME +.B bash-rb-ps1 +\- rainbow PS1 prompt generator for bash + +.SH SYNOPSIS +.B bash-rb-ps1 +[\fIoption\fR] + +.SH DESCRIPTION +.B bash-rb-ps1 +is an executable binary which generates environment variables that bash can evaluate to put a rainbow-colored prompt in the terminal. It also displays IP as a block of 4 colours. +.SH OPTIONS +.TP +.B help +Prints the command to run in your shell to enable the rainbow prompt. +.TP +.B view +Print the PS1 with xterm color codes, without PS1 syntax. This is used to preview the prompt before enabling it. +.SH ENVIRONMENT +.TP +.B IPCOLOR +changes the color palette used for the IP address. + If set to `alt`, it uses an alternative color palette. + If set to `none`, the IP address block and username will be removed from the prompt. + If unset or set to any other value, the default color palette will be used. +.TP +.B IPCmd +specifies a custom command to retrieve the current IP address. + If set, it overrides the default command used by bash-rb-ps1. + The command should output an IPv4 address at the beginning of its output. + Anything after the first space or newline in the output is ignored. + If unset, it defaults to `hostname -i`. +.TP +.B IPStr +manually sets the IPv4 address to a specific value. + If set, the IPCmd will not be executed, and the value of IPStr will be used instead. + +.SH EXAMPLES +.TP +To enable the rainbow prompt, run: +.B eval $(bash-rb-ps1 help) +.TP +To view the prompt without enabling it, run: +.B bash-rb-ps1 view +.TP +To set a custom command for the IP address, run: +.B export IPCmd="my-custom-ip-command" +.TP +To set a specific IP address manually, run: +.B export IPStr="192.168.69.42" +.TP +To use an alternative color palette for the IP address, run: +.B export IPCOLOR=alt +.TP +To disable the IP address block and username from the prompt, run: +.B export IPCOLOR=none +.TP +To reset the IP address color palette to the default, unset the IPCOLOR variable: +.B unset IPCOLOR +.SH SEE ALSO +.BR bash (1) +.SH AUTHOR +Sophie Kisiel <sophie@sophuwu.com> +.SH GIT +https://git.sophuwu.com/bashprompt
A releaser/nfpm.yaml

@@ -0,0 +1,26 @@

+name: "bash-rb-ps1" +arch: "{{ Target }}" +platform: "linux" +version: "{{ Version }}" +section: "default" +priority: "extra" +replaces: +provides: +depends: +recommends: +suggests: +conflicts: +maintainer: "sophuwu <sophie@sophuwu.com>" +description: | + sophps is a an extension for bash that genrates rainbow PS1 + it also displays IP as a block of 4 colours. +vendor: "cdn.sophuwu.com" +homepage: "https://git.sophuwu.com/bashprompt" +license: "MIT" +changelog: "" +contents: +- src: ./bash-rb-ps1 + dst: /usr/bin/bash-rb-ps1 +- src: ../bash-rb-ps1.1 + dst: /usr/share/man/man1/bash-rb-ps1.1 +overrides:
A releaser/zig-cpp.sh

@@ -0,0 +1,33 @@

+#!/bin/bash +command -v upx +doUpx="$?" + +set -e +command -v zig +[[ "$TARGET" == "amd64" || "$TARGET" == "arm64" ]] || exit 1 +[[ "$VERSION" == "$(date +%Y.%m.%d)" ]] || exit 1 +START_DIR=$(pwd) +BUILD_DIR="$START_DIR/build/$VERSION" +SRC_DIR="$BUILD_DIR/src" +BUILD_DIR="$BUILD_DIR/$TARGET" +BIN_OUT="$BUILD_DIR/bash-rb-ps1" + +mkdir -p $BUILD_DIR + +ZIGTAR="x86_64-linux-musl" +if [[ $TARGET == "arm64" ]]; then + ZIGTAR="aarch64-linux-musl" +elif [[ $TARGET == "amd64" ]]; then + ZIGTAR="x86_64-linux-musl" +else + echo "Unsupported target: $TARGET" + exit 1 +fi + +sed -e "s/{{ Version }}/$VERSION/g" "$START_DIR/nfpm.yaml" | sed -e "s/{{ Target }}/$TARGET/g" > "$BUILD_DIR/nfpm.yaml" +cd "$BUILD_DIR" +zig c++ -target $ZIGTAR -std=c++17 -o "$BIN_OUT" $SRC_DIR/*.cpp +if [[ $doUpx == "0" ]]; then + upx --best --lzma "$BIN_OUT" +fi +nfpm package --packager deb --config nfpm.yaml