231 lines
8.0 KiB
Plaintext
231 lines
8.0 KiB
Plaintext
|
#!/usr/bin/env bash
|
|||
|
|
|||
|
#echo " ";
|
|||
|
#echo " ▐▄• ▄ .▄▄ · ▄▄▄▄▄▄▄▄ .·▄▄▄▄▄▄ . ▐ ▄ ▄▄▄ ▄▄· ";
|
|||
|
#echo " █▌█▌▪▐█ ▀. •██ ▀▄.▀·▐▄▄·▀▄.▀·•█▌▐█▀▄ █·▐█ ▌▪";
|
|||
|
#echo " ·██· ▄▀▀▀█▄ ▐█.▪▐▀▀▪▄██▪ ▐▀▀▪▄▐█▐▐▌▐▀▀▄ ██ ▄▄";
|
|||
|
#echo " ▪▐█·█▌▐█▄▪▐█ ▐█▌·▐█▄▄▌██▌.▐█▄▄▌██▐█▌▐█•█▌▐███▌";
|
|||
|
#echo " ▀ •▀▀ ▀▀ ▀▀▀▀ ▀▀▀ ▀▀▀ ▀▀▀ ▀▀▀ ▀▀ █▪.▀ ▀·▀▀▀ ";
|
|||
|
|
|||
|
# If not running interactively, don't do anything
|
|||
|
[[ $- != *i* ]] && return
|
|||
|
|
|||
|
# shopt
|
|||
|
shopt -s autocd # change to named directory
|
|||
|
shopt -s cdspell # autocorrects cd misspellings
|
|||
|
shopt -s checkwinsize # checks term size when bash regains control
|
|||
|
shopt -s cmdhist # save multi-line commands in history as single line
|
|||
|
shopt -s dotglob # include dotfiles in filename expansion
|
|||
|
shopt -s expand_aliases # expand aliases
|
|||
|
shopt -s extglob # extended pattern matching
|
|||
|
shopt -s histappend # do not overwrite history
|
|||
|
|
|||
|
# tab-completion
|
|||
|
if ! shopt -oq posix; then
|
|||
|
if [ -f /usr/share/bash-completion/bash_completion ]; then
|
|||
|
. /usr/share/bash-completion/bash_completion
|
|||
|
elif [ -f /etc/bash_completion ]; then
|
|||
|
. /etc/bash_completion
|
|||
|
fi
|
|||
|
fi
|
|||
|
|
|||
|
# start gpg/ssh-agent
|
|||
|
unset SSH_AGENT_PID
|
|||
|
if [ "${gnupg_SSH_AUTH_SOCK_by:-0}" -ne $$ ]; then
|
|||
|
export SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket)"
|
|||
|
fi
|
|||
|
export GPG_TTY=$(tty)
|
|||
|
gpg-connect-agent updatestartuptty /bye >/dev/null
|
|||
|
|
|||
|
# if ! pgrep -u "$USER" ssh-agent >/dev/null; then
|
|||
|
# ssh-agent -t 1h >"$XDG_RUNTIME_DIR/ssh-agent.env"
|
|||
|
# fi
|
|||
|
# if [[ ! "$SSH_AUTH_SOCK" ]]; then
|
|||
|
# source "$XDG_RUNTIME_DIR/ssh-agent.env" >/dev/null
|
|||
|
# fi
|
|||
|
|
|||
|
envsetup() {
|
|||
|
umask 022
|
|||
|
alias which='command -v'
|
|||
|
source build/envsetup.sh
|
|||
|
|
|||
|
export LANG=C.UTF-8
|
|||
|
export _JAVA_OPTIONS=-XX:-UsePerfData
|
|||
|
export BUILD_DATETIME=$(cat out/build_date.txt 2>/dev/null || date -u +%s)
|
|||
|
echo "BUILD_DATETIME=$BUILD_DATETIME"
|
|||
|
export BUILD_NUMBER=$(cat out/soong/build_number.txt 2>/dev/null || date -u -d @$BUILD_DATETIME +%Y%m%d00)
|
|||
|
echo "BUILD_NUMBER=$BUILD_NUMBER"
|
|||
|
export DISPLAY_BUILD_NUMBER=true
|
|||
|
export BUILD_USERNAME=\u0000
|
|||
|
export BUILD_HOSTNAME=\u0000
|
|||
|
}
|
|||
|
|
|||
|
# extract | usage: ex <file>
|
|||
|
ex()
|
|||
|
{
|
|||
|
if [ -f "$1" ] ; then
|
|||
|
case $1 in
|
|||
|
*.tar.bz2) tar xjf $1 ;;
|
|||
|
*.tar.gz) tar xzf $1 ;;
|
|||
|
*.bz2) bunzip2 $1 ;;
|
|||
|
*.rar) unrar x $1 ;;
|
|||
|
*.gz) gunzip $1 ;;
|
|||
|
*.tar) tar xf $1 ;;
|
|||
|
*.tbz2) tar xjf $1 ;;
|
|||
|
*.tgz) tar xzf $1 ;;
|
|||
|
*.zip) unzip $1 ;;
|
|||
|
*.Z) uncompress $1;;
|
|||
|
*.7z) 7z x $1 ;;
|
|||
|
*.deb) ar x $1 ;;
|
|||
|
*.tar.xz) tar xf $1 ;;
|
|||
|
*.tar.zst) unzstd $1 ;;
|
|||
|
*) echo "'$1' cannot be extracted via ex()" ;;
|
|||
|
esac
|
|||
|
else
|
|||
|
echo "'$1' is not a valid file"
|
|||
|
fi
|
|||
|
}
|
|||
|
|
|||
|
# git-cherry-pick | usage: gcp <github commit url>
|
|||
|
gcp() {
|
|||
|
GCP_GIVEN=$1
|
|||
|
GCP_URL=$(echo ${GCP_GIVEN} | awk -F'/' '{print $1FS$2FS$3FS$4FS$5}')
|
|||
|
GCP_COMMIT=$(echo ${GCP_GIVEN} | awk -F'/' '{print $7}')
|
|||
|
git fetch $GCP_URL $GCP_COMMIT && git cherry-pick FETCH_HEAD
|
|||
|
}
|
|||
|
|
|||
|
# installed? | usage: is_available <executable>
|
|||
|
is_available() {
|
|||
|
command -v "$1" >/dev/null 2>&1
|
|||
|
}
|
|||
|
|
|||
|
# List lib dependencies of any lib/bin
|
|||
|
list_blob_deps() {
|
|||
|
readelf -d $1 | grep "\(NEEDED\)" | sed -r "s/.*\[(.*)\]/\1/"
|
|||
|
}
|
|||
|
|
|||
|
# pixeldrain upload | usage: pdup <file>
|
|||
|
PD_API_KEY="$(cat /mnt/files/Documents/store/pixeldrain)"
|
|||
|
pdup() {
|
|||
|
[ -z "$1" ] && echo "Error: File not specified!" && return
|
|||
|
ID=$(curl --progress-bar -T "$1" -u :$PD_API_KEY https://pixeldrain.com/api/file/ | cat | grep -Po '(?<="id":")[^"]*')
|
|||
|
echo -e "\nhttps://pixeldrain.com/u/$ID"
|
|||
|
}
|
|||
|
|
|||
|
# repo sync++ | usage: repofastsync <optional flags/repo>
|
|||
|
repofastsync() {
|
|||
|
#time schedtool -B -e ionice -n 1 \
|
|||
|
time "$(command -v repo)" sync \
|
|||
|
-c --no-tags --no-clone-bundle --force-sync -j16 \
|
|||
|
"$@"
|
|||
|
}
|
|||
|
|
|||
|
# random color-script scheme test
|
|||
|
scheme_test() {
|
|||
|
local COLOR_SCRIPT_REPO=https://api.github.com/repos/stark/Color-Scripts/contents/color-scripts
|
|||
|
wget -q -O - $(curl -s $COLOR_SCRIPT_REPO | jq '.[] | "\(.path) \(.download_url)"' -r | shuf -n1 | cut -d " " -f2) | bash
|
|||
|
}
|
|||
|
|
|||
|
# tere file explorer | usage: tere
|
|||
|
tere() {
|
|||
|
local result=$(command tere "$@")
|
|||
|
[ -n "$result" ] && cd -- "$result"
|
|||
|
}
|
|||
|
|
|||
|
# fetch random git commit message
|
|||
|
whatthecommit() {
|
|||
|
curl --silent --fail https://whatthecommit.com/index.txt
|
|||
|
}
|
|||
|
|
|||
|
# aliases
|
|||
|
alias ..="cd .."
|
|||
|
alias adp="adb push"
|
|||
|
alias cls="echo -e '\0033\0143'"
|
|||
|
alias config="/usr/bin/git --git-dir=$HOME/dotfiles --work-tree=$HOME"
|
|||
|
alias cp="cp -i"
|
|||
|
alias df="df -h"
|
|||
|
alias du="du -c -h"
|
|||
|
alias e="$EDITOR"
|
|||
|
alias fetch="neofetch --ascii ~/.config/neofetch/logo-ascii"
|
|||
|
alias free="free -m"
|
|||
|
alias grep="grep --color=tty -d skip"
|
|||
|
alias jctl="journalctl -p 3 -xb"
|
|||
|
alias ls='exa -l --color=always --group-directories-first'
|
|||
|
alias ll='exa -al --color=always --group-directories-first'
|
|||
|
alias lt='exa -aT --color=always --group-directories-first'
|
|||
|
alias l.='exa -a | egrep "^\."'
|
|||
|
alias merge='xrdb -merge ~/.Xresources'
|
|||
|
alias mirror="sudo reflector -f 30 -l 30 --number 10 --verbose --save /etc/pacman.d/mirrorlist"
|
|||
|
alias mirrord="sudo reflector --latest 50 --number 20 --sort delay --save /etc/pacman.d/mirrorlist"
|
|||
|
alias mirrors="sudo reflector --latest 50 --number 20 --sort score --save /etc/pacman.d/mirrorlist"
|
|||
|
alias mirrora="sudo reflector --latest 50 --number 20 --sort age --save /etc/pacman.d/mirrorlist"
|
|||
|
alias mkcheetah="m otatools vendorbootimage vendorkernelbootimage target-files-package"
|
|||
|
alias mkdir="mkdir -p -v"
|
|||
|
alias more="less"
|
|||
|
alias mv="mv -i"
|
|||
|
alias nano="nano -au"
|
|||
|
alias ping="ping -c 5"
|
|||
|
alias psa="ps auxf"
|
|||
|
alias psgrep="ps aux | grep -v grep | grep -i -e VSZ -e"
|
|||
|
alias psmem='ps auxf | sort -nr -k 4'
|
|||
|
alias pscpu='ps auxf | sort -nr -k 3'
|
|||
|
alias qr_read="maim -qs | zbarimg -q --raw - | xclip -selection clipboard -f"
|
|||
|
alias reboot="sudo systemctl -i reboot"
|
|||
|
alias reload="clear && reset && cls && source $HOME/.xstefenrc"
|
|||
|
alias rm="rm -i"
|
|||
|
alias rp="repopick "
|
|||
|
alias rr='curl -s -L https://raw.githubusercontent.com/keroserene/rickrollrc/master/roll.sh | bash'
|
|||
|
alias showcommands="croot && gzip -cd out/verbose.log.gz | less -R"
|
|||
|
alias ss_sel_clip="maim -s | xclip -selection clipboard -t image/png"
|
|||
|
alias ss_active_save="maim -i $(xdotool getactivewindow) ~/Pictures/maim$(date +%s).jpg"
|
|||
|
alias ss_full_save="maim ~/Pictures/maim-$(date +%s).png"
|
|||
|
alias startx="startx $HOME/.xinitrc $@"
|
|||
|
if is_available doas; then
|
|||
|
complete -cf doas
|
|||
|
alias sudoedit="doas rnano"
|
|||
|
else
|
|||
|
alias sudo="sudo "
|
|||
|
fi
|
|||
|
alias sysu="systemctl --user"
|
|||
|
alias update-grub="grub-mkconfig -o /boot/grub/grub.cfg"
|
|||
|
alias wget="wget -c -t 0 --retry-connrefused"
|
|||
|
alias wttr="curl wttr.in/dfw?format=3"
|
|||
|
alias obxp='xprop | grep "WM_WINDOW_ROLE\|WM_CLASS" && echo "WM_CLASS(STRING) = \"NAME\", \"CLASS\""'
|
|||
|
#alias xup="sudo pacman -Sy && sudo powerpill -Su && paru -Su"
|
|||
|
alias xup='yay'
|
|||
|
alias yabs="curl -sL yabs.sh | bash"
|
|||
|
|
|||
|
# env vars
|
|||
|
export USE_CCACHE=1
|
|||
|
export CCACHE_DIR="/mnt/ccache"
|
|||
|
export CCACHE_EXEC="$(command -v ccache)"
|
|||
|
export EDITOR="nano"
|
|||
|
export WITHOUT_CHECK_API=true
|
|||
|
export SKIP_ABI_CHECKS=true
|
|||
|
export WITH_GAPPS=true
|
|||
|
export WITH_GMS=true
|
|||
|
export KERNEL_LTO=thin
|
|||
|
#export GLOBAL_THINLTO=true
|
|||
|
export USE_THINLTO_CACHE=true
|
|||
|
|
|||
|
# mounts / path
|
|||
|
[[ $PATH != ?(*:)$HOME/.local/bin?(:*) ]] && export PATH=$HOME/.local/bin:$PATH
|
|||
|
[[ $PATH != ?(*:)$HOME/.cargo/bin?(:*) ]] && export PATH=$PATH:$HOME/.cargo/bin
|
|||
|
[[ ! $(findmnt -rno SOURCE,TARGET /mnt/ccache) ]] && mount /mnt/ccache
|
|||
|
|
|||
|
# ------------------------------------------------------------------
|
|||
|
# misc
|
|||
|
# ------------------------------------------------------------------
|
|||
|
|
|||
|
# mondays
|
|||
|
eval $(thefuck --alias FUCK)
|
|||
|
|
|||
|
# sudo prompt colors
|
|||
|
export SUDO_PROMPT="$(tput bold setab 1 setaf 7)[sudo]$(tput sgr0) $(tput setaf 6)password for$(tput sgr0) $(tput setaf 5)%p$(tput sgr0): "
|
|||
|
|
|||
|
# prompt
|
|||
|
#colorscript -e random
|
|||
|
#eval "$(starship init bash)"
|
|||
|
SBP_PATH=$HOME/.sbp
|
|||
|
. ${SBP_PATH}/sbp.bash
|