Commit 8fa866b4 authored by nimrod's avatar nimrod
Browse files

.bashrc refactor.

Move stuff around.
parent 0804ecfe
Loading
Loading
Loading
Loading
+1 −111
Changes for .bashrc: 1 added line, 111 removed lines.
Original line number Diff line number Diff line
@@ -14,20 +14,6 @@ do
    fi
done

export ANSIBLE_CACHE_PLUGIN=jsonfile
export ANSIBLE_CACHE_PLUGIN_CONNECTION="$HOME/.ansible/facts"
export ANSIBLE_CALLBACKS_ENABLED="ansible.posix.profile_tasks, ansible.posix.timer"
export ANSIBLE_DEPRECATION_WARNINGS=True
export ANSIBLE_FORKS=5
export ANSIBLE_GATHERING=smart
export ANSIBLE_INVENTORY_ANY_UNPARSED_IS_FAILED=True
export ANSIBLE_PIPELINING=True
export ANSIBLE_PYTHON_INTERPRETER=auto
export ANSIBLE_RETRY_FILES_SAVE_PATH=/tmp/
export ANSIBLE_SSH_CONTROL_PATH="/tmp/ssh-%%h"
export ANSIBLE_SYSTEM_WARNINGS=True
export ANSIBLE_VERBOSITY=2
export AWS_DEFAULT_PROFILE='shore'
if flatpak info org.mozilla.firefox >/dev/null 2>&1
then
    export BROWSER='flatpak run org.mozilla.firefox'
@@ -38,8 +24,6 @@ fi
export CFLAGS="-g3 -Wall -Wextra -Wconversion -Wdouble-promotion -Wno-unused-parameter -Wno-unused-function -Wno-sign-conversion -fsanitize=undefined -fsanitize-trap"
export CLOUDSDK_ACTIVE_CONFIG_NAME='shore'
export EDITOR=vim
export GITLAB_BASE_URL='https://git.shore.co.il/api/v4'
export GITLAB_HOST='https://git.shore.co.il'
export HELM_HOME="$HOME/.helm"
export HISTCONTROL=ignoreboth:erasedups
export HISTFILESIZE=100000
@@ -69,22 +53,14 @@ export PATH="$HOME/Repositories/Shore/ssh-ca:$PATH"
export PATH="$HOME/Repositories/Shore/ssl-ca:$PATH"
export PGSSLROOTCERT=/etc/ssl/certs/ca-certificates.crt
export PS1='\u@\h:\w\$ '
export PYTHON_GITLAB_CFG=~/.config/python-gitlab.cfg
export REDISCLI_HISTFILE="$HOME/Documents/.rediscli_history"
export VAGRANT_DEFAULT_PROVIDER="virtualbox"

