mirror of
https://github.com/ivuorinen/dotfiles.git
synced 2026-01-26 11:14:08 +00:00
108 lines
2.2 KiB
Bash
Executable File
108 lines
2.2 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
#
|
|
# shell functions
|
|
#
|
|
# shellcheck source="../scripts/shared.sh"
|
|
source "$DOTFILES/scripts/shared.sh"
|
|
|
|
# Weather in Tampere, or other city
|
|
weather()
|
|
{
|
|
# https://github.com/chubin/wttr.in#usage
|
|
local city="${1:-Tampere}"
|
|
curl "http://wttr.in/${city// /+}?2nFQM&lang=fi"
|
|
}
|
|
|
|
# Docker
|
|
ssh-docker()
|
|
{
|
|
docker exec -it "$@" bash
|
|
}
|
|
|
|
# Create a new directory and enter it
|
|
mkd()
|
|
{
|
|
mkdir -p "$@" && cd "$@" || exit
|
|
}
|
|
|
|
# All the dig info
|
|
digga()
|
|
{
|
|
dig +nocmd "$1" any +multiline +noall +answer
|
|
}
|
|
|
|
# Rector project to php version 8.2 by default.
|
|
rector()
|
|
{
|
|
local php="${1:-82}"
|
|
docker run -v "$(pwd)":/project rector/rector:latest process \
|
|
"/project/$1" \
|
|
--set "php${php}" \
|
|
--autoload-file /project/vendor/autoload.php
|
|
}
|
|
|
|
# Commit everything
|
|
commit()
|
|
{
|
|
commitMessage="$*"
|
|
|
|
if [ "$commitMessage" = "" ]; then
|
|
commitMessage="Automated commit"
|
|
fi
|
|
|
|
git add .
|
|
eval "git commit -a -m '${commitMessage}'"
|
|
}
|
|
|
|
scheduler()
|
|
{
|
|
while :; do
|
|
php artisan schedule:run
|
|
echo "Sleeping 60 seconds..."
|
|
sleep 60
|
|
done
|
|
}
|
|
|
|
silent()
|
|
{
|
|
"$@" >&/dev/null
|
|
}
|
|
|
|
ask()
|
|
{
|
|
while true; do
|
|
read -p "$1 ([y]/n) " -r
|
|
REPLY=${REPLY:-"y"}
|
|
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
|
return 1
|
|
elif [[ $REPLY =~ ^[Nn]$ ]]; then
|
|
return 0
|
|
fi
|
|
done
|
|
}
|
|
|
|
# Defines default antigen bundles
|
|
x-default-antigen-bundles()
|
|
{
|
|
# these should be always available
|
|
antigen bundle colored-man-pages
|
|
antigen bundle command-not-found
|
|
antigen bundle ssh-agent
|
|
antigen bundle MichaelAquilina/zsh-you-should-use
|
|
antigen bundle jreese/zsh-titles
|
|
antigen bundle unixorn/autoupdate-antigen.zshplugin
|
|
antigen bundle zsh-users/zsh-completions
|
|
antigen bundle zsh-users/zsh-syntax-highlighting
|
|
|
|
# these should be available if there's need
|
|
have brew && antigen bundle brew
|
|
have docker && antigen bundle docker
|
|
have docker-compose && antigen bundle sroze/docker-compose-zsh-plugin
|
|
have jq && antigen bundle reegnz/jq-zsh-plugin
|
|
have nvm && antigen bundle nvm
|
|
have nvm && antigen bundle "$DOTFILES/config/zsh/plugins/nvm-auto-use"
|
|
have php && antigen bundle php
|
|
have python && antigen bundle MichaelAquilina/zsh-autoswitch-virtualenv
|
|
have rvm && antigen bundle unixorn/rvm-plugin
|
|
}
|