update bash script
This commit is contained in:
parent
b56a08eaeb
commit
340f797fd0
3 changed files with 53 additions and 543 deletions
334
bash/.bashrc
334
bash/.bashrc
|
|
@ -1,334 +0,0 @@
|
||||||
# If not running interactively, don't do anything
|
|
||||||
case $- in
|
|
||||||
*i*) ;;
|
|
||||||
*) return;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
# don't put duplicate lines or lines starting with space in the history.
|
|
||||||
# See bash(1) for more options
|
|
||||||
HISTCONTROL=ignoreboth
|
|
||||||
|
|
||||||
# append to the history file, don't overwrite it
|
|
||||||
shopt -s histappend
|
|
||||||
|
|
||||||
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
|
|
||||||
HISTSIZE=1000
|
|
||||||
HISTFILESIZE=2000
|
|
||||||
|
|
||||||
# check the window size after each command and, if necessary,
|
|
||||||
# update the values of LINES and COLUMNS.
|
|
||||||
shopt -s checkwinsize
|
|
||||||
|
|
||||||
# If set, the pattern "**" used in a pathname expansion context will
|
|
||||||
# match all files and zero or more directories and subdirectories.
|
|
||||||
#shopt -s globstar
|
|
||||||
|
|
||||||
# make less more friendly for non-text input files, see lesspipe(1)
|
|
||||||
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
|
|
||||||
|
|
||||||
# set variable identifying the chroot you work in (used in the prompt below)
|
|
||||||
if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
|
|
||||||
debian_chroot=$(cat /etc/debian_chroot)
|
|
||||||
fi
|
|
||||||
|
|
||||||
# set a fancy prompt (non-color, unless we know we "want" color)
|
|
||||||
case "$TERM" in
|
|
||||||
xterm-color|*-256color) color_prompt=yes;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
# If this is an xterm set the title to user@host:dir
|
|
||||||
case "$TERM" in
|
|
||||||
xterm*|rxvt*)
|
|
||||||
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
# enable color support for ls and grep (even tho i don't use grep ???)
|
|
||||||
if [ -x /usr/bin/dircolors ]; then
|
|
||||||
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
|
|
||||||
alias ls='ls --color=auto'
|
|
||||||
alias grep='grep --color=auto'
|
|
||||||
fi
|
|
||||||
|
|
||||||
# -------------- Aliases
|
|
||||||
alias gs="git status"
|
|
||||||
|
|
||||||
# ll alias breakdown
|
|
||||||
# -a includes hidden files
|
|
||||||
# -l displays the listing in long format, showing file attributes such as permissions
|
|
||||||
# -F appends a character to each entry in the listing to indicate the file type (e.g '/' for directories and '*' for executables)
|
|
||||||
alias ll="ls -alF"
|
|
||||||
|
|
||||||
# la alias breakdown
|
|
||||||
# -A list all entries without ./ and ../
|
|
||||||
alias la="ls -A"
|
|
||||||
|
|
||||||
# l alias breakdown
|
|
||||||
# -C list entries by columns
|
|
||||||
# -F appends a character to each entry in the listing to indicate the file type (e.g '/' for directories and '*' for executables)
|
|
||||||
alias l="ls -CF"
|
|
||||||
|
|
||||||
# Add an "alert" alias for long running commands. Use like so:
|
|
||||||
# sleep 10; alert
|
|
||||||
alias alert='notify-send --urgency=normal -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
|
|
||||||
|
|
||||||
# add alias for clear, makes it easier
|
|
||||||
alias cc="clear"
|
|
||||||
|
|
||||||
# always select the clipboard
|
|
||||||
alias xc="xclip -selection clipboard"
|
|
||||||
|
|
||||||
# Nice line headers for logs
|
|
||||||
ERROR=$'\033[39;41mERROR:\033[0m'
|
|
||||||
SUCCESS=$'\033[39;42mSUCCESS:\033[0m'
|
|
||||||
WARNING=$'\033[39;43mWARNING:\033[0m'
|
|
||||||
INFO=$'\033[39;44mINFO:\033[0m'
|
|
||||||
|
|
||||||
# -------------- Functions
|
|
||||||
# list directory and cd into it
|
|
||||||
sd() {
|
|
||||||
local path=${1:-.}
|
|
||||||
local result=$(ls -d ${path}/*/ 2> /dev/null | fzf)
|
|
||||||
if [[ -n "${result}" ]]; then
|
|
||||||
cd "${result}"
|
|
||||||
else
|
|
||||||
echo -e "$ERROR No directories found or no selection made."
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# list files and opens it in neovim
|
|
||||||
sf() {
|
|
||||||
local path=${2:-.}
|
|
||||||
if [[ $1 == "-h" ]]; then
|
|
||||||
local result=$(find ${path} -type f -name '.*' 2> /dev/null | fzf)
|
|
||||||
else
|
|
||||||
local result=$(find ${path} -type f 2> /dev/null | fzf)
|
|
||||||
fi
|
|
||||||
if [[ -n "${result}" ]]; then
|
|
||||||
nvim "${result}"
|
|
||||||
else
|
|
||||||
echo -e "$ERROR No files found or no selecteion made."
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# fuzzy cd into specific folders
|
|
||||||
fcd() {
|
|
||||||
local selected_dir=$({
|
|
||||||
echo "$HOME/.config/asa"
|
|
||||||
echo "$HOME/.config/alacritty"
|
|
||||||
echo "$HOME/.cache"
|
|
||||||
echo "$HOME/.cache/asadesuka"
|
|
||||||
echo "$HOME/Documents/Obsidian Vault"
|
|
||||||
find "$HOME/ghq" -mindepth 2 -maxdepth 2 -type d
|
|
||||||
ls -d -1 "$HOME/"/*/ | grep -v \.git
|
|
||||||
} | fzf)
|
|
||||||
|
|
||||||
if [ -n "$selected_dir" ]; then
|
|
||||||
cd "$selected_dir"
|
|
||||||
if [[ -f .nvmrc ]]; then
|
|
||||||
NVMRC_VERSION=$(cat .nvmrc)
|
|
||||||
CURRENT_VERSION=$(nvm current)
|
|
||||||
if [ "$NVMRC_VERSIOn" != "$CURRENT_VERSION" ]; then
|
|
||||||
nvm use
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo -e "$ERROR No selection made."
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# clone repository
|
|
||||||
cl() {
|
|
||||||
local url=$1
|
|
||||||
local ghq_dir="$HOME/ghq"
|
|
||||||
|
|
||||||
# extract project name
|
|
||||||
if [[ $url =~ git@github\.com:([^/]+)/([^/]+)\.git ]]; then
|
|
||||||
local project_name="${BASH_REMATCH[1]}"
|
|
||||||
local repository_name="${BASH_REMATCH[2]}"
|
|
||||||
elif [[ $url =~ https://github\.com/([^/]+)/([^/]+)\.git ]]; then
|
|
||||||
local project_name="${BASH_REMATCH[1]}"
|
|
||||||
local repository_name="${BASH_REMATCH[2]}"
|
|
||||||
elif [[ $# -ne 0 ]]; then
|
|
||||||
local project_name="juancwu"
|
|
||||||
local repository_name="$url"
|
|
||||||
local url="git@github.com:juancwu/$repository_name.git"
|
|
||||||
else
|
|
||||||
echo -e "$ERROR Invalid URL format"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# check if directory for project exists or not
|
|
||||||
local project_dir="${ghq_dir}/${project_name}/${repository_name}"
|
|
||||||
if [[ ! -d $project_dir ]]; then
|
|
||||||
mkdir -p $project_dir
|
|
||||||
fi
|
|
||||||
|
|
||||||
git clone $url $project_dir
|
|
||||||
}
|
|
||||||
|
|
||||||
# get branch if available
|
|
||||||
parse-git-branch() {
|
|
||||||
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
|
|
||||||
}
|
|
||||||
|
|
||||||
# delete local branches that don't exists in remote repository
|
|
||||||
git-prune() {
|
|
||||||
git fetch --prune
|
|
||||||
git branch -vv | grep '\[origin/.*: gone\]' | awk '{print $1}' | xargs git branch -d
|
|
||||||
}
|
|
||||||
|
|
||||||
# fuzzy find branches and switch to selected branch
|
|
||||||
gc() {
|
|
||||||
local selected_branch=$(git branch | fzf | sed 's/^[ \*]*//')
|
|
||||||
|
|
||||||
if [ -n "$selected_branch" ]; then
|
|
||||||
git checkout "$selected_branch"
|
|
||||||
else
|
|
||||||
echo "No branch selected"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# fuzzy find remote branches and switch to selected branch
|
|
||||||
gcr() {
|
|
||||||
git fetch
|
|
||||||
local selected_branch=$(git branch -r | fzf | sed -E 's/^([ \*]*origin\/[\ *]*)*//')
|
|
||||||
|
|
||||||
if [ -n "$selected_branch" ]; then
|
|
||||||
git checkout "$selected_branch"
|
|
||||||
else
|
|
||||||
echo "No branch selected"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# makes it easier to spin up ngrok with static domain, pass in the port ngrok needs to listen
|
|
||||||
sngrok() {
|
|
||||||
ngrok http --domain=hyena-merry-literally.ngrok-free.app $1
|
|
||||||
}
|
|
||||||
|
|
||||||
# Set prompt
|
|
||||||
if [ "$color_prompt" = yes ]; then
|
|
||||||
PS1="${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[01;31m\]\$(parse-git-branch)\[\033[00m\] \$ "
|
|
||||||
else
|
|
||||||
PS1="${debian_chroot:+($debian_chroot)}\u@\h:\w\$(parse-git-branch)\$ "
|
|
||||||
fi
|
|
||||||
unset color_prompt
|
|
||||||
|
|
||||||
# setup terminal stuff
|
|
||||||
# determine initial terminal color mode
|
|
||||||
TERM_COLOR_MODE=dark
|
|
||||||
command -v asadesuka > /dev/null 2>&1
|
|
||||||
if [ $? -eq 0 ]; then
|
|
||||||
IS_ASA=$(asadesuka -offset=30)
|
|
||||||
if [ $IS_ASA == "true" ]; then
|
|
||||||
TERM_COLOR_MODE=light
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
CURRENT_HOUR=$(date +"%H")
|
|
||||||
SEVEN_AM=7
|
|
||||||
SEVEN_PM=19
|
|
||||||
if [ $CURRENT_HOUR -ge $SEVEN_AM ] && [ $CURRENT_HOUR -lt $SEVEN_PM ]; then
|
|
||||||
TERM_COLOR_MODE=light
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
export TERM_COLOR_MODE
|
|
||||||
|
|
||||||
# set the terminal color theme
|
|
||||||
USE_TERM=kitty
|
|
||||||
if [ $TERM_COLOR_MODE == "light" ]; then
|
|
||||||
if [ $USE_TERM == "kitty" ]; then
|
|
||||||
kitten @ set-colors --all "$HOME/.config/kitty/light.conf"
|
|
||||||
fi
|
|
||||||
if [ $USE_TERM == "alacritty" ]; then
|
|
||||||
theme_link="$HOME/.config/alacritty/theme.toml"
|
|
||||||
rm -rf "$theme_link"
|
|
||||||
ln "$HOME/.config/alacritty/themes/themes/catppuccin_latte.toml" "$theme_link"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
if [ $USE_TERM == "kitty" ]; then
|
|
||||||
kitten @ set-colors --all "$HOME/.config/kitty/dark.conf"
|
|
||||||
fi
|
|
||||||
if [ $USE_TERM == "alacritty" ]; then
|
|
||||||
theme_link="$HOME/.config/alacritty/theme.toml"
|
|
||||||
rm -r "$theme_link"
|
|
||||||
ln "$HOME/.config/alacritty/themes/themes/catppuccin_mocha.toml" "$theme_link"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# setup kitty, it will export TERM_COLOR_MODE (can be light or dark)
|
|
||||||
# source ~/.config/kitty/setup.sh
|
|
||||||
# function to toggle kitty terminal theme
|
|
||||||
toggle_theme() {
|
|
||||||
if [ "$TERM_COLOR_MODE" == "light" ]; then
|
|
||||||
export TERM_COLOR_MODE=dark
|
|
||||||
theme="catppuccin_latte"
|
|
||||||
else
|
|
||||||
export TERM_COLOR_MODE=light
|
|
||||||
theme="catppuccin_mocha"
|
|
||||||
fi
|
|
||||||
if [ $USE_TERM == "kitty" ]; then
|
|
||||||
kitten @ set-colors --all "$HOME/.config/kitty/$TERM_COLOR_MODE.conf"
|
|
||||||
fi
|
|
||||||
if [ $USE_TERM == "alacritty" ]; then
|
|
||||||
theme_link="$HOME/.config/alacritty/theme.toml"
|
|
||||||
rm -r "$theme_link"
|
|
||||||
ln "$HOME/.config/alacritty/themes/themes/$theme.toml" "$theme_link"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
type -p curl >/dev/null || echo -e "$WARNING curl is not installed"
|
|
||||||
|
|
||||||
command -v nvm > /dev/null 2>&1
|
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
echo -e "$WARNING nvm is not installed"
|
|
||||||
fi
|
|
||||||
|
|
||||||
command -v pnpm > /dev/null 2>&1
|
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
echo -e "$WARNING pnpm is not installed"
|
|
||||||
fi
|
|
||||||
|
|
||||||
command -v gh > /dev/null 2>&1
|
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
echo -e "$WARNING gh cli is not installed"
|
|
||||||
fi
|
|
||||||
|
|
||||||
command -v nvim > /dev/null 2>&1
|
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
echo -e "$ERROR neovim is not installed"
|
|
||||||
fi
|
|
||||||
|
|
||||||
command -v yarn > /dev/null 2>&1
|
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
echo -e "$WARNING yarn is not installed"
|
|
||||||
fi
|
|
||||||
|
|
||||||
command -v bun > /dev/null 2>&1
|
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
echo -e "$WARNING bun is not installed"
|
|
||||||
fi
|
|
||||||
|
|
||||||
command -v notify-send > /dev/null 2>&1
|
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
echo -e "$WARNING notify-send is not installed. Will affect the alias: \033[34;49;1malert\033[0m"
|
|
||||||
fi
|
|
||||||
|
|
||||||
command -v lazygit > /dev/null 2>&1
|
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
echo -e "$WARNING lazygit is not installed"
|
|
||||||
else
|
|
||||||
alias lg="lazygit"
|
|
||||||
fi
|
|
||||||
|
|
||||||
command -v rustc > /dev/null 2>&1
|
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
echo -e "$WARNING rust is not installed"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# set bat theme
|
|
||||||
export BAT_THEME="ansi"
|
|
||||||
|
|
||||||
# walk editor
|
|
||||||
export EDITOR=vim
|
|
||||||
|
|
@ -1,182 +0,0 @@
|
||||||
# If not running interactively, don't do anything
|
|
||||||
case $- in
|
|
||||||
*i*) ;;
|
|
||||||
*) return;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
# don't put duplicate lines or lines starting with space in the history.
|
|
||||||
# See bash(1) for more options
|
|
||||||
HISTCONTROL=ignoreboth
|
|
||||||
|
|
||||||
# append to the history file, don't overwrite it
|
|
||||||
shopt -s histappend
|
|
||||||
|
|
||||||
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
|
|
||||||
HISTSIZE=1000
|
|
||||||
HISTFILESIZE=2000
|
|
||||||
|
|
||||||
# check the window size after each command and, if necessary,
|
|
||||||
# update the values of LINES and COLUMNS.
|
|
||||||
shopt -s checkwinsize
|
|
||||||
|
|
||||||
# enable color support for ls and grep (even tho i don't use grep ???)
|
|
||||||
if [ -x /usr/bin/dircolors ]; then
|
|
||||||
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
|
|
||||||
alias ls='ls --color=auto'
|
|
||||||
alias grep='grep --color=auto'
|
|
||||||
fi
|
|
||||||
|
|
||||||
# -------------- Aliases
|
|
||||||
alias gs="git status"
|
|
||||||
|
|
||||||
alias lg="lazygit"
|
|
||||||
|
|
||||||
# ll alias breakdown
|
|
||||||
# -a includes hidden files
|
|
||||||
# -l displays the listing in long format, showing file attributes such as permissions
|
|
||||||
# -F appends a character to each entry in the listing to indicate the file type (e.g '/' for directories and '*' for executables)
|
|
||||||
alias ll="ls -alF"
|
|
||||||
|
|
||||||
# la alias breakdown
|
|
||||||
# -A list all entries without ./ and ../
|
|
||||||
alias la="ls -A"
|
|
||||||
|
|
||||||
# l alias breakdown
|
|
||||||
# -C list entries by columns
|
|
||||||
# -F appends a character to each entry in the listing to indicate the file type (e.g '/' for directories and '*' for executables)
|
|
||||||
alias l="ls -CF"
|
|
||||||
|
|
||||||
# add alias for clear, makes it easier
|
|
||||||
alias cc="clear"
|
|
||||||
|
|
||||||
# always select the clipboard
|
|
||||||
alias xc="xclip -selection clipboard"
|
|
||||||
|
|
||||||
# Nice line headers for logs
|
|
||||||
ERROR=$'\033[39;41mERROR:\033[0m'
|
|
||||||
SUCCESS=$'\033[39;42mSUCCESS:\033[0m'
|
|
||||||
WARNING=$'\033[39;43mWARNING:\033[0m'
|
|
||||||
INFO=$'\033[39;44mINFO:\033[0m'
|
|
||||||
|
|
||||||
# -------------- Functions
|
|
||||||
# fuzzy cd into specific folders
|
|
||||||
fcd() {
|
|
||||||
local selected_dir=$({
|
|
||||||
find "$HOME/.config" -maxdepth 1 -type d
|
|
||||||
find "$HOME/.cache" -maxdepth 1 -type d
|
|
||||||
find "/opt/ghq" -mindepth 2 -maxdepth 2 -type d
|
|
||||||
ls -d -1 "/opt/"/*/ | grep -v \.git
|
|
||||||
} | fzf)
|
|
||||||
|
|
||||||
if [ -n "$selected_dir" ]; then
|
|
||||||
cd "$selected_dir"
|
|
||||||
if [[ -f .nvmrc ]]; then
|
|
||||||
NVMRC_VERSION=$(cat .nvmrc)
|
|
||||||
CURRENT_VERSION=$(nvm current)
|
|
||||||
if [ "$NVMRC_VERSIOn" != "$CURRENT_VERSION" ]; then
|
|
||||||
nvm use
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo -e "$ERROR No selection made."
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# clone repository
|
|
||||||
cl() {
|
|
||||||
local url=$1
|
|
||||||
local ghq_dir="/opt/ghq"
|
|
||||||
|
|
||||||
# extract project name
|
|
||||||
if [[ $url =~ git@github\.com:([^/]+)/([^/]+)\.git ]]; then
|
|
||||||
local project_name="${BASH_REMATCH[1]}"
|
|
||||||
local repository_name="${BASH_REMATCH[2]}"
|
|
||||||
elif [[ $url =~ https://github\.com/([^/]+)/([^/]+)\.git ]]; then
|
|
||||||
local project_name="${BASH_REMATCH[1]}"
|
|
||||||
local repository_name="${BASH_REMATCH[2]}"
|
|
||||||
elif [[ $# -ne 0 ]]; then
|
|
||||||
local project_name="juancwu"
|
|
||||||
local repository_name="$url"
|
|
||||||
local url="git@github.com:juancwu/$repository_name.git"
|
|
||||||
else
|
|
||||||
echo -e "$ERROR Invalid URL format"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# check if directory for project exists or not
|
|
||||||
local project_dir="${ghq_dir}/${project_name}/${repository_name}"
|
|
||||||
if [[ ! -d $project_dir ]]; then
|
|
||||||
mkdir -p $project_dir
|
|
||||||
fi
|
|
||||||
|
|
||||||
git clone $url $project_dir
|
|
||||||
}
|
|
||||||
|
|
||||||
# get branch if available
|
|
||||||
parse-git-branch() {
|
|
||||||
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
|
|
||||||
}
|
|
||||||
|
|
||||||
# delete local branches that don't exists in remote repository
|
|
||||||
git-prune() {
|
|
||||||
git fetch --prune
|
|
||||||
git branch -vv | grep '\[origin/.*: gone\]' | awk '{print $1}' | xargs git branch -d
|
|
||||||
}
|
|
||||||
|
|
||||||
# fuzzy find branches and switch to selected branch
|
|
||||||
gc() {
|
|
||||||
local selected_branch=$(git branch | fzf | sed 's/^[ \*]*//')
|
|
||||||
|
|
||||||
if [ -n "$selected_branch" ]; then
|
|
||||||
git checkout "$selected_branch"
|
|
||||||
else
|
|
||||||
echo "No branch selected"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# fuzzy find remote branches and switch to selected branch
|
|
||||||
gcr() {
|
|
||||||
git fetch
|
|
||||||
local selected_branch=$(git branch -r | fzf | sed -E 's/^([ \*]*origin\/[\ *]*)*//')
|
|
||||||
|
|
||||||
if [ -n "$selected_branch" ]; then
|
|
||||||
git checkout "$selected_branch"
|
|
||||||
else
|
|
||||||
echo "No branch selected"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# makes it easier to spin up ngrok with static domain, pass in the port ngrok needs to listen
|
|
||||||
sngrok() {
|
|
||||||
ngrok http --domain=hyena-merry-literally.ngrok-free.app $1
|
|
||||||
}
|
|
||||||
|
|
||||||
export ASA_LAT="43.46680000"
|
|
||||||
export ASA_LNG="-80.51639000"
|
|
||||||
export ASA_TZID="UTC"
|
|
||||||
|
|
||||||
export LANG=en_CA.UTF-8
|
|
||||||
export LC_ALL=en_CA.UTF-8
|
|
||||||
|
|
||||||
# set bat theme
|
|
||||||
export BAT_THEME="ansi"
|
|
||||||
|
|
||||||
# set sudoedit editor
|
|
||||||
export EDITOR="nvim"
|
|
||||||
export VISUAL="nvim"
|
|
||||||
|
|
||||||
source "/opt/.cargo/env"
|
|
||||||
|
|
||||||
# pnpm
|
|
||||||
export PNPM_HOME="$HOME/.local/share/pnpm"
|
|
||||||
case ":$PATH:" in
|
|
||||||
*":$PNPM_HOME:"*) ;;
|
|
||||||
*) export PATH="$PNPM_HOME:$PATH" ;;
|
|
||||||
esac
|
|
||||||
# pnpm end
|
|
||||||
|
|
||||||
export NVM_DIR="/opt/.nvm"
|
|
||||||
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
|
|
||||||
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
|
|
||||||
|
|
||||||
export PATH=$PATH:/usr/local/go/bin
|
|
||||||
|
|
@ -57,40 +57,66 @@ sf() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# fuzzy cd into specific folders
|
# fuzzy find all directories from cwd using fd
|
||||||
|
# or quickly select best match from query
|
||||||
fcd() {
|
fcd() {
|
||||||
local selected_dir=""
|
local selected_dir=""
|
||||||
|
|
||||||
|
# Common directories to exclude
|
||||||
|
local exclude_dirs=(
|
||||||
|
".git"
|
||||||
|
"node_modules"
|
||||||
|
"vendor"
|
||||||
|
".cache"
|
||||||
|
"dist"
|
||||||
|
"build"
|
||||||
|
"target"
|
||||||
|
".next"
|
||||||
|
".nuxt"
|
||||||
|
"__pycache__"
|
||||||
|
".pytest_cache"
|
||||||
|
".venv"
|
||||||
|
"venv"
|
||||||
|
"env"
|
||||||
|
".env"
|
||||||
|
"coverage"
|
||||||
|
".nyc_output"
|
||||||
|
".sass-cache"
|
||||||
|
"bower_components"
|
||||||
|
".idea"
|
||||||
|
".vscode"
|
||||||
|
".vs"
|
||||||
|
"*.egg-info"
|
||||||
|
".tox"
|
||||||
|
".mypy_cache"
|
||||||
|
".ruff_cache"
|
||||||
|
".turbo"
|
||||||
|
"out"
|
||||||
|
"tmp"
|
||||||
|
".svn"
|
||||||
|
".hg"
|
||||||
|
".bzr"
|
||||||
|
)
|
||||||
|
|
||||||
|
# Build fd exclude arguments
|
||||||
|
local fd_excludes=""
|
||||||
|
for dir in "${exclude_dirs[@]}"; do
|
||||||
|
fd_excludes="$fd_excludes -E $dir"
|
||||||
|
done
|
||||||
|
|
||||||
if [ $# -eq 1 ]; then
|
if [ $# -eq 1 ]; then
|
||||||
selected_dir=$({
|
# Use fd with type directory, exclude common dirs, and apply fzf filter
|
||||||
find "$HOME/.config" -maxdepth 1 -type d
|
selected_dir=$(fd -t d $fd_excludes . | fzf --filter="$1" --select-1 --exit-0 | head -1)
|
||||||
find "$HOME/.config" -maxdepth 1 -type l
|
|
||||||
find "$HOME/.cache" -maxdepth 1 -type d
|
|
||||||
find "$HOME/ghq" -mindepth 2 -maxdepth 2 -type d
|
|
||||||
ls -d -1 "$HOME/"/*/ | grep -v \.git
|
|
||||||
} | fzf --filter="$1" --select-1 --exit-0 | head -1)
|
|
||||||
else
|
else
|
||||||
selected_dir=$({
|
# Interactive selection with fzf
|
||||||
find "$HOME/.config" -maxdepth 1 -type d
|
selected_dir=$(fd -t d $fd_excludes . | fzf)
|
||||||
find "$HOME/.config" -maxdepth 1 -type l
|
|
||||||
find "$HOME/.cache" -maxdepth 1 -type d
|
|
||||||
find "$HOME/ghq" -mindepth 2 -maxdepth 2 -type d
|
|
||||||
ls -d -1 "$HOME/"/*/ | grep -v \.git
|
|
||||||
} | fzf)
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "$selected_dir" ]; then
|
if [ -n "$selected_dir" ]; then
|
||||||
cd "$selected_dir"
|
cd "$selected_dir"
|
||||||
if [[ -f .nvmrc ]]; then
|
else
|
||||||
NVMRC_VERSION=$(cat .nvmrc)
|
echo -e "$ERROR No selection made or no directories found."
|
||||||
CURRENT_VERSION=$(nvm current)
|
fi
|
||||||
if [ "$NVMRC_VERSIOn" != "$CURRENT_VERSION" ]; then
|
|
||||||
nvm use
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo -e "$ERROR No selection made."
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# fuzzy find all directories from cwd
|
# fuzzy find all directories from cwd
|
||||||
Loading…
Add table
Add a link
Reference in a new issue