mirror of
https://mau.dev/andreijiroh-dev/dotfiles.git
synced 2025-05-15 01:53:08 +00:00
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:
parent
22503403bb
commit
81aca31cdf
10 changed files with 214 additions and 10 deletions
25
bin/fix-wrong-emails
Executable file
25
bin/fix-wrong-emails
Executable 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
92
bin/open-editor
Executable 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
36
bin/setup-chroot
Executable 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
8
bin/update-discord
Executable 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
|
Loading…
Add table
Add a link
Reference in a new issue