17 Commits
0.5.1 ... 0.9.0

Author SHA1 Message Date
9cfc86b596 added .local/bin folder in PATH 2026-04-30 10:23:24 +02:00
2ba65cce12 added variables in deploy function usage message 2026-04-22 18:49:18 +02:00
5e4a8464c5 feat(kubernetes): Guard kubectl initialization and completions
Ensures kubectl-related aliases and functions are only sourced if the `kubectl` command is available.
2026-04-16 19:21:35 +02:00
2c0ac0f6ab feat(bash): Improve source directory calculation in bashrc overrides 2026-04-16 17:08:47 +02:00
77ab262c43 added kubernetes aliases and help functions 2026-04-14 15:26:58 +02:00
d689420388 added aliases and deploy function 2026-03-05 00:46:52 +01:00
1d8ec5e402 added aliases alias 2025-03-29 19:24:33 +01:00
8d37dfd5ad added function to display fingerprint in pubkey command 2024-09-05 16:31:56 +02:00
bea9c85c9a added taglist alias and tagpush functions 2024-03-24 10:00:30 +01:00
0eb28cf6cc added ability to dynamically source files from file in home directory
added explanation and example in README.md
2024-03-24 09:50:29 +01:00
3c9736d165 added clarifications in README.md 2024-03-24 09:43:01 +01:00
759f0c9494 added user, password & container name to samba server, added alias to stop samba server 2024-03-24 06:03:51 +01:00
39cb410c3e added check for git command presence to enable git functions in terminal fancyfying 2023-12-19 16:56:06 +01:00
d792ce8809 fixed bashrc, removed variable, not working 2023-12-19 16:54:37 +01:00
dc984eb128 removed network host from sambaserver, fixed samba options 2023-12-17 12:33:18 +01:00
5d6c22f1b8 added infinitenothing alias 2023-12-17 12:32:32 +01:00
c53a382a4f fixed typo in bashrc path, variabilized bashrc path 2023-12-14 15:13:51 +01:00
10 changed files with 117 additions and 14 deletions

View File

