chore(scripts): 🔨 a bit of refractoring scripts and bashrc
Add some SPDX-License-Identifier magic and some code documentation too. Signed-off-by: Andrei Jiroh Eugenio Halili <ajhalili2006@gmail.com>
This commit is contained in:
parent
d46a0e89a0
commit
52b2e2662f
|
@ -1,9 +1,25 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
if [[ $@ != "" ]]; then
|
||||
# SPDX-License-Identifier: MPL-2.0
|
||||
# An script to lazy-add all of my SSH keys to keychain or ssh-agent (if left blank) or
|
||||
# auto-load an specific ssh key when $1 is defined.
|
||||
|
||||
if [[ $1 != "" ]]; then
|
||||
echo "==> Adding your SSH key ($1) to SSH agent..."
|
||||
ssh-add $HOME/.ssh/$@
|
||||
elif [[ $@ == "" ]]; then
|
||||
ssh-add $HOME/.ssh/$1
|
||||
elif [[ $1 == "" ]]; then
|
||||
echo "==> Adding all of your SSH keys from ~/.ssh directory..."
|
||||
ssh-add ~/.ssh/launchpad
|
||||
for key in ~/.ssh/*; do
|
||||
if [[ $key == "$HOME/.ssh/*config" ]] || [[ $key == "$HOME/.ssh/*known_hosts*" ]]; then
|
||||
true
|
||||
elif [[ $key == "$HOME/.ssh/*.pub" ]]; then
|
||||
true
|
||||
else
|
||||
if command -v keychain >> /dev/null; then
|
||||
eval "$(keychain --eval $key)"
|
||||
else
|
||||
ssh-add "$key"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# SPDX-License-Identifier: MPL-2.0
|
||||
# An utility script for cleaning up history files from your home directory
|
||||
# for different shells and even some programming languages' REPLs.
|
||||
|
||||
usage() {
|
||||
echo "history-cleanup: Remove .*_history files from your home directory"
|
||||
|
@ -7,14 +11,25 @@ usage() {
|
|||
echo
|
||||
echo "WARNING: Since this script is written in Bash, there'll be no support"
|
||||
echo "for other shells, considering the best-effort policy, from the"
|
||||
echo "original script author"
|
||||
echo "Available commands:"
|
||||
echo "all Delete any history file found in home directory."
|
||||
echo "bash Delete ~/.bash_history + run history -c"
|
||||
echo "python"
|
||||
echo "original script author. Proceed at your own risk!"
|
||||
echo
|
||||
echo "COMMANDS:"
|
||||
echo " list List all .*history files within your home directory"
|
||||
echo " all Delete any history file found in home directory."
|
||||
echo " bash Delete ~/.bash_history + run history -c"
|
||||
echo " python"
|
||||
exit
|
||||
}
|
||||
|
||||
if [[ $@ == "" ]]; then
|
||||
list() {
|
||||
# shellcheck disable=SC2010
|
||||
ls ~ -Al | grep history
|
||||
}
|
||||
|
||||
bash_history_cleanup() {
|
||||
rm ~/.bash_history
|
||||
}
|
||||
|
||||
if [[ $1 == "" ]]; then
|
||||
usage
|
||||
fi
|
||||
|
|
|
@ -1,9 +1,13 @@
|
|||
#!/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)
|
||||
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)
|
||||
VI_PATH=$(command -v vi) # maybe neovim?
|
||||
OPEN_EDITOR_LOCKFILE=$HOME/.dotfiles/config/open-editor
|
||||
|
||||
if [[ $1 == "" ]]; then
|
||||
|
|
|
@ -16,11 +16,14 @@ export DEBEMAIL="ajhalili2006@gmail.com"
|
|||
## Update path and inject some vars before the shell interactivity checks ##
|
||||
export DOTFILES_HOME="$HOME/.dotfiles"
|
||||
export DOTFILES_STUFF_BIN="$DOTFILES_HOME/bin"
|
||||
export PATH="$HOME/.local/bin:$HOME/.cargo/bin:$DOTFILES_STUFF_BIN:$PATH"
|
||||
export PATH="$HOME/.asdf/shims:$HOME/.local/bin:$HOME/.cargo/bin:$DOTFILES_STUFF_BIN:$PATH"
|
||||
|
||||
## Add homebrew to path ##
|
||||
test -d /home/linuxbrew/.linuxbrew && eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
|
||||
test -d $HOME/.linuxbrew && eval $($HOME/.linuxbrew/bin/brew shellenv)
|
||||
export HOMEBREW_HOME=${HOMEBREW_HOME:-"/home/linuxbrew/.linuxbrew"}
|
||||
test -d "$HOMEBREW_HOME" && eval "$($HOMEBREW_HOME/bin/brew shellenv)"
|
||||
[[ -r "$HOMEBREW_HOME/etc/profile.d/bash_completion.sh" ]] && . "/home/linuxbrew/.linuxbrew/etc/profile.d/bash_completion.sh"
|
||||
|
||||
export GPG_TTY=$(tty) # in case shit happens
|
||||
|
||||
############################################################################
|
||||
|
||||
|
@ -203,3 +206,4 @@ export GEM_HOME="$HOME/.gems" PATH="$HOME/.gems/bin:$PATH"
|
|||
|
||||
# bashbox
|
||||
[ -s "$HOME/.bashbox/env" ] && source "$HOME/.bashbox/env";
|
||||
source "${XDG_CONFIG_HOME:-$HOME/.config}/asdf-direnv/bashrc"
|
||||
|
|
Loading…
Reference in New Issue