alias 0-day-cleanup='ssh kodi.shore.co.il "sudo -u debian-transmission find /srv/library/Comics -name *.part -path *0-Day\ Week\ of* -delete"'
alias all-hosts='echo -n ns1 ns4 host01 kodi mr8300 | xargs -d " " -I HOST ssh HOST.shore.co.il'
alias all-repos='find "$HOME/Repositories" -maxdepth 3 -type d -name .git -print0 | xargs -IX -0 git -C "X/../"'
alias ansible-local-playbook='ansible-playbook -i localhost, -c local -e "ansible_python_interpreter=$(which python3)"'
alias ansible-local='ansible localhost -c local -i localhost, -e "ansible_python_interpreter=$(which python3)"'
alias aptitude='aptitude --display-format %p --quiet'
alias black='black --line-length 79'
alias cdtemp='cd "$(mktemp -d)"'
alias check_tcp='nc -vzw10'
alias check_unix='nc -Uvzw3'
alias clean-swp="find \$HOME/ -name '*.swp' -delete"
alias close='ssh -fnNTS ~/.ssh/%C.sock -O exit'
alias color='less --raw-control-chars -p'
alias concat="perl -pe 's/\\n/\\\\n/g'"
alias cphere='cp --target-directory=./'
@@ -98,8 +74,6 @@ alias df='df --output=source,fstype,size,used,avail,pcent,iavail,ipcent,target'
alias diff='diff --unified'
alias dpkglog="grep -v 'status\\|trigproc\\|configure' /var/log/dpkg.log"
alias gen-mac='hexdump -n5 -e '\''"02" 5/1 ":%02X" "\n"'\'' /dev/urandom'
alias gen-ssh-config="rc_make .ssh/config"
alias hcl2json='json2hcl -reverse'
alias jjb='jenkins-jobs'
alias l='ls -F'
alias la='ls -AF'
@@ -122,7 +96,6 @@ alias pre-commit-update-skel='pre-commit autoupdate --config ~/.config/git/skel/
# shellcheck disable=SC2139
alias rc_make="make --directory $HOME --always-make"
alias rc_update="rc_make vendored generated"
alias restart-kodi='ssh kodi.shore.co.il "sudo systemctl kill --kill-who=all --signal=9 xorg.service"'
# shellcheck disable=SC2032
alias rm='rm --dir'
alias screenshot-cleanup='find "$HOME/Pictures" -name "Screenshot from *.png" -delete'
@@ -133,10 +106,6 @@ alias todo="vim \$HOME/Documents/TODO.yml"
alias tolower='awk "{print tolower(\$0)}"'
# shellcheck disable=SC2142
alias toupper='awk "{print toupper(\$0)}"'
alias transmission-remote='forward kodi.shore.co.il 9091:localhost:9091 && transmission-remote'
alias unscp="scp -o \"UserKnownHostsFile /dev/null\" -o \"StrictHostKeyChecking no\""
alias unsftp="sftp -o \"UserKnownHostsFile /dev/null\" -o \"StrictHostKeyChecking no\""
alias unssh="ssh -o \"UserKnownHostsFile /dev/null\" -o \"StrictHostKeyChecking no\""
alias update-requirements='find -name "*requirements*.txt" -exec pur --requirement {} \;'
alias utcnow='date --utc --iso-8601=seconds'
# shellcheck disable=SC2139
@@ -144,13 +113,6 @@ alias wbr="ssh -t ns4.shore.co.il $(command -v wb)"
alias wifi-portal='curl --silent --fail --write-out "%{redirect_url}" --output /dev/null http://detectportal.firefox.com/success.txt'
alias xargs="xargs "

ansible_all () {
    pushd ~/Repositories/Shore/homelab/Ansible || return
    ansible all "$@"
    # shellcheck disable=SC2164
    popd
}