@@ -6,5 +6,22 @@ Feel free to try or poke around in the source (it's all human-readable bash), or
## Usage
Explaining section for not-so-intuitive configurations
- alias `sambaserver`: please `cd` into the directoy is needed to be shared and execute `sambaserver` followed by `"shareuser;<SUBSTITUTE-YOUR-PASSWORD-HERE>"`, then just login with username `shareuser` and the provided password with the host computer as URL/IP, autodiscovery of both the host and the share was tested working on Windows and a Samsung Tablet.
- alias `termbin`: use when piping a cat/echo/file/etc to upload to termbin.com (¡requires Netcat!)
- alias `sambaserver`: (¡requires Docker!) please `cd` into the directoy is needed to be shared and execute `sambaserver`, then just login with default username `user` and the default password `P4ssw0rd` with the host computer as URL/IP, autodiscovery of both the host and the share was tested working on Windows and a Samsung Tablet.
- alias `sambastop`: (¡requires Docker!) when you're finished, this command stops and removes the samba container.
- alias `termbin`: (¡requires Netcat!) use when piping a cat/echo/file/etc to upload to termbin.com
## Modular sourcing mechanism
Create a file in your home directory called `~/.bash_sources`, and put a script path on every line of this file, it will be sourced automatically.<br>
WARNING: it has to be a full path, for example `/path/to/script.sh` and not abbreviated (as in `~/script.sh`)... idk bash decided like so.<br>
WARNING 2: every line needs to be a path to a file, not a direct command, sourcing a file is possible; souring an "export" or a function... not so much!
#### For example:
`/home/user/.bash_sources`:
```bash
/home/user/.bash_path
/path/to/some/other/script.sh
```
`/home/user/.bash_path`:
```bash
export PATH=~/bin/myproject/bin:$PATH
```

View File

@@ -1,4 +1,16 @@
for source in $(find "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd)" -type f | grep -Ev "_all|terminal_fancyfying"); do
_source_basedir="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd)"
# Source all the overrides in this folder
for source in $(find "${_source_basedir}" -type f | grep -Ev "_all|terminal_fancyfying"); do
. "${source}"
done
. "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd)/terminal_fancyfying_${TERMINAL_FANCYFY}"
. "${_source_basedir}/terminal_fancyfying_${TERMINAL_FANCYFY}"
# If the file ~/.bash_sources exist, source every line it contains
if [ -f ~/.bash_sources ]; then
while IFS= read -r line; do
# Skip empty lines and comments (#)
if [ -n "$line" ] && ! [[ "$line" == \#* ]]; then
. "$line"
fi
done < ~/.bash_sources
fi

View File

@@ -1,15 +1,22 @@
alias pubkey='for PUBKEY_FILE in $(ls ~/.ssh/id_*.pub); do echo "${PUBKEY_FILE} :" | sed -e "s/.*id_//;s/\.pub//"; cat "${PUBKEY_FILE}"; echo; done'
alias pubkey='for PUBKEY_FILE in $(ls ~/.ssh/id_*.pub); do echo "${PUBKEY_FILE} :" | sed -e "s/.*id_//;s/\.pub//"; cat "${PUBKEY_FILE}"; ssh-keygen -lf "${PUBKEY_FILE}" -E sha256; echo; done'
alias taglist='git tag | tr - \~ | sort -V | tr \~ -'
alias desudo="sudo -k"
alias hosts='sudo nano /etc/hosts'
alias historygrep='history | grep'
alias sshconfig='nano ~/.ssh/config'
alias aliases='nano ~/.bash_aliases'
alias bashrc='. ~/.bashrc'
alias bashrc-edit="nano ~/.bashrc"
alias sshagent='eval `ssh-agent` && ssh-add ~/.ssh/id_!(*.pub)'
alias sshfingerprint='ssh-keygen -lf'
alias nocomments='grep -vE "^$|^#|^;"'
alias ipecho="curl -fsSL https://ipecho.net/plain; echo"
alias newrepo='bash <(curl -s https://get.bjphoster.com/new-git-repo.sh)'
alias newansibleworkspace='bash <(curl -s https://get.bjphoster.com/new-ansible-workspace.sh)'
alias infinitenothing='while true; do sleep 1; done'
alias sambaserver='docker run -it --rm --network host -p 137:137 -p 138:138 -p 139:139 -p 445:445 -v `pwd`:/share dperson/samba -n -p -s "sambashare;/share;yes;no;no;shareuser" -w "WORKGROUP"'
alias sambaserver='docker run -dit --rm --name sambaserver -p 137:137 -p 138:138 -p 139:139 -p 445:445 -v `pwd`:/share dperson/samba -n -p -u "user;P4ssw0rd" -s "share;/share;yes;no;yes;user;user" -w "WORKGROUP"'
alias sambastop='docker stop sambaserver; docker rm sambaserver'
alias acme.sh='docker run -it --rm -v ~/acme.sh:/acme.sh neilpang/acme.sh'
alias termbin='nc termbin.com 9999'
alias dnsversion='dig txt chaos version.bind'

17
bashrc_overrides/deploy Normal file
View File

@@ -0,0 +1,17 @@
deploy() {
REPO_HOST="git.bjphoster.com/"
REPO_ORG="deployments"
DEPLOY_DIRECTORY="${DEPLOY_DIRECTORY:-/srv}"
SERVICE="$1"
if [ "$#" -lt 1 ]; then
echo "Usage: deploy <service> [service-name]"
echo "Variable overrides: REPO_HOST - REPO_ORG - DEPLOY_DIRECTORY"
return
fi
if [ "$#" -gt 1 ]; then
SERVICE_NAME="$2"
else
SERVICE_NAME="$SERVICE"
fi
git clone https://$REPO_HOST$REPO_ORG/$SERVICE $DEPLOY_DIRECTORY/$SERVICE_NAME
}

View File

@@ -21,3 +21,16 @@ __git_prompt() {
__git_history() {
echo "$(git log --oneline | cut -d ' ' -f 1)"
}
tagpush() {
if [ -z "$1" ]; then
echo "Usage: tagpush <tag>"
return
fi
git tag "$1"
# for every remote
for REMOTE in $(git remote) ; do
# push current branch and newly created tag
git push "$REMOTE" $(git branch | grep "*" | sed 's/\* //') "$1"
done
}

View File

@@ -1,4 +1,8 @@
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
if [ -d "$HOME/bin" ]; then
PATH="$HOME/bin:$PATH"
fi
# also include .local/bin if it exists
if [ -d "$HOME/.local/bin" ]; then
PATH="$HOME/.local/bin:$PATH"
fi

View File

@@ -0,0 +1,27 @@
if command -v kubectl >/dev/null 2>&1; then
source <(kubectl completion bash)
alias k="kubectl"
alias kcontext="kubectl config use-context"
kns() {
if [[ $# -eq 0 ]]; then
printf '%s\n' "$(kubectl config view --minify -o jsonpath='{.contexts[0].context.namespace}')"
else
local ns="${1?Namespace required}"
kubectl config set-context --current --namespace "$ns"
printf 'Switched current context to namespace: %s\n' "$ns"
fi
}
_kns_completion() {
local cur
cur=${COMP_WORDS[COMP_CWORD]}
COMPREPLY=( $(compgen -W "$(kubectl get namespaces -o name | sed 's|namespace/||')" -- "$cur") )
}
_kcontext_completion() {
local cur
cur=${COMP_WORDS[COMP_CWORD]}
COMPREPLY=( $(compgen -W "$(kubectl config get-contexts -o name)" -- $cur) )
}
complete -F __start_kubectl k
complete -F _kns_completion kns
complete -F _kcontext_completion kcontext
fi

View File

@@ -1,4 +1,7 @@
GIT_FUNCTIONS=true
command -v git &>/dev/null
if [ $? -eq 0 ]; then
GIT_FUNCTIONS=true
fi
# Spaced
#PS1="${LIGHTBLUE}[ ${LIGHTRED}\u ${LIGHTBLUE}@ ${LIGHTBROWN}$(hostname --fqdn) ${LIGHTBLUE}] ${LIGHTPURPLE}( ${GREEN}\w ${LIGHTPURPLE}) "
@@ -7,7 +10,7 @@ GIT_FUNCTIONS=true
# another version I really like
PS1="${PURPLE}\# ${LIGHTBLUE}{${LIGHTGREEN}\u${BROWN}@${LIGHTGREEN}\$(hostname --fqdn)${LIGHTBLUE}} ${LIGHTPURPLE}[${CYAN}\w${LIGHTPURPLE}] "
if [ $GIT_FUNCTIONS ]; then
if [ $GIT_FUNCTIONS = "true" ]; then
#PS1="$PS1${LIGHTPURPLE}[${LIGHTCYAN}$(__git_prompt)${LIGHTPURPLE}]"
PS1="$PS1${LIGHTBROWN}(${LIGHTCYAN}\$(__git_prompt)${LIGHTBROWN}) "
fi

View File

@@ -1,11 +1,14 @@
GIT_FUNCTIONS=true
command -v git &>/dev/null
if [ $? -eq 0 ]; then
GIT_FUNCTIONS=true
fi
# Spaced
#PS1="${LIGHTBLUE}[ ${LIGHTRED}\u ${LIGHTBLUE}@ ${LIGHTBROWN}$(hostname --fqdn) ${LIGHTBLUE}] ${LIGHTPURPLE}( ${GREEN}\w ${LIGHTPURPLE}) "
# Not spaced
PS1="${LIGHTBLUE}[${LIGHTRED}\u${LIGHTBLUE}@${LIGHTBROWN}$(hostname --fqdn)${LIGHTBLUE}]${LIGHTPURPLE}(${GREEN}\w${LIGHTPURPLE})"
if [ $GIT_FUNCTIONS ]; then
if [ $GIT_FUNCTIONS = "true" ]; then
#PS1="$PS1${LIGHTPURPLE}[${LIGHTCYAN}$(__git_prompt)${LIGHTPURPLE}]"
PS1="$PS1${LIGHTBROWN}(${LIGHTCYAN}\$(__git_prompt)${LIGHTBROWN}) "
fi

View File

@@ -18,7 +18,7 @@ _bashrc_present() {
_arguments() {
if [ "$(_bashrc_present)" = true ]; then
PRESENT=true
CURRENT_FANCYFY="$(grep TERMINAL_FANCYFY /home/bryanpedini/.bashrc | sed 's/.*=//')"
CURRENT_FANCYFY="$(grep TERMINAL_FANCYFY ~/.bashrc | sed 's/.*=//')"
fi
for PARM in "$@"; do
if [ "${PARM}" = "--server" ]; then
@@ -43,7 +43,7 @@ _help() {
echo " --force"
echo " Force the reinstallation of the files"
echo " --delete"
echo " Delete the reference in ~/.bashrc"
echo " Delete the reference in ${BASHRC}"
echo " --move"
echo " Create a new reference if the location of this folder has been changed"
echo " --server"