feat: script updates

This commit is contained in:
2024-06-23 10:20:52 +03:00
parent 35e353936b
commit 856391c9ff
4 changed files with 66 additions and 11 deletions

View File

@@ -85,7 +85,7 @@ return {
vim.api.nvim_create_autocmd(event, {
buffer = bufnr,
group = group,
callback = function() format() end,
callback = format,
desc = "[lsp] format on save",
})
-- end

View File

@@ -106,6 +106,15 @@ if [[ -f "$HOME/.cargo/env" ]]; then
. "$HOME/.cargo/env"
fi
if [[ -d "$HOME/Dev/gba/butano" ]]; then
export BUTANO_HOME="$HOME/Dev/gba/butano"
fi
if [[ -d "/opt/devkitpro" ]]; then
export DEVKITPRO="/opt/devkitpro"
export DEVKITARM="/opt/devkitpro/devkitARM"
fi
if [[ -f ~/.fzf.zsh ]]; then source ~/.fzf.zsh; fi
if [[ -f /opt/homebrew/opt/chruby/share/chruby/chruby.sh ]]; then source /opt/homebrew/opt/chruby/share/chruby/chruby.sh; fi
if [[ -f $(which rbenv) ]]; then eval "$(rbenv init - zsh)"; fi

View File

@@ -2,7 +2,7 @@
type src >/dev/null || source "$DOTFILES/zplug.init.zsh"
echo_yellow "Preparing..."
src exports
src -q exports
if is_mac && [[ ! -d "$HOME/Library/ApplicationSupport" ]]; then
ln -s "$HOME/Library/Application Support" "$HOME/Library/ApplicationSupport"

View File

@@ -76,14 +76,23 @@ is_linux() {
rc() {
if [[ $# -eq 0 ]]; then
echo_red "Usage: rc [-n] <dotfile>"
echo_red "Usage: rc [-n] [-q] <dotfile>"
return 1
fi
no_src=0
quiet=0
if [[ $1 == '-n' ]]; then
no_src=1
while [[ $# -gt 1 ]]; do
case $1 in
-n)
no_src=1
;;
-q)
quiet=1
;;
esac
shift
fi
done
if [[ -f "$DOTFILES/$1.sh" ]]; then
file="$DOTFILES/$1.sh"
@@ -98,9 +107,16 @@ rc() {
newhash=$(md5 $file)
if [[ $? -eq 0 && $hash != $newhash ]]; then
if [[ $no_src -ne 1 ]]; then src $1; fi
if [[ $no_src -ne 1 ]]; then
if [[ $quiet -ne 1 ]]; then
src $1
else
src -q $1
fi
fi
else
echo "No changes made"
return 2
fi
return 0
fi
@@ -110,10 +126,20 @@ rc() {
src() {
if [[ $# -eq 0 ]]; then
echo_red "Usage: src <dotfile>"
echo_red "Usage: src [-q] <dotfile>"
return 1
fi
while [[ $# -gt 1 ]]; do
case $1 in
-q)
quiet=1
;;
esac
shift
done
if [[ -f "$DOTFILES/$1.sh" ]]; then
file="$DOTFILES/$1.sh"
else
@@ -121,7 +147,9 @@ src() {
fi
if [[ -f $file ]]; then
echo "Reloading $file..."
if [[ $quiet -ne 1 ]]; then
echo "Reloading $file..."
fi
source "$file"
return 0
fi
@@ -314,13 +342,31 @@ reload-zsh() {
bench() {
if [[ $# -eq 0 ]]; then
echo_red "Usage: bench <command>"
echo_red "Usage: bench [-v] <command>"
return 1
fi
verbose=0
while [[ $# -gt 1 ]]; do
case $1 in
-v)
verbose=1
;;
esac
shift
done
command=$1
shift
echo "Benchmarking $command..."
/usr/bin/time -v $command $@
bin="/usr/bin/time"
flags=''
if [[ $verbose -eq 1 ]]; then
flags='-h -l'
fi
# TODO implement
# xargs $bin $flags $command $@
/usr/bin/time -h -l $command $@
}
strjoin() {