feat(scripts): import more scripts from legacy codebase

Plus, in this commit:
* updated most of shell rc and then some

Signed-off-by: Andrei Jiroh Halili <ajhalili2006@gmail.com>
This commit is contained in:
Andrei Jiroh Halili 2023-01-19 19:22:37 +08:00
parent 22503403bb
commit 81aca31cdf
No known key found for this signature in database
GPG key ID: 67BFC91B3DA12BE8
10 changed files with 214 additions and 10 deletions

View file

@ -6,7 +6,13 @@ export HOST_SPECIFIC_BASHRC_PATH="$HOME/.config/$HOSTNAME.bashrc"
source "$HOME/.env" source "$HOME/.env"
if [[ -f "$HOME/.env.local" ]]; then if [[ -f "$HOME/.env.local" ]]; then
source "$HOME/.env.local" source "$HOME/.env.local"
export LOCAL_DOTENV_LOADED=true LOCAL_DOTENV_LOADED=true
fi fi
# Stage 1: Source the ~/.profile
source "$HOME/.profile" source "$HOME/.profile"
# Added by Toolbox App
export PATH="$PATH:/home/ajhalili2006/.local/share/JetBrains/Toolbox/scripts"

View file

@ -35,7 +35,6 @@ export GOPATH="$HOME/.local/share/go"
export EDITOR=nano export EDITOR=nano
# For compartibility reasons and not to fuck things up on ~/go/bin. # For compartibility reasons and not to fuck things up on ~/go/bin.
# Custom path might be also on ~/.env too? # Custom path might be also on ~/.env too?
export PATH="$DOTFILES_BIN:$HOME/go/bin:$HOME/.local/bin:$GOPATH/bin:$PATH"
# It would be nice if I would work on self-hosted reimplementation of # It would be nice if I would work on self-hosted reimplementation of
# proxy.golang.org, but in meanwhile, you need to fuck off Google on this. # proxy.golang.org, but in meanwhile, you need to fuck off Google on this.
# (Fucking Facebook and Microsoft off your lives are also hard too ICYMI.) # (Fucking Facebook and Microsoft off your lives are also hard too ICYMI.)

View file

@ -32,22 +32,22 @@ enable_mouse=1
delay=5 delay=5
hide_function_bar=0 hide_function_bar=0
header_layout=three_25_25_50 header_layout=three_25_25_50
column_meters_0=AllCPUs Memory Swap column_meters_0=CPU Memory Swap ZFSARC ZFSCARC
column_meter_modes_0=1 1 1 column_meter_modes_0=1 1 1 2 2
column_meters_1=DiskIO NetworkIO Uptime DateTime column_meters_1=DiskIO NetworkIO LoadAverage Tasks Battery
column_meter_modes_1=1 1 2 2 column_meter_modes_1=1 1 1 1 1
column_meters_2=Hostname Tasks LoadAverage column_meters_2=PressureStallIOFull PressureStallMemoryFull Hostname DateTime Uptime
column_meter_modes_2=2 2 1 column_meter_modes_2=1 1 2 2 2
tree_view=1 tree_view=1
sort_key=46 sort_key=46
tree_sort_key=48 tree_sort_key=47
sort_direction=-1 sort_direction=-1
tree_sort_direction=1 tree_sort_direction=1
tree_view_always_by_pid=0 tree_view_always_by_pid=0
all_branches_collapsed=0 all_branches_collapsed=0
screen:Main=PID USER PRIORITY NICE M_VIRT M_RESIDENT M_SHARE STATE PERCENT_CPU PERCENT_MEM TIME Command screen:Main=PID USER PRIORITY NICE M_VIRT M_RESIDENT M_SHARE STATE PERCENT_CPU PERCENT_MEM TIME Command
.sort_key=PERCENT_CPU .sort_key=PERCENT_CPU
.tree_sort_key=USER .tree_sort_key=PERCENT_MEM
.tree_view=1 .tree_view=1
.tree_view_always_by_pid=0 .tree_view_always_by_pid=0
.sort_direction=-1 .sort_direction=-1

29
.config/konsolerc Normal file
View file

