Files
dotfiles/config/functions
Ismo Vuorinen e5d6cb37fd shell: have, path_(append|prepend|remove)
- have: command -v shorthand
- path_append: appends dir to PATH
- path_prepend: prepends dir to PATH
- path_remove: removes dir from PATH
2023-04-14 00:42:08 +03:00

96 lines
2.1 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
function weather
{
# https://github.com/chubin/wttr.in#usage
local city="${1:-Tampere}"
curl "http://wttr.in/${city// /+}?2nFQM&lang=fi"
}
# Docker
function ssh-docker
{
docker exec -it "$@" bash
}
# Create a new directory and enter it
function mkd
{
mkdir -p "$@" && cd "$@" || exit
}
# All the dig info
function digga
{
dig +nocmd "$1" any +multiline +noall +answer
}
# Rector project to php version 8.0 by default.
function rector
{
local php="${1:-80}"
docker run -v "$(pwd)":/project rector/rector:latest process \
"/project/$1" \
--set "php${php}" \
--autoload-file /project/vendor/autoload.php
}
# Commit everything
function commit
{
commitMessage="$*"
if [ "$commitMessage" = "" ]; then
commitMessage="Automated commit"
fi
git add .
eval "git commit -a -m '${commitMessage}'"
}
function scheduler
{
while :; do
php artisan schedule:run
echo "Sleeping 60 seconds..."
sleep 60
done
}
function silent
{
"$@" >&/dev/null
}
# Defines default antigen bundles
function 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 Sparragus/zsh-auto-nvm-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 git && antigen bundle git
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 php && antigen bundle php
have python && antigen bundle MichaelAquilina/zsh-autoswitch-virtualenv
have rvm && antigen bundle unixorn/rvm-plugin
}