bak () {
    for x in "$@"
    do
@@ -158,14 +120,10 @@ bak () {
    done
}

black8() {
    black "$@" && flake8 "$@"
}

container_name() {
    if [ -f /run/.containerenv ]
    then
        # shellcheck disable=SC1091
        # shellcheck disable=SC1091,SC2154
        ( . /run/.containerenv; echo "$name"; )
    else
        hostname -s
@@ -190,80 +148,12 @@ genpass () {
    echo
}

kodi_scan () {
    # shellcheck disable=SC1083
    ssh kodi.shore.co.il curl --silent --fail --show-error --json \'{\"jsonrpc\": \"2.0\", \"id\": \"transmission\", \"method\": \"VideoLibrary.Scan\"}\' http://127.0.0.1:8080/jsonrpc | jt
    # shellcheck disable=SC1083
    ssh kodi.shore.co.il curl --silent --fail --show-error --json \'{\"jsonrpc\": \"2.0\", \"id\": \"transmission\", \"method\": \"AudioLibrary.Scan\"}\' http://127.0.0.1:8080/jsonrpc | jt
}

mnt_lib () {
    mkdir -p "$HOME/Library"
    rclone mount \
        --daemon \
        --gid "$(id -g)" \
        --vfs-cache-mode full \
        --uid "$(id -u)" \
        library:/ \
        "$HOME/Library"
}

new_experiment () {
    if [ "$#" -ne 1 ]
    then
        echo 'Usage: new_experiment EXPERIMENT_NAME' >&2
        return 1
    fi
    local name="$1"
    local repo="$HOME/Repositories/Shore/experiments"
    if [ ! -d "$repo/.git" ]
    then
        git clone git@git.shore.co.il:nimrod/experiments.git "$repo"
    fi
    # shellcheck disable=SC2164
    cd "$repo"
    git checkout master
    git checkout -b "$name/master"
}

# shellcheck disable=SC2120
prune_ssh_sockets () {
    { [ "${1:-}" != '-f' ] && [ "${1:-}" != '--force' ]; } || killall -v ssh || true
    find ~/.ssh/ \
        -maxdepth 1 \
        -type s \
        \! -name 'cm_*.sock' \
        -execdir sh -c 'lsof -t "$1" >/dev/null || rm "$1"' _ {} \;
}

set_title () {
    local default_title
    default_title="$(basename "$PWD")"
    printf "\033]0;%s\007" "${1:-$default_title}"
}

ssh_keyscan_add () {
    ssh-keyscan "$@" >> "$HOME/.ssh/known_hosts"
    sort -uo "$HOME/.ssh/known_hosts" "$HOME/.ssh/known_hosts"
}

sync_comics () {
    local this_month last_month format
    format='+kodi.shore.co.il:/srv/library/Comics/0-Day\ Week\ of\ %Y.%m.*'
    this_month="$( date "$format" )"
    last_month="$( date --date '1 month ago' "$format" )"
    rsync --prune-empty-dirs --ignore-missing-args --recursive --compress --progress --exclude "*.part" "$last_month" "$this_month" "$HOME/Downloads/Comics/"
    # shellcheck disable=SC2033
    find "$HOME/Downloads/Comics/" -name "$(date --date '2 month ago' +'0-Day\ Week\ of\ %Y.%m.*')" -exec rm -r {} +
}

temp_venv () {
    cdtemp
    venv .
    # shellcheck disable=SC1090,SC1091
    . bin/activate
}

toux () {
    touch "$@"
    chmod +x "$@"
+26
Changes for .bashrc.d/ansible: 26 added lines, 0 removed lines.
Original line number Diff line number Diff line
# shellcheck shell=bash
# vim: ft=sh

export ANSIBLE_CACHE_PLUGIN=jsonfile
export ANSIBLE_CACHE_PLUGIN_CONNECTION="$HOME/.ansible/facts"
export ANSIBLE_CALLBACKS_ENABLED="ansible.posix.profile_tasks, ansible.posix.timer"
export ANSIBLE_DEPRECATION_WARNINGS=True
export ANSIBLE_FORKS=5
export ANSIBLE_GATHERING=smart
export ANSIBLE_INVENTORY_ANY_UNPARSED_IS_FAILED=True
export ANSIBLE_PIPELINING=True
export ANSIBLE_PYTHON_INTERPRETER=auto
export ANSIBLE_RETRY_FILES_SAVE_PATH=/tmp/
export ANSIBLE_SSH_CONTROL_PATH="/tmp/ssh-%%h"
export ANSIBLE_SYSTEM_WARNINGS=True
export ANSIBLE_VERBOSITY=2

alias ansible-local-playbook='ansible-playbook -i localhost, -c local -e "ansible_python_interpreter=$(which python3)"'
alias ansible-local='ansible localhost -c local -i localhost, -e "ansible_python_interpreter=$(which python3)"'

ansible_all () {
    pushd ~/Repositories/Shore/homelab/Ansible || return
    ansible all "$@"
    # shellcheck disable=SC2164
    popd
}
+4
Changes for .bashrc.d/aws: 4 added lines, 0 removed lines.
Original line number Diff line number Diff line
# shellcheck shell=bash
# vim: ft=sh

export AWS_DEFAULT_PROFILE='shore'
+26
Changes for .bashrc.d/git: 26 added lines, 0 removed lines.
Original line number Diff line number Diff line
# shellcheck shell=bash
# vim: ft=sh

export GITLAB_BASE_URL='https://git.shore.co.il/api/v4'
export GITLAB_HOST='https://git.shore.co.il'
export PYTHON_GITLAB_CFG=~/.config/python-gitlab.cfg

alias all-repos='find "$HOME/Repositories" -maxdepth 3 -type d -name .git -print0 | xargs -IX -0 git -C "X/../"'

new_experiment () {
    if [ "$#" -ne 1 ]
    then
        echo 'Usage: new_experiment EXPERIMENT_NAME' >&2
        return 1
    fi
    local name="$1"
    local repo="$HOME/Repositories/Shore/experiments"
    if [ ! -d "$repo/.git" ]
    then
        git clone git@git.shore.co.il:nimrod/experiments.git "$repo"
    fi
    # shellcheck disable=SC2164
    cd "$repo"
    git checkout master
    git checkout -b "$name/master"
}
+1 −1
Changes for .bashrc.d/github.j2: 1 added line, 1 removed line.
Original line number Diff line number Diff line
# vim: ft=bash
export GITHUB_TOKEN='{{ run(["ph", "show", "--field", "CLI 2025 token", "Web Sites/GitHub"])["stdout"] }}'
export GITHUB_TOKEN='{{ run(["ph", "show", "--field", "CLI2026 token", "Web Sites/GitHub"])["stdout"] }}'
export GITHUB_OAUTH_TOKEN="$GITHUB_TOKEN"
Loading