@ -0,0 +1,29 @@
[Desktop Entry]
DefaultProfile=~ajhalili2006 - bash.profile
[General]
ConfigVersion=1
[KonsoleWindow]
ShowWindowTitleOnTitleBar=true
[MainWindow]
MenuBar=Disabled
State=AAAA/wAAAAD9AAAAAQAAAAAAAAAAAAAAAPwCAAAAAvsAAAAiAFEAdQBpAGMAawBDAG8AbQBtAGEAbgBkAHMARABvAGMAawAAAAAA/////wAAAAAAAAAA+wAAABwAUwBTAEgATQBhAG4AYQBnAGUAcgBEAG8AYwBrAAAAAAD/////AAAA1QEAAAMAAAVWAAACjwAAAAQAAAAEAAAACAAAAAj8AAAAAQAAAAIAAAACAAAAFgBtAGEAaQBuAFQAbwBvAGwAQgBhAHIBAAAAAP////8AAAAAAAAAAAAAABwAcwBlAHMAcwBpAG8AbgBUAG8AbwBsAGIAYQByAQAAAOj/////AAAAAAAAAAA=
ToolBarsMovable=Disabled
eDP-1 Height 1366x768=701
eDP-1 Height 768=698
eDP-1 Width 1366=1366
eDP-1 Width 1366x768=1366
eDP-1 Window-Maximized 1366x768=true
eDP-1 XPosition=0
eDP-1 XPosition 1366x768=0
eDP-1 YPosition=24
eDP-1 YPosition 1366x768=67
[TabBar]
NewTabButton=true
TabBarVisibility=AlwaysShowTabBar
[UiSettings]
ColorScheme=Default

3
.env
View file

@ -14,6 +14,9 @@ export DEBFULLNAME="Andrei Jiroh Halili"
# on my public GPG key btw, so YOLO it. # on my public GPG key btw, so YOLO it.
export DEBEMAIL="ajhalili2006@gmail.com" export DEBEMAIL="ajhalili2006@gmail.com"
# Customized PATH + Jetbrains Toolbox
export PATH="$DOTFILES_BIN:$HOME/go/bin:$HOME/.local/bin:$GOPATH/bin:$PATH:$HOME/.local/share/JetBrains/Toolbox/scripts"
########################################################################################## ##########################################################################################
# Code snippets from https://git.sr.ht/~sircmpwn/dotfiles/tree/db5945a4/item/.env # Code snippets from https://git.sr.ht/~sircmpwn/dotfiles/tree/db5945a4/item/.env
########################################################################################## ##########################################################################################

View file

@ -13,3 +13,9 @@ mesg n 2> /dev/null || true
# then import the rest # then import the rest
source "$HOME/.env" source "$HOME/.env"
source "$HOME/.config/aliases" source "$HOME/.config/aliases"
export POSIX_PROFILE_SOURCED=true
# Added by Toolbox App
export PATH="$PATH:/home/ajhalili2006/.local/share/JetBrains/Toolbox/scripts"

25
bin/fix-wrong-emails Executable file
View file

@ -0,0 +1,25 @@
#!/bin/bash
if [[ $1 != "" ]]; then
git filter-branch --env-filter '
WRONG_EMAIL=$1
NEW_NAME="Andrei Jiroh Eugenio Halili"
NEW_EMAIL="andreijiroh@madebythepins.tk"
if [ "$GIT_COMMITTER_EMAIL" = "$WRONG_EMAIL" ]
then
export GIT_COMMITTER_NAME="$NEW_NAME"
export GIT_COMMITTER_EMAIL="$NEW_EMAIL"
fi
if [ "$GIT_AUTHOR_EMAIL" = "$WRONG_EMAIL" ]
then
export GIT_AUTHOR_NAME="$NEW_NAME"
export GIT_AUTHOR_EMAIL="$NEW_EMAIL"
fi
' --tag-name-filter cat -- --branches --tags
else
echo "Usage $0 <wrong-email@host.me>"
echo "Easily fix wrong emails in Git commit history. It is advised to use this script only"
echo "on non-public commits, since this might be distaterous for forks to pull any changes"
echo "in the public commits."
fi

92
bin/open-editor Executable file
View file

@ -0,0 +1,92 @@
#!/bin/env bash
# SPDX-License-Identifier: MPL-2.0
# An bloody script for opening text editors from the command line via $EDITOR and
# command flags, work in progress and probably abandoned.
# shellcheck disable=SC2034
VSCODE_PATH=$(command -v code) # TODO: Add PATH detection for VS Code Desktop+Server/OpenVSCode Server/VSCodium/code-server
NANO_PATH=$(command -v nano)
VI_PATH=$(command -v vi) # maybe neovim?
OPEN_EDITOR_LOCKFILE=$HOME/.dotfiles/config/open-editor
if [[ $1 == "" ]]; then
echo "open-editor: Want to learn more how to use me? Use the '--help' flag to see the docs."
exit
fi
# Stack Overflow: https://stackoverflow.com/questions/7069682/how-to-get-arguments-with-flags-in-bash#21128172
while test $# -gt 0; do
case "$1" in
-h|--help)
echo "$0 - shortcut to open editors within and from command line"
echo "By default, the script will attempt to guess what text editor to use as much"
echo "as possible. You can lock with the ~/.dotfiles/config/open-editor file."
echo
echo "$0 [options] filename"
echo " "
echo "options:"
echo "-h, --help show brief help"
echo "-c, --use-code use Visual Studio Code, with the 'wait' flag"
echo "-n, --use-nano use GNU Nano"
echo "--lockfile Generate a lockfile within your home directory"
echo " or edit if found."
exit 0
;;
-c|--use-code)
shift
echo "open-editor: Firing up your editor, please wait..."
sleep 3
if test $# -gt 0; then
# shellcheck disable=SC2086
code --wait $1
else
echo "error: no file specified, aborting..."
exit 1
fi
shift
;;
-n|--use-nano)
shift
echo "open-editor: Firing up your editor, please wait..."
sleep 3
if test $# -gt 0; then
# shellcheck disable=SC2086
nano $1
exit
fi
shift
;;
--lockfile)
shift
if test $# -gt 0; then
export OUTPUT=$1
else
echo "no output dir specified"
exit 1
fi
shift
;;
-*)
echo "open-editor: Unsupported flag, edit the script file to customize."
exit 1
;;
esac
done
if [[ $VSCODE_PATH != "" ]]; then
echo "open-editor: Firing up your editor, please wait..."
sleep 3
code --wait "$1"
exit
elif [[ $NANO_PATH != "" ]]; then
echo "open-editor: Firing up your editor, please wait..."
sleep 3
nano "$1"
exit
else
echo "open-editor: Firing up your editor, please wait..."
sleep 3
vi "$1"
exit
fi

36
bin/setup-chroot Executable file
View file

@ -0,0 +1,36 @@
#!/usr/bin/bash
# Chroot command is optional and assume login binary
CHROOT_COMMAND=${2:-"/usr/bin/login"}
TARGET_DIR=$1
if [[ $TARGET_DIR == "" ]]; then
echo "Usage: $0 TARGET_DIR [CHROOT_COMMAND]"
exit 1
fi
if [ $EUID != "0" ]; then
echo "error: Must be root to proceed!"
exit 1
fi
echo "===> Mounting required parts for chroot operation..."
mount -o bind /dev "$TARGET_DIR/dev"
mount -t proc none "$TARGET_DIR/proc"
mount -o bind /sys "$TARGET_DIR/sys"
echo " Kernel and device mount setup done!"
sleep 3
if [[ -f "$TARGET_DIR/setup-chroot-env.sh" ]]; then
echo "===> Preparing chroot environment..."
if ! bash "$TARGET_DIR/setup-chroot-env.sh"; then
echo "! Chroot env setup failed, please proceed at your own risk."
else
echo " Setup done!"
fi
sleep 3
fi
echo "===> Teleporting to the chroot environment in 3 seconds..."
sleep 3
exec chroot "$TARGET_DIR" ${CHROOT_COMMAND}

8
bin/update-discord Executable file
View file

@ -0,0 +1,8 @@
#!/bin/bash
set -e
# An script to automate upgrading Discord via the deb download link.
# TODO:Implement checks and flags to support for rpms and tar.gz setups
wget "https://discord.com/api/download?platform=linux&format=deb" -O /tmp/discord-linux-amd64.deb
sudo apt install /tmp/discord-linux-amd64.deb