Compare commits

...

11 Commits

Author SHA1 Message Date
d8292ca033 fmt + brewfile update 2023-04-22 14:57:27 +03:00
e929b85669 brew: fzf 2023-04-22 14:56:34 +03:00
775d2abf13 tools: cheat configs & dirs 2023-04-22 11:17:36 +03:00
740ad17207 Tool: cheat, yamllint configs 2023-04-21 01:45:43 +03:00
c9d0284c91 dfm: Install command improvements 2023-04-18 07:44:01 +03:00
ac8b7beb9b scripts: x-hr & x-welxome-banner 2023-04-17 23:16:33 +03:00
2fa6c69e4a Submodule updates 2023-04-17 09:05:33 +03:00
c1287c4ea8 dfm: menu rework, docs. codestyle fixes. 2023-04-14 10:10:32 +03:00
7b63afd4f5 dfm: Fix imagick installation 2023-04-14 00:48:37 +03:00
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
4492c386b6 dfm: rewrote the usage menu generation 2023-04-14 00:01:58 +03:00
33 changed files with 649 additions and 211 deletions

View File

@@ -8,24 +8,6 @@ indent_style = space
insert_final_newline = true insert_final_newline = true
trim_trailing_whitespace = true trim_trailing_whitespace = true
[*.lua] [.git{ignore,modules}]
insert_final_newline = true indent_style = tab
indent_size = 1
[*.yaml]
indent_size = 2
insert_final_newline = true
[*.yml]
indent_size = 2
insert_final_newline = true
[*.sh]
indent_size = 2
indent_style = space
insert_final_newline = true
shell_variant = bash # --language-variant
binary_next_line = true
switch_case_indent = true # --case-indent
space_redirects = false
keep_padding = false
function_next_line = true # --func-next-line

2
.gitignore vendored
View File

@@ -1,6 +1,6 @@
Brewfile.lock.json Brewfile.lock.json
*.log *.log
*-secret *-secret
*cache
.idea .idea
.vscode .vscode

7
.gitmodules vendored
View File

@@ -1,3 +1,4 @@
# vim: set expandtab:
[submodule "dotbot"] [submodule "dotbot"]
path = dotbot path = dotbot
url = https://github.com/anishathalye/dotbot.git url = https://github.com/anishathalye/dotbot.git
@@ -26,3 +27,9 @@
update = rebase update = rebase
branch = main branch = main
ignore = dirty ignore = dirty
[submodule "cheat-community"]
path = config/cheat/cheatsheets/community
url = https://github.com/cheat/cheatsheets.git
ignore = dirty

2
.yamlignore Normal file
View File

@@ -0,0 +1,2 @@
# .yamlignore

View File

@@ -69,10 +69,14 @@ brew "eg-examples"
brew "faas-cli" brew "faas-cli"
# Simple, fast and user-friendly alternative to find # Simple, fast and user-friendly alternative to find
brew "fd" brew "fd"
# Banner-like program prints strings as ASCII art
brew "figlet"
# Libraries to talk to Microsoft SQL Server and Sybase databases # Libraries to talk to Microsoft SQL Server and Sybase databases
brew "freetds" brew "freetds"
# Monitor a directory for changes and run a shell command # Monitor a directory for changes and run a shell command
brew "fswatch" brew "fswatch"
# Command-line fuzzy finder written in Go
brew "fzf"
# Disk usage analyzer with console interface written in Go # Disk usage analyzer with console interface written in Go
brew "gdu", link: false brew "gdu", link: false
# GitHub command-line tool # GitHub command-line tool
@@ -129,6 +133,8 @@ brew "lazydocker"
brew "libpq" brew "libpq"
# Linguistic software and Finnish dictionary # Linguistic software and Finnish dictionary
brew "libvoikko" brew "libvoikko"
# Rainbows and unicorns in your console!
brew "lolcat"
# Package manager for the Lua programming language # Package manager for the Lua programming language
brew "luarocks" brew "luarocks"
# Swiss Army Knife for macOS # Swiss Army Knife for macOS
@@ -155,6 +161,8 @@ brew "pandoc"
brew "perl" brew "perl"
# General-purpose scripting language # General-purpose scripting language
brew "php@8.1" brew "php@8.1"
# Simple Python style checker in one Python file
brew "pycodestyle"
# Python version management # Python version management
brew "pyenv" brew "pyenv"
# Migrate pip packages from one Python version to another # Migrate pip packages from one Python version to another
@@ -213,6 +221,8 @@ brew "watch"
brew "wget" brew "wget"
# Personal information dashboard for your terminal # Personal information dashboard for your terminal
brew "wtfutil" brew "wtfutil"
# Check your $HOME for unwanted files and directories
brew "xdg-ninja"
# JavaScript package manager # JavaScript package manager
brew "yarn" brew "yarn"
# A vulnerability scanner for container images and filesystems # A vulnerability scanner for container images and filesystems
@@ -291,6 +301,8 @@ cask "quicklook-json"
cask "quicklookase" cask "quicklookase"
# Automatically hides or quits apps after periods of inactivity # Automatically hides or quits apps after periods of inactivity
cask "quitter" cask "quitter"
# Control your tools with a few keystrokes
cask "raycast"
# Move and resize windows using keyboard shortcuts or snap areas # Move and resize windows using keyboard shortcuts or snap areas
cask "rectangle" cask "rectangle"
# MySQL/MariaDB database management # MySQL/MariaDB database management

1
add-submodules.sh Normal file → Executable file
View File

@@ -2,3 +2,4 @@
git submodule add --name dotbot-brew -f https://github.com/wren/dotbot-brew.git dotbot-brew git submodule add --name dotbot-brew -f https://github.com/wren/dotbot-brew.git dotbot-brew
git submodule add --name dotbot-include -f https://gitlab.com/gnfzdz/dotbot-include.git dotbot-include git submodule add --name dotbot-include -f https://gitlab.com/gnfzdz/dotbot-include.git dotbot-include
git submodule add --name cheat-community -f https://github.com/cheat/cheatsheets.git config/cheat/cheatsheets/community

View File

@@ -6,6 +6,8 @@ colors
# Defaults # Defaults
export DOTFILES="$HOME/.dotfiles" export DOTFILES="$HOME/.dotfiles"
# shellcheck source=shared.sh
source "$DOTFILES/scripts/shared.sh"
# Run x-load-configs in your terminal to reload the files. # Run x-load-configs in your terminal to reload the files.
function x-load-configs() function x-load-configs()
@@ -28,14 +30,14 @@ ANTIGEN_ZSH_PATH="$XDG_BIN_HOME/antigen.zsh"
[[ -f "$ANTIGEN_ZSH_PATH" ]] && source "$ANTIGEN_ZSH_PATH" [[ -f "$ANTIGEN_ZSH_PATH" ]] && source "$ANTIGEN_ZSH_PATH"
# antigen is present # antigen is present
if command -v antigen &> /dev/null; then have antigen && {
antigen use oh-my-zsh antigen use oh-my-zsh
# config/functions # config/functions
x-default-antigen-bundles x-default-antigen-bundles
antigen apply antigen apply
fi }
eval "$(starship init zsh)"
# starship is present
have starship && eval "$(starship init zsh)"

View File

@@ -1,9 +1,11 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# shellcheck source="../scripts/shared.sh"
source "$DOTFILES/scripts/shared.sh"
# Get installed php versions from brew and setup aliases # Get installed php versions from brew and setup aliases
function x-set-php-aliases function x-set-php-aliases
{ {
if command -v brew &> /dev/null; then have brew && {
local php_versions=() local php_versions=()
while IFS="" read -r line; do php_versions+=("$line"); done < <(brew list | grep '^php') while IFS="" read -r line; do php_versions+=("$line"); done < <(brew list | grep '^php')
@@ -31,7 +33,7 @@ function x-set-php-aliases
# shellcheck disable=SC2139,SC2140 # shellcheck disable=SC2139,SC2140
alias "${php_alias}c"="$php_exec $php_error_reporting $(which composer)" alias "${php_alias}c"="$php_exec $php_error_reporting $(which composer)"
done done
fi }
} }
if [[ $(uname) == 'Darwin' ]]; then if [[ $(uname) == 'Darwin' ]]; then
@@ -74,10 +76,8 @@ alias code_scanner='docker run
alias zedit='$EDITOR ~/.dotfiles' alias zedit='$EDITOR ~/.dotfiles'
if hash irssi 2> /dev/null; then have irssi \
# shellcheck disable=2139 && alias irssi="irssi --config='$IRSSI_CONFIG_FILE' --home='$IRSSI_CONFIG_HOME'"
alias irssi="irssi --config='$IRSSI_CONFIG_FILE' --home='$IRSSI_CONFIG_HOME'"
fi
if [[ -f "$HOME/.aliases.local" ]]; then if [[ -f "$HOME/.aliases.local" ]]; then
# shellcheck disable=SC1091 # shellcheck disable=SC1091

84
config/cheat/conf.yml Normal file
View File

@@ -0,0 +1,84 @@
---
# The editor to use with 'cheat -e <sheet>'. Defaults to $EDITOR or $VISUAL.
editor: $EDITOR
# Should 'cheat' always colorize output?
colorize: true
# Which 'chroma' colorscheme should be applied to the output?
# Options are available here:
# https://github.com/alecthomas/chroma/tree/master/styles
style: monokai
# Which 'chroma' "formatter" should be applied?
# One of: "terminal", "terminal256", "terminal16m"
formatter: terminal256
# Through which pager should output be piped?
# 'less -FRX' is recommended on Unix systems
# 'more' is recommended on Windows
pager: less -FRX
# Cheatpaths are paths at which cheatsheets are available on your local
# filesystem.
#
# It is useful to sort cheatsheets into different cheatpaths for organizational
# purposes. For example, you might want one cheatpath for community
# cheatsheets, one for personal cheatsheets, one for cheatsheets pertaining to
# your day job, one for code snippets, etc.
#
# Cheatpaths are scoped, such that more "local" cheatpaths take priority over
# more "global" cheatpaths. (The most global cheatpath is listed first in this
# file; the most local is listed last.) For example, if there is a 'tar'
# cheatsheet on both global and local paths, you'll be presented with the local
# one by default. ('cheat -p' can be used to view cheatsheets from alternative
# cheatpaths.)
#
# Cheatpaths can also be tagged as "read only". This instructs cheat not to
# automatically create cheatsheets on a read-only cheatpath. Instead, when you
# would like to edit a read-only cheatsheet using 'cheat -e', cheat will
# perform a copy-on-write of that cheatsheet from a read-only cheatpath to a
# writeable cheatpath.
#
# This is very useful when you would like to maintain, for example, a
# "pristine" repository of community cheatsheets on one cheatpath, and an
# editable personal reponsity of cheatsheets on another cheatpath.
#
# Cheatpaths can be also configured to automatically apply tags to cheatsheets
# on certain paths, which can be useful for querying purposes.
# Example: 'cheat -t work jenkins'.
#
# Community cheatsheets must be installed separately, though you may have
# downloaded them automatically when installing 'cheat'. If not, you may
# download them here:
#
# https://github.com/cheat/cheatsheets
cheatpaths:
# Cheatpath properties mean the following:
# 'name': the name of the cheatpath
# (view with 'cheat -d', filter with 'cheat -p')
# 'path': the filesystem path of the cheatsheet directory
# (view with 'cheat -d')
# 'tags': tags that should be automatically applied to sheets on this path
# 'readonly': shall user-created ('cheat -e') cheatsheets be saved here?
- name: community
path: ~/.config/cheat/cheatsheets/community
tags: [ community ]
readonly: true
# If you have personalized cheatsheets, list them last. They will take
# precedence over the more global cheatsheets.
- name: personal
path: ~/.config/cheat/cheatsheets/personal
tags: [ personal ]
readonly: false
# While it requires no configuration here, it's also worth noting that
# cheat will automatically append directories named '.cheat' within the
# current working directory to the 'cheatpath'. This can be very useful if
# you'd like to closely associate cheatsheets with, for example, a directory
# containing source code.
#
# Such "directory-scoped" cheatsheets will be treated as the most "local"
# cheatsheets, and will override less "local" cheatsheets. Similarly,
# directory-scoped cheatsheets will always be editable ('readonly: false').

View File

@@ -3,7 +3,8 @@
# vim: filetype=zsh # vim: filetype=zsh
export DOTFILES="$HOME/.dotfiles" export DOTFILES="$HOME/.dotfiles"
export PATH="$DOTFILES/local/bin:$PATH" source "$DOTFILES/scripts/shared.sh"
path_append "$DOTFILES/local/bin"
# Explicitly set XDG folders # Explicitly set XDG folders
# https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html # https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
@@ -23,21 +24,20 @@ export HOMEBREW_SBIN="$HOMEBREW/sbin"
export HOMEBREW_PKG="$HOMEBREW/opt" export HOMEBREW_PKG="$HOMEBREW/opt"
export HOMEBREW_NO_ENV_HINTS=1 export HOMEBREW_NO_ENV_HINTS=1
export PATH="$XDG_BIN_HOME:$HOMEBREW_BIN:$HOMEBREW_SBIN:/usr/local/sbin:$PATH" path_append "/usr/local/bin"
path_append "$HOMEBREW_SBIN"
path_append "$HOMEBREW_BIN"
path_append "$XDG_BIN_HOME"
# brew, https://brew.sh # brew, https://brew.sh
if command -v brew &> /dev/null; then have brew && {
BREW_PYTHON=$(brew --prefix python)/bin path_append "$(brew --prefix python)/bin"
GNUBIN_DIR=$(brew --prefix coreutils)/libexec/gnubin path_append "$(brew --prefix coreutils)/libexec/gnubin"
BREW_RUBY=$(brew --prefix ruby)/bin path_append "$(brew --prefix ruby)/bin"
BREW_GEMS=$(gem environment gemdir)/bin path_append "$(gem environment gemdir)/bin"
}
export PATH="$BREW_PYTHON:$GNUBIN_DIR:$BREW_GEMS:$BREW_RUBY:$PATH"
fi
source "$DOTFILES/config/exports-shell" source "$DOTFILES/config/exports-shell"
source "$DOTFILES/config/exports-apps" source "$DOTFILES/config/exports-apps"
if command -v nvim &> /dev/null; then have nvim && export EDITOR="nvim"
export EDITOR="nvim"
fi

View File

@@ -2,6 +2,7 @@
# shellcheck shell=bash # shellcheck shell=bash
# shellcheck enable=external-sources # shellcheck enable=external-sources
# vim: filetype=zsh # vim: filetype=zsh
source "$DOTFILES/scripts/shared.sh"
# Antigen configuration # Antigen configuration
# https://github.com/zsh-users/antigen/wiki/Configuration # https://github.com/zsh-users/antigen/wiki/Configuration
@@ -11,61 +12,62 @@ export ANTIGEN_PLUGIN_RECEIPT_F=".local/share/antigen/antigen_plugin_lastupdate"
# Ansible configuration # Ansible configuration
# https://docs.ansible.com/ansible/latest/reference_appendices/config.html # https://docs.ansible.com/ansible/latest/reference_appendices/config.html
if hash ansible 2> /dev/null; then have ansible && {
export ANSIBLE_HOME="$XDG_CONFIG_HOME/ansible" export ANSIBLE_HOME="$XDG_CONFIG_HOME/ansible"
export ANSIBLE_CONFIG="$XDG_CONFIG_HOME/ansible.cfg" export ANSIBLE_CONFIG="$XDG_CONFIG_HOME/ansible.cfg"
export ANSIBLE_GALAXY_CACHE_DIR="$XDG_CACHE_HOME/ansible/galaxy_cache" export ANSIBLE_GALAXY_CACHE_DIR="$XDG_CACHE_HOME/ansible/galaxy_cache"
x-dc "$ANSIBLE_HOME" x-dc "$ANSIBLE_HOME"
x-dc "$ANSIBLE_GALAXY_CACHE_DIR" x-dc "$ANSIBLE_GALAXY_CACHE_DIR"
fi }
# composer, https://getcomposer.org/ # composer, https://getcomposer.org/
if command -v composer &> /dev/null; then have composer && {
export COMPOSER_HOME="$XDG_STATE_HOME/composer" export COMPOSER_HOME="$XDG_STATE_HOME/composer"
export COMPOSER_BIN="$COMPOSER_HOME/vendor/bin" export COMPOSER_BIN="$COMPOSER_HOME/vendor/bin"
export PATH="$COMPOSER_BIN:$PATH" export PATH="$COMPOSER_BIN:$PATH"
fi }
# docker, https://docs.docker.com/engine/reference/commandline/cli/ # docker, https://docs.docker.com/engine/reference/commandline/cli/
if command -v docker &> /dev/null; then have docker && {
export DOCKER_CONFIG="$XDG_CONFIG_HOME/docker" export DOCKER_CONFIG="$XDG_CONFIG_HOME/docker"
x-dc "$DOCKER_CONFIG" x-dc "$DOCKER_CONFIG"
fi }
# ffmpeg # ffmpeg
if hash ffmpeg 2> /dev/null; then have ffmpeg && {
export FFMPEG_DATADIR="$XDG_CONFIG_HOME/ffmpeg" export FFMPEG_DATADIR="$XDG_CONFIG_HOME/ffmpeg"
x-dc "$FFMPEG_DATADIR" x-dc "$FFMPEG_DATADIR"
fi }
# gcloud # gcloud
if hash gcloud 2> /dev/null; then have gcloud && {
GCLOUD_LOC=$(gcloud info --format="value(installation.sdk_root)" --quiet) GCLOUD_LOC=$(gcloud info --format="value(installation.sdk_root)" --quiet)
[[ -f "$GCLOUD_LOC/path.zsh.inc" ]] && builtin source "$GCLOUD_LOC/path.zsh.inc" [[ -f "$GCLOUD_LOC/path.zsh.inc" ]] && builtin source "$GCLOUD_LOC/path.zsh.inc"
[[ -f "$GCLOUD_LOC/completion.zsh.inc" ]] && builtin source "$GCLOUD_LOC/completion.zsh.inc" [[ -f "$GCLOUD_LOC/completion.zsh.inc" ]] && builtin source "$GCLOUD_LOC/completion.zsh.inc"
fi }
# gem, rubygems # gem, rubygems
if command -v gem &> /dev/null; then have gem && {
export GEM_HOME="$XDG_STATE_HOME/gem" export GEM_HOME="$XDG_STATE_HOME/gem"
export GEM_PATH="$XDG_STATE_HOME/gem" export GEM_PATH="$XDG_STATE_HOME/gem"
export PATH="$GEM_HOME/bin:$PATH" export PATH="$GEM_HOME/bin:$PATH"
fi path_append "$GEM_PATH/bin"
}
# If we have go packages, include them to the PATH # If we have go packages, include them to the PATH
if command -v go &> /dev/null; then have go && {
export GOPATH="$XDG_DATA_HOME/go" export GOPATH="$XDG_DATA_HOME/go"
export GOBIN="$XDG_BIN_HOME" export GOBIN="$XDG_BIN_HOME"
x-dc "$GOPATH" x-dc "$GOPATH"
fi }
# irssi # irssi
if hash irssi 2> /dev/null; then have irssi && {
# These variables are used in ./alias with --config and --home # These variables are used in ./alias with --config and --home
export IRSSI_CONFIG_HOME="$XDG_CONFIG_HOME/irssi" export IRSSI_CONFIG_HOME="$XDG_CONFIG_HOME/irssi"
export IRSSI_CONFIG_FILE="$IRSSI_CONFIG_HOME/config" export IRSSI_CONFIG_FILE="$IRSSI_CONFIG_HOME/config"
x-dc "$IRSSI_CONFIG_HOME" x-dc "$IRSSI_CONFIG_HOME"
fi }
# nvm, the node version manager # nvm, the node version manager
export NVM_LAZY_LOAD=true export NVM_LAZY_LOAD=true
@@ -76,21 +78,21 @@ export NVM_DIR="$XDG_CONFIG_HOME/nvm"
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
# op (1Password cli) is present # op (1Password cli) is present
if hash op 2> /dev/null; then have op && {
export OP_CACHE="$XDG_STATE_HOME/1password" export OP_CACHE="$XDG_STATE_HOME/1password"
x-dc "$OP_CACHE" x-dc "$OP_CACHE"
eval "$(op completion zsh)" eval "$(op completion zsh)"
compdef _op op compdef _op op
fi }
# pyenv, python environments # pyenv, python environments
if command -v pyenv &> /dev/null; then have pyenv && {
export PYENV_ROOT="$XDG_STATE_HOME/pyenv" export PYENV_ROOT="$XDG_STATE_HOME/pyenv"
x-dc "$PYENV_ROOT" x-dc "$PYENV_ROOT"
export PATH="$PYENV_ROOT/bin:$PATH" path_append "$PYENV_ROOT/bin"
eval "$(pyenv init -)" eval "$(pyenv init -)"
fi }
# wakatime, https://github.com/wakatime/wakatime-cli # wakatime, https://github.com/wakatime/wakatime-cli
export WAKATIME_HOME="$XDG_STATE_HOME/wakatime" export WAKATIME_HOME="$XDG_STATE_HOME/wakatime"
@@ -104,4 +106,3 @@ export _Z_DATA="$XDG_STATE_HOME/z"
export ANDROID_HOME="$XDG_DATA_HOME/android" export ANDROID_HOME="$XDG_DATA_HOME/android"
export GNUPGHOME="$XDG_DATA_HOME/gnupg" export GNUPGHOME="$XDG_DATA_HOME/gnupg"
export SCREENRC="$XDG_CONFIG_HOME/misc/screenrc" export SCREENRC="$XDG_CONFIG_HOME/misc/screenrc"

View File

@@ -1,6 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# shellcheck shell=bash # shellcheck shell=bash
# vim: filetype=zsh # vim: filetype=zsh
source "$DOTFILES/scripts/shared.sh"
export LC_ALL=fi_FI.utf8 export LC_ALL=fi_FI.utf8
@@ -39,10 +40,7 @@ hash shopt 2> /dev/null && shopt -s checkwinsize
&& source "$XDG_BIN_HOME/iterm2_shell_integration.zsh" && source "$XDG_BIN_HOME/iterm2_shell_integration.zsh"
# Set dircolors based on the file, if it exists # Set dircolors based on the file, if it exists
if command -v dircolors &> /dev/null; then have dircolors && eval $(dircolors "$XDG_CONFIG_HOME/dircolors")
# shellcheck disable=SC2046
eval $(dircolors "$XDG_CONFIG_HOME/dircolors")
fi
# If we are using zsh, color our dir lists and such # If we are using zsh, color our dir lists and such
if [ "$SHELL" = "$(which zsh)" ]; then if [ "$SHELL" = "$(which zsh)" ]; then
@@ -51,5 +49,14 @@ if [ "$SHELL" = "$(which zsh)" ]; then
export HISTFILE="$XDG_STATE_HOME/zsh/history" export HISTFILE="$XDG_STATE_HOME/zsh/history"
zstyle ':completion:*' cache-path "$XDG_CACHE_HOME/zsh/zcompcache" zstyle ':completion:*' cache-path "$XDG_CACHE_HOME/zsh/zcompcache"
zstyle ':completion:*' list-colors "$LS_COLORS" zstyle ':completion:*' list-colors "$LS_COLORS"
# fzf
[ -f "${XDG_CONFIG_HOME:-$HOME/.config}"/fzf/fzf.zsh ] \
&& source "${XDG_CONFIG_HOME:-$HOME/.config}"/fzf/fzf.zsh
fi fi
# If we are using bash
if [ "$SHELL" = "$(which bash)" ]; then
[ -f "${XDG_CONFIG_HOME:-$HOME/.config}"/fzf/fzf.bash ] \
&& source "${XDG_CONFIG_HOME:-$HOME/.config}"/fzf/fzf.bash
fi

View File

@@ -2,9 +2,11 @@
# #
# shell functions # shell functions
# #
# shellcheck source="../scripts/shared.sh"
source "$DOTFILES/scripts/shared.sh"
# Weather in Tampere, or other city # Weather in Tampere, or other city
function weather weather()
{ {
# https://github.com/chubin/wttr.in#usage # https://github.com/chubin/wttr.in#usage
local city="${1:-Tampere}" local city="${1:-Tampere}"
@@ -12,25 +14,25 @@ function weather
} }
# Docker # Docker
function ssh-docker ssh-docker()
{ {
docker exec -it "$@" bash docker exec -it "$@" bash
} }
# Create a new directory and enter it # Create a new directory and enter it
function mkd mkd()
{ {
mkdir -p "$@" && cd "$@" || exit mkdir -p "$@" && cd "$@" || exit
} }
# All the dig info # All the dig info
function digga digga()
{ {
dig +nocmd "$1" any +multiline +noall +answer dig +nocmd "$1" any +multiline +noall +answer
} }
# Rector project to php version 8.0 by default. # Rector project to php version 8.0 by default.
function rector rector()
{ {
local php="${1:-80}" local php="${1:-80}"
docker run -v "$(pwd)":/project rector/rector:latest process \ docker run -v "$(pwd)":/project rector/rector:latest process \
@@ -40,7 +42,7 @@ function rector
} }
# Commit everything # Commit everything
function commit commit()
{ {
commitMessage="$*" commitMessage="$*"
@@ -52,7 +54,7 @@ function commit
eval "git commit -a -m '${commitMessage}'" eval "git commit -a -m '${commitMessage}'"
} }
function scheduler scheduler()
{ {
while :; do while :; do
php artisan schedule:run php artisan schedule:run
@@ -61,36 +63,26 @@ function scheduler
done done
} }
function silent silent()
{ {
"$@" >&/dev/null "$@" >&/dev/null
} }
# Remove directory from the PATH variable ask()
# usage: path_remove ~/.local/bin
function path_remove
{ {
PATH=$(echo -n "$PATH" | awk -v RS=: -v ORS=: "\$0 != \"$1\"" | sed 's/:$//') while true; do
} read -p "$1 ([y]/n) " -r
REPLY=${REPLY:-"y"}
# Append directory to the PATH if [[ $REPLY =~ ^[Yy]$ ]]; then
# usage: path_append ~/.local/bin return 1
function path_append elif [[ $REPLY =~ ^[Nn]$ ]]; then
{ return 0
path_remove "$1" fi
PATH="${PATH:+"$PATH:"}$1" done
}
# Prepend directory to the PATH
# usage: path_prepend ~/.local/bin
function path_prepend
{
path_remove "$1"
PATH="$1${PATH:+":$PATH"}"
} }
# Defines default antigen bundles # Defines default antigen bundles
function x-default-antigen-bundles x-default-antigen-bundles()
{ {
# these should be always available # these should be always available
antigen bundle colored-man-pages antigen bundle colored-man-pages
@@ -104,13 +96,12 @@ function x-default-antigen-bundles
antigen bundle zsh-users/zsh-syntax-highlighting antigen bundle zsh-users/zsh-syntax-highlighting
# these should be available if there's need # these should be available if there's need
hash git 2> /dev/null && antigen bundle git have brew && antigen bundle brew
hash brew 2> /dev/null && antigen bundle brew have docker && antigen bundle docker
hash docker 2> /dev/null && antigen bundle docker have docker-compose && antigen bundle sroze/docker-compose-zsh-plugin
hash docker-compose 2> /dev/null && antigen bundle sroze/docker-compose-zsh-plugin have jq && antigen bundle reegnz/jq-zsh-plugin
hash jq 2> /dev/null && antigen bundle reegnz/jq-zsh-plugin have nvm && antigen bundle nvm
hash nvm 2> /dev/null && antigen bundle nvm have php && antigen bundle php
hash php 2> /dev/null && antigen bundle php have python && antigen bundle MichaelAquilina/zsh-autoswitch-virtualenv
hash python 2> /dev/null && antigen bundle MichaelAquilina/zsh-autoswitch-virtualenv have rvm && antigen bundle unixorn/rvm-plugin
hash rvm 2> /dev/null && antigen bundle unixorn/rvm-plugin
} }

13
config/fzf/fzf.bash Normal file
View File

@@ -0,0 +1,13 @@
# Setup fzf
# ---------
if [[ ! "$PATH" == */opt/homebrew/opt/fzf/bin* ]]; then
PATH="${PATH:+${PATH}:}/opt/homebrew/opt/fzf/bin"
fi
# Auto-completion
# ---------------
[[ $- == *i* ]] && source "/opt/homebrew/opt/fzf/shell/completion.bash" 2> /dev/null
# Key bindings
# ------------
source "/opt/homebrew/opt/fzf/shell/key-bindings.bash"

13
config/fzf/fzf.zsh Normal file
View File

@@ -0,0 +1,13 @@
# Setup fzf
# ---------
if [[ ! "$PATH" == */opt/homebrew/opt/fzf/bin* ]]; then
PATH="${PATH:+${PATH}:}/opt/homebrew/opt/fzf/bin"
fi
# Auto-completion
# ---------------
[[ $- == *i* ]] && source "/opt/homebrew/opt/fzf/shell/completion.zsh" 2> /dev/null
# Key bindings
# ------------
source "/opt/homebrew/opt/fzf/shell/key-bindings.zsh"

32
config/yamllint/config Normal file
View File

@@ -0,0 +1,32 @@
---
extends: default
ignore-from-file: [.gitignore, .yamlignore]
rules:
braces:
level: warning
max-spaces-inside: 1
brackets:
level: warning
max-spaces-inside: 1
colons:
level: warning
commas:
level: warning
comments: disable
comments-indentation: disable
document-start: disable
empty-lines:
level: warning
hyphens:
level: warning
indentation:
level: warning
indent-sequences: consistent
line-length:
level: warning
allow-non-breakable-inline-mappings: true
max: 120
truthy: disable

View File

@@ -9,6 +9,7 @@
# Helper variables, override with ENVs like `VERBOSE=1 dfm help` # Helper variables, override with ENVs like `VERBOSE=1 dfm help`
: "${VERBOSE:=0}" : "${VERBOSE:=0}"
: "${DOTFILES:=$HOME/.dotfiles}" : "${DOTFILES:=$HOME/.dotfiles}"
: "${SHARED_SCRIPT:=$DOTFILES/scripts/shared.sh}"
: "${INSTALL_SCRIPT:=$DOTFILES/scripts/install-dotfiles.sh}" : "${INSTALL_SCRIPT:=$DOTFILES/scripts/install-dotfiles.sh}"
: "${BREWFILE:=$DOTFILES/Brewfile}" : "${BREWFILE:=$DOTFILES/Brewfile}"
: "${HOSTFILES:=$DOTFILES/hosts}" : "${HOSTFILES:=$DOTFILES/hosts}"
@@ -18,11 +19,27 @@ SCRIPT=$(basename "$0")
VERSION_NVM="v0.39.3" VERSION_NVM="v0.39.3"
# shellcheck source=./../../scripts/shared.sh # shellcheck source=./../../scripts/shared.sh
source "$DOTFILES/scripts/shared.sh" source "$SHARED_SCRIPT"
function section_install function section_install
{ {
USAGE_PREFIX="$SCRIPT install" USAGE_PREFIX="$SCRIPT install <command>"
MENU=(
"all:Installs everything in the correct order"
"antigen:Updates the antigen.zsh file"
"composer:Install composer"
"dotenv:Install dotenv-linter"
"gh:Install GitHub CLI Extensions"
"go:Install Go Packages"
"imagick:Install ImageMagick CLI"
"starship:Install starship.rs"
"macos:Setup nice macOS defaults"
"nvm:Install Node Version Manager (nvm)"
"npm:Install NPM Packages"
"ntfy:Install ntfy"
"z:Install z"
)
case "$1" in case "$1" in
all) all)
@@ -42,115 +59,111 @@ function section_install
;; ;;
antigen) antigen)
curl -L git.io/antigen > "$DOTFILES/local/bin/antigen.zsh" \ curl -L git.io/antigen > "$DOTFILES/local/bin/antigen.zsh" \
&& msg_done "🎉 New antigen installed!" && msg_yay "New antigen installed!"
;; ;;
composer) composer)
bash "$DOTFILES/scripts/install-composer.sh" \ bash "$DOTFILES/scripts/install-composer.sh" \
&& msg_done "🎉 composer installed!" && msg_yay "composer installed!"
;; ;;
dotenv) dotenv)
curl -sSfL \ curl -sSfL \
https://raw.githubusercontent.com/dotenv-linter/dotenv-linter/master/install.sh \ https://raw.githubusercontent.com/dotenv-linter/dotenv-linter/master/install.sh \
| sh -s -- -b "$XDG_BIN_HOME" \ | sh -s -- -b "$XDG_BIN_HOME" \
&& msg_done "🎉 dotenv-linter installed!" && msg_yay "dotenv-linter installed!"
;; ;;
gh) gh)
bash "$DOTFILES/scripts/install-gh-extensions.sh" \ bash "$DOTFILES/scripts/install-gh-extensions.sh" \
&& msg_done "🎉 github cli extensions installed!" && msg_yay "github cli extensions installed!"
;; ;;
go) go)
bash "$DOTFILES/scripts/install-go-packages.sh" \ bash "$DOTFILES/scripts/install-go-packages.sh" \
&& msg_done "🎉 go packages installed!" && msg_yay "go packages installed!"
;; ;;
imagick) imagick)
wget https://imagemagick.org/archive/binaries/magick > "$XDG_BIN_HOME/magick" \ curl -L https://imagemagick.org/archive/binaries/magick > "$XDG_BIN_HOME/magick" \
&& msg_done "🎉 imagick installed!" && msg_yay "imagick installed!"
;; ;;
starship) starship)
curl -sS https://starship.rs/install.sh | sh -s -- --bin-dir ~/.local/bin \ curl -sS https://starship.rs/install.sh | sh -s -- --bin-dir ~/.local/bin \
&& msg_done "🎉 starship installed!" && msg_yay "starship installed!"
;; ;;
macos) macos)
bash "$DOTFILES/scripts/set-macos-defaults.sh" \ bash "$DOTFILES/scripts/set-macos-defaults.sh" \
&& msg_done "🎉 Brewfile defined apps has been installed!" && msg_yay "Brewfile defined apps has been installed!"
;; ;;
nvm) nvm)
curl -o- "https://raw.githubusercontent.com/nvm-sh/nvm/$VERSION_NVM/install.sh" | bash \ curl -o- "https://raw.githubusercontent.com/nvm-sh/nvm/$VERSION_NVM/install.sh" | bash \
&& nvm install --lts --latest-npm --default \ && nvm install --lts --latest-npm --default
&& git checkout "$HOME/.zshrc" \ git checkout "$DOTFILES/base/zshrc"
&& msg_done "🎉 nvm installed!" msg_yay "nvm installed!"
;; ;;
npm) npm)
bash "$DOTFILES/scripts/install-npm-packages.sh" \ bash "$DOTFILES/scripts/install-npm-packages.sh" \
&& msg_done "🎉 NPM Packages have been installed!" && msg_yay "NPM Packages have been installed!"
;; ;;
ntfy) ntfy)
bash "$DOTFILES/scripts/install-ntfy.sh" \ bash "$DOTFILES/scripts/install-ntfy.sh" \
&& msg_done "🎉 ntfy installed!" && msg_yay "ntfy installed!"
;; ;;
z) z)
bash "$DOTFILES/scripts/install-z.sh" \ bash "$DOTFILES/scripts/install-z.sh" \
&& msg_done "🎉 z has been installed!" && msg_yay "z has been installed!"
;; ;;
*) *)
menu_section "$USAGE_PREFIX" "all | antigen | composer | dotenv | gh | go | imagick | starship | macos | nvm | npm" menu_usage "$USAGE_PREFIX" "${MENU[@]}"
menu_item "all" "Installs macos defaults, antigen, starship, brew, nvm, npm packages and others"
menu_item "antigen" "Updates the antigen.zsh file"
menu_item "composer" "Install composer"
menu_item "dotenv" "Install dotenv-linter"
menu_item "gh" "Install GitHub CLI Extensions"
menu_item "go" "Install Go Packages"
menu_item "imagick" "Install ImageMagick CLI"
menu_item "starship" "Install starship.rs"
menu_item "macos" "Setup nice macOS defaults"
menu_item "nvm" "Install Node Version Manager (nvm)"
menu_item "npm" "Install NPM Packages"
menu_item "ntfy" "Install ntfy"
menu_item "z" "Install z"
;; ;;
esac esac
} }
function section_brew function section_brew
{ {
USAGE_PREFIX="$SCRIPT brew" USAGE_PREFIX="$SCRIPT brew <command>"
if ! command -v brew &> /dev/null; then MENU=(
menu_section "$USAGE_PREFIX" "brew not available on this system" "install:Installs items defined in Brewfile"
else "update:Updates and upgrades brew packages"
"updatebundle:Updates Brewfile with descriptions"
"autoupdate:Setups brew auto-update and runs it immediately"
)
have brew && {
case "$1" in case "$1" in
install) install)
brew bundle install --file="$BREWFILE" && msg_done "🎉 Done!" brew bundle install --file="$BREWFILE" && msg_yay "Done!"
;; ;;
update) update)
brew update && brew outdated && brew upgrade && brew cleanup brew update && brew outdated && brew upgrade && brew cleanup
msg_done "🎉 Done!" msg_yay "Done!"
;; ;;
updatebundle) updatebundle)
# Updates .dotfiles/Brewfile with descriptions # Updates .dotfiles/Brewfile with descriptions
brew bundle dump \ brew bundle dump \
--force \ --force \
--file="$BREWFILE" \ --file="$BREWFILE" \
--describe && msg_done "🎉 Done!" --describe && msg_yay "Done!"
;; ;;
autoupdate) autoupdate)
brew autoupdate delete brew autoupdate delete
brew autoupdate start 43200 --upgrade --cleanup --immediate brew autoupdate start 43200 --upgrade --cleanup --immediate
;; ;;
*) *)
menu_section "$USAGE_PREFIX" "install | update | updatebundle | autoupdate" menu_usage "$USAGE_PREFIX" "${MENU[@]}"
menu_item "install" "Installs items defined in Brewfile"
menu_item "update" "Updates and upgrades brew packages"
menu_item "updatebundle" "Updates Brewfile with descriptions"
menu_item "autoupdate" "Setups brew auto-update and runs it immediately"
;; ;;
esac esac
fi } || menu_section "$USAGE_PREFIX" "brew not available on this system"
} }
function section_dotfiles function section_dotfiles
{ {
USAGE_PREFIX="$SCRIPT dotfiles" USAGE_PREFIX="$SCRIPT dotfiles <command>"
MENU=(
"fmt:Run all formatters"
"yamlfmt:Run yamlfmt to all dotfiles, which are in our control"
"shfmt:Run shfmt to all dotfiles"
"reset_all:Reset everything, runs all configured reset actions"
"reset_nvim:Resets nvim. Deletes caches, removes nvim folders and relinks nvim folders"
)
case "$1" in case "$1" in
fmt) fmt)
@@ -171,16 +184,16 @@ function section_dotfiles
~/.config/astronvim \ ~/.config/astronvim \
~/.config/nvim ~/.config/nvim
msg_ok "Deleted old nvim files" msg_ok "Deleted old nvim files"
ln -s ~/.dotfiles/config/astronvim ~/.config/astronvim ln -s $DOTFILES/config/astronvim ~/.config/astronvim
ln -s ~/.dotfiles/config/nvim ~/.config/nvim ln -s $DOTFILES/config/nvim ~/.config/nvim
msg_ok "Linked nvim and astronvim" msg_ok "Linked nvim and astronvim"
hash npm 2> /dev/null && $0 install npm have npm && $0 install npm
msg_ok "Installed packages" msg_ok "Installed packages"
msg_done "nvim reset!" msg_done "nvim reset!"
;; ;;
yamlfmt) yamlfmt)
# format yaml files # format yaml files
yamlfmt -conf "$DOTFILES/.yamlfmt" have yamlfmt && yamlfmt -conf "$DOTFILES/.yamlfmt" || msg_err "yamlfmt not found"
;; ;;
shfmt) shfmt)
# Format shell scripts according to following rules. # Format shell scripts according to following rules.
@@ -197,25 +210,25 @@ function section_dotfiles
--func-next-line --list --write \ --func-next-line --list --write \
--indent 2 --case-indent --space-redirects \ --indent 2 --case-indent --space-redirects \
--binary-next-line {} \; --binary-next-line {} \;
msg_done "🎉 dotfiles have been shfmt formatted!" msg_yay "dotfiles have been shfmt formatted!"
;; ;;
*) *)
menu_section "$USAGE_PREFIX" "fmt | reset_all | reset_nvim | yamlfmt | shfmt" menu_usage "$USAGE_PREFIX" "${MENU[@]}"
menu_item "fmt" "Run all formatters"
menu_item "reset_all" "Reset everything, runs all configured reset actions"
menu_item "reset_nvim" "Resets nvim. Deletes caches, removes nvim folders and relinks nvim folders"
menu_item "yamlfmt" "Run yamlfmt to all dotfiles, which are in our control"
menu_item "shfmt" "Run shfmt to all dotfiles"
;; ;;
esac esac
} }
function section_check function section_check
{ {
USAGE_PREFIX="$SCRIPT check" USAGE_PREFIX="$SCRIPT check <command>"
X_HOSTNAME=$(hostname) X_HOSTNAME=$(hostname)
X_ARCH=$(uname) X_ARCH=$(uname)
MENU=(
"arch <arch>:Empty <arch> returns current. Exit code 0=match to current, 1=no match."
"host <host>:Empty <host> returns current. Exit code 0=match to current, 1=no match."
)
case "$1" in case "$1" in
a | arch) a | arch)
[[ "$2" = "" ]] && echo "$X_ARCH" && exit 0 [[ "$2" = "" ]] && echo "$X_ARCH" && exit 0
@@ -226,9 +239,7 @@ function section_check
[[ $X_HOSTNAME = "$2" ]] && exit 0 || exit 1 [[ $X_HOSTNAME = "$2" ]] && exit 0 || exit 1
;; ;;
*) *)
menu_section "$USAGE_PREFIX" "arch | host" menu_usage "$USAGE_PREFIX" "${MENU[@]}"
menu_item "arch <arch>" "Empty returns current. Exit code 0 when match, 1 when not."
menu_item "host <host>" "Empty returns current. Exit code 0 when match, 1 when not."
;; ;;
esac esac
} }
@@ -236,24 +247,31 @@ function section_check
# Secret menu for visual tests # Secret menu for visual tests
function section_tests function section_tests
{ {
USAGE_PREFIX="$SCRIPT tests" USAGE_PREFIX="$SCRIPT tests <command>"
MENU=(
"msg:List all log functions from shared.sh"
)
case "$1" in case "$1" in
msg) msg)
msg "msg" msg "msg"
msg_done "msg_done" msg_done "msg_done"
msg_prompt "msg_prompt" msg_done_suffix "msg_done_suffix"
msg_prompt_done "msg_prompt_done" msg_err "msg_err"
msg_nested "msg_nested" msg_nested "msg_nested"
msg_nested_done "msg_nested_done" msg_nested_done "msg_nested_done"
msg_run "msg_run" "second_param"
msg_ok "msg_ok" msg_ok "msg_ok"
msg_prompt "msg_prompt"
msg_prompt_done "msg_prompt_done"
msg_run "msg_run" "second_param"
msg_run_done "msg_run_done" "second_param"
msg_warn "msg_warn" msg_warn "msg_warn"
msg_err "msg_err" msg_yay "msg_yay"
msg_yay_done "msg_yay_done"
;; ;;
*) *)
menu_section "$USAGE_PREFIX" "msg" menu_usage "$USAGE_PREFIX" "${MENU[@]}"
menu_item "msg" "List all log functions from shared.sh"
;; ;;
esac esac
} }
@@ -261,8 +279,8 @@ function section_tests
function usage function usage
{ {
echo "" echo ""
menu_section "Usage: $SCRIPT" "install | reset | brew | check | dotfiles" msg_prompt "Usage: $SCRIPT <section> <command>"
echo $" All commands have their own subcommands." echo $" Empty <command> prints <section> help."
echo "" echo ""
section_install section_install
echo "" echo ""

View File

@@ -11,4 +11,3 @@ dir="$1"
if [ ! -d "$dir" ]; then if [ ! -d "$dir" ]; then
mkdir -p "$dir" && exit 0 mkdir -p "$dir" && exit 0
fi fi

53
local/bin/x-hr Executable file
View File

@@ -0,0 +1,53 @@
#!/usr/bin/env bash
# Simple script to output a solid line in the terminal
# Useful for marking the end of a task in your bash log
# Inspired by @LuRsT's script of the same name
# Can be called directly, or source'd in *rc file
#
# Licensed under MIT, (C) Alicia Sykes 2022
# See: https://github.com/Lissy93/dotfiles
#
# Modified by Ismo Vuorinen <https://github.com/ivuorinen> 2023
# Determine width of terminal
hr_col_count="$(tput cols)"
if [ -z "${hr_col_count+set}" ] || [ "$hr_col_count" -lt 1 ]; then
hr_col_count="${COLUMNS:-80}"
fi
# Colors
CLR_RED="\033[1;31m"
hr_color="${hr_color:=$CLR_RED}"
hr_reset="\033[0m"
# Prints the HR line
hr_draw_char() {
local CHAR="$1"
local LINE=''
LINE=$(printf "%*s" "$((hr_col_count - 2))")
LINE="${LINE// /${CHAR}}"
echo -e "◀${hr_color}${LINE:0:${hr_col_count}}${hr_reset}▶"
}
# Passes param and calls hr()
hr() {
for WORD in "${@:--}"; do
hr_draw_char "$WORD"
done
}
# Determine if file is being run directly or sourced
(
[[ -n $ZSH_EVAL_CONTEXT && $ZSH_EVAL_CONTEXT =~ :file$ ]] \
|| [[ -n $KSH_VERSION && $(cd "$(dirname -- "$0")" \
&& printf '%s' "${PWD%/}/")$(basename -- "$0") != "${.sh.file}" ]] \
|| [[ -n $BASH_VERSION ]] && (return 0 2>/dev/null)
) && sourced=1 || sourced=0
# Either instantiate immediately, or set alias for later
if [ "$sourced" -eq 0 ]; then
[ "$0" == "${BASH_SOURCE[0]}" ] && hr "$@"
else
export alias hr='hr'
fi

View File

@@ -2,4 +2,3 @@
# Source: https://github.com/thirtythreeforty/dotfiles/blob/master/bin/extip # Source: https://github.com/thirtythreeforty/dotfiles/blob/master/bin/extip
curl icanhazip.com "${@}" curl icanhazip.com "${@}"

93
local/bin/x-welcome-banner Executable file
View File

@@ -0,0 +1,93 @@
#!/usr/bin/env bash
######################################################################
# 🌞 Welcome Banner #
######################################################################
# Prints personal greeting, system info and data about today #
# Intended for use as a MOTD, for when using multiple systems #
# For docs and more info, see: https://github.com/lissy93/dotfiles #
# #
# Licensed under MIT (C) Alicia Sykes 2022 <https://aliciasykes.com> #
######################################################################
# Formatting variables
COLOR_P='\033[1;36m'
COLOR_S='\033[0;36m'
RESET='\033[0m'
# Print time-based personalized message, using figlet & lolcat if availible
function welcome_greeting () {
h=$(date +%H)
if [ "$h" -lt 04 ] || [[ $h -gt 22 ]];
then greeting="Good Night"
elif [ "$h" -lt 12 ];
then greeting="Good morning"
elif [ "$h" -lt 18 ];
then greeting="Good afternoon"
elif [ "$h" -lt 22 ];
then greeting="Good evening"
else
greeting="Hello"
fi
WELCOME_MSG="$greeting $USER!"
if hash lolcat 2>/dev/null && hash figlet 2>/dev/null; then
echo "${WELCOME_MSG}" | figlet | lolcat
else
echo -e "$COLOR_P${WELCOME_MSG}${RESET}\n"
fi
}
# Print system information with neofetch, if it's installed
function welcome_sysinfo () {
if hash neofetch 2>/dev/null; then
neofetch --shell_version off \
--disable kernel distro shell resolution de wm wm_theme theme icons terminal \
--backend off \
--colors 4 8 4 4 8 6 \
--color_blocks off \
--memory_display info
fi
}
# Print todays info: Date, IP, weather, etc
function welcome_today () {
timeout=1
echo -e "\033[1;34mToday\n------"
# Print date time
echo -e "$COLOR_S$(date '+🗓️ Date: %A, %B %d, %Y at %H:%M')"
# Print local weather
curl -s -m $timeout "https://wttr.in?format=%cWeather:+%C+%t,+%p+%w"
echo -e "${RESET}"
# Print IP address
if hash ip 2>/dev/null; then
ip_address=$(ip route get 8.8.8.8 | awk -F"src " 'NR==1{split($2,a," ");print a[1]}')
ip_interface=$(ip route get 8.8.8.8 | awk -F"dev " 'NR==1{split($2,a," ");print a[1]}')
echo -e "${COLOR_S}🌐 IP: $(curl -s -m $timeout 'https://ipinfo.io/ip') (${ip_address} on ${ip_interface})"
echo -e "${RESET}\n"
fi
}
# Putting it all together
function welcome() {
welcome_greeting
welcome_sysinfo
welcome_today
}
# Determine if file is being run directly or sourced
([[ -n $ZSH_EVAL_CONTEXT && $ZSH_EVAL_CONTEXT =~ :file$ ]] \
|| [[ -n $KSH_VERSION && $(cd "$(dirname -- "$0")" \
&& printf '%s' "${PWD%/}/")$(basename -- "$0") != "${.sh.file}" ]] \
|| [[ -n $BASH_VERSION ]] && (return 0 2>/dev/null)
) && sourced=1 || sourced=0
# If script being called directly run immediately
if [ "$sourced" -eq 0 ]; then
welcome "$@"
fi
# EOF

View File

@@ -1,6 +1,10 @@
#!/bin/bash #!/usr/bin/env bash
# Install PHP Package Manager Composer
#
# shellcheck source="shared.sh"
source "$HOME/.dotfiles/scripts/shared.sh"
if command -v php &> /dev/null; then have php && {
EXPECTED_CHECKSUM="$(php -r 'copy("https://composer.github.io/installer.sig", "php://stdout");')" EXPECTED_CHECKSUM="$(php -r 'copy("https://composer.github.io/installer.sig", "php://stdout");')"
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
ACTUAL_CHECKSUM="$(php -r "echo hash_file('sha384', 'composer-setup.php');")" ACTUAL_CHECKSUM="$(php -r "echo hash_file('sha384', 'composer-setup.php');")"
@@ -16,4 +20,4 @@ if command -v php &> /dev/null; then
rm composer-setup.php rm composer-setup.php
mv composer.phar ~/.local/bin/composer mv composer.phar ~/.local/bin/composer
exit $RESULT exit $RESULT
fi } || msg_err "PHP Not Available, cannot install composer"

View File

@@ -4,9 +4,7 @@
# shellcheck source="shared.sh" # shellcheck source="shared.sh"
source "$HOME/.dotfiles/scripts/shared.sh" source "$HOME/.dotfiles/scripts/shared.sh"
if ! command -v gh &> /dev/null; then have gh && {
msg_run "gh (GitHub Client) could not be found, please install it first"
else
extensions=( extensions=(
# GitHub CLI extension for generating a report on repository dependencies. # GitHub CLI extension for generating a report on repository dependencies.
andyfeller/gh-dependency-report andyfeller/gh-dependency-report
@@ -41,4 +39,4 @@ else
done done
msg_ok "Done" msg_ok "Done"
fi } || msg_err "gh (GitHub Client) could not be found, please install it first"

View File

@@ -4,9 +4,7 @@
# shellcheck source=shared.sh # shellcheck source=shared.sh
source "$HOME/.dotfiles/scripts/shared.sh" source "$HOME/.dotfiles/scripts/shared.sh"
if ! command -v go &> /dev/null; then have go && {
msg "go hasn't been installed yet."
else
packages=( packages=(
# sysadmin/scripting utilities, distributed as a single binary # sysadmin/scripting utilities, distributed as a single binary
github.com/skx/sysbox@latest github.com/skx/sysbox@latest
@@ -14,6 +12,7 @@ else
github.com/google/yamlfmt/cmd/yamlfmt@latest github.com/google/yamlfmt/cmd/yamlfmt@latest
github.com/ericchiang/pup@latest github.com/ericchiang/pup@latest
github.com/suntong/html2md@latest github.com/suntong/html2md@latest
github.com/cheat/cheat/cmd/cheat@latest
) )
for pkg in "${packages[@]}"; do for pkg in "${packages[@]}"; do
@@ -28,5 +27,4 @@ else
done done
msg_ok "Done" msg_ok "Done"
} || msg "go hasn't been installed yet."
fi

View File

@@ -4,9 +4,7 @@
# shellcheck source=shared.sh # shellcheck source=shared.sh
source "$HOME/.dotfiles/scripts/shared.sh" source "$HOME/.dotfiles/scripts/shared.sh"
if ! command -v npm &> /dev/null; then have npm && {
msg_err "npm could not be found."
else
packages=( packages=(
# This is a tool to check if your files consider your .editorconfig rules. # This is a tool to check if your files consider your .editorconfig rules.
"editorconfig-checker" "editorconfig-checker"
@@ -17,7 +15,6 @@ else
"prettier" "prettier"
"@bchatard/alfred-jetbrains" "@bchatard/alfred-jetbrains"
"@johnnymorganz/stylua-bin" "@johnnymorganz/stylua-bin"
"js-debug"
"stylelint-lsp" "stylelint-lsp"
"blade-formatter" "blade-formatter"
"@loopback/cli" "@loopback/cli"
@@ -31,8 +28,17 @@ else
# Skip comments # Skip comments
if [[ ${pkg:0:1} == "#" ]]; then continue; fi if [[ ${pkg:0:1} == "#" ]]; then continue; fi
msg_run "Installing npm package:" "$pkg" if [[ $(npm ls -g -p "$pkg") != "" ]]; then
npm install -g --no-fund --no-progress --no-timing "$pkg" msg_run_done "$pkg" "already installed"
else
msg_run "Installing npm package:" "$pkg"
npm install -g --no-fund --no-progress --no-timing "$pkg"
fi
echo "" echo ""
done done
fi
msg_run "Upgrading all global packages"
npm -g --no-progress --no-timing --no-fund outdated
npm -g --no-timing --no-fund upgrade
} || msg_err "npm could not be found."

View File

@@ -1,8 +1,14 @@
#!/bin/bash #!/usr/bin/env bash
#
# Install ntfy
#
# shellcheck source=shared.sh
source "$HOME/.dotfiles/scripts/shared.sh"
set -e set -e
if ! command -v ntfy &> /dev/null; then have ntfy && {
msg "ntfy already installed"
} || {
case $(dfm check arch) in case $(dfm check arch) in
Linux) Linux)
NTFY_ARCH="linux_$(arch)" NTFY_ARCH="linux_$(arch)"
@@ -28,6 +34,4 @@ if ! command -v ntfy &> /dev/null; then
fi fi
rm -rf "${NTFY_DEST}" "${NTFY_DEST}.tar.gz" rm -rf "${NTFY_DEST}" "${NTFY_DEST}.tar.gz"
else }
echo "ntfy already installed"
fi

View File

@@ -1,4 +1,9 @@
#!/usr/bin/env bash #!/usr/bin/env bash
#
# Install z
#
# shellcheck source=shared.sh
source "$HOME/.dotfiles/scripts/shared.sh"
Z_GIT_PATH="https://github.com/rupa/z.git" Z_GIT_PATH="https://github.com/rupa/z.git"
Z_BIN_PATH="$XDG_BIN_HOME/z" Z_BIN_PATH="$XDG_BIN_HOME/z"
@@ -6,5 +11,5 @@ Z_BIN_PATH="$XDG_BIN_HOME/z"
if [ ! -d "$Z_BIN_PATH" ]; then if [ ! -d "$Z_BIN_PATH" ]; then
git clone "$Z_GIT_PATH" "$Z_BIN_PATH" git clone "$Z_GIT_PATH" "$Z_BIN_PATH"
else else
echo "z ($Z_BIN_PATH/) already installed" msg_done "z ($Z_BIN_PATH/) already installed"
fi fi

View File

@@ -11,6 +11,28 @@ CLR_GREEN="\033[1;32m"
CLR_BLUE="\033[1;34m" CLR_BLUE="\033[1;34m"
CLR_RESET="\033[0m" CLR_RESET="\033[0m"
# -- Color functions -- #
function __color_red()
{
local MSG="$1"
echo -e "${CLR_RED}${MSG}${CLR_RESET}"
}
function __color_yellow()
{
local MSG="$1"
echo -e "${CLR_YELLOW}${MSG}${CLR_RESET}"
}
function __color_green()
{
local MSG="$1"
echo -e "${CLR_GREEN}${MSG}${CLR_RESET}"
}
function __color_blue()
{
local MSG="$1"
echo -e "${CLR_BLUE}${MSG}${CLR_RESET}"
}
# -- Helpers -- # # -- Helpers -- #
function __log_marker() function __log_marker()
{ {
@@ -32,6 +54,11 @@ function __log_marker_warn()
echo -e "${CLR_YELLOW}${CLR_RESET}" echo -e "${CLR_YELLOW}${CLR_RESET}"
} }
function __log_marker_question()
{
echo -e "${CLR_YELLOW}?${CLR_RESET}"
}
function __log_marker_err() function __log_marker_err()
{ {
echo -e "${CLR_RED}${CLR_RESET}" echo -e "${CLR_RED}${CLR_RESET}"
@@ -48,19 +75,34 @@ function msg()
echo -e "$(__log_marker) $1" echo -e "$(__log_marker) $1"
} }
function msg_yay()
{
echo -e "🎉 $1"
}
function msg_yay_done()
{
echo -e "🎉 $1 ...$(__log_marker_ok)"
}
function msg_done() function msg_done()
{ {
echo -e "$(__log_marker) $1 ...$(__log_marker_ok)" echo -e "$(__log_marker) $1 ...$(__log_marker_ok)"
} }
function msg_done_suffix()
{
echo -e "$(__log_marker) ...$(__log_marker_ok)"
}
function msg_prompt() function msg_prompt()
{ {
echo -e "$(__log_marker) $1" echo -e "$(__log_marker_question) $1"
} }
function msg_prompt_done() function msg_prompt_done()
{ {
echo -e "$(__log_marker) $1 ...$(__log_marker_ok)" echo -e "$(__log_marker_question) $1 ...$(__log_marker_ok)"
} }
function msg_nested() function msg_nested()
@@ -78,6 +120,11 @@ function msg_run()
echo -e "${CLR_GREEN}$1${CLR_RESET} $2" echo -e "${CLR_GREEN}$1${CLR_RESET} $2"
} }
function msg_run_done()
{
echo -e "${CLR_GREEN}$1${CLR_RESET} $2 ...$(__log_marker_ok)"
}
function msg_ok() function msg_ok()
{ {
echo -e "$(__log_marker_ok) $1" echo -e "$(__log_marker_ok) $1"
@@ -111,3 +158,69 @@ function fn_exists()
declare -f -F "$1" > /dev/null declare -f -F "$1" > /dev/null
return $? return $?
} }
# Takes a bash array ("cow:moo", "dinosaur:roar") and loops
# through the keys to build menu section listing.
function menu_usage_header()
{
MENU_CMD="$1"
shift
MENU_ARRAY=("$@")
KEYS=""
for item in "${MENU_ARRAY[@]}"; do
CMD=$(echo "${item}" | awk -F ":" '{print $1}')
KEYS+="${CMD} | "
done
# "???" removes 3 last characters, being " | " from the end
menu_section "$MENU_CMD" "${KEYS%???}"
}
# Takes the usage command "$0 dotfiles" and a
# bash array ("cow:moo" "dinosaur:roar") and loops
# through in building a menu for dfm command usage listing.
function menu_usage()
{
MENU_CMD="$1"
shift
MENU_ARRAY=("$@")
msg "$MENU_CMD"
for item in "${MENU_ARRAY[@]}"; do
CMD=$(echo "${item}" | awk -F ":" '{print $1}')
DESC=$(echo "${item}" | awk -F ":" '{print $2}')
menu_item "$CMD" "$DESC"
done
}
# shorthand for checking if the system has the bin in path.
# usage: have php && php -v
function have
{
command -v "$1" >&/dev/null
}
# Remove directory from the PATH variable
# usage: path_remove ~/.local/bin
function path_remove
{
PATH=$(echo -n "$PATH" | awk -v RS=: -v ORS=: "\$0 != \"$1\"" | sed 's/:$//')
}
# Append directory to the PATH
# usage: path_append ~/.local/bin
function path_append
{
path_remove "$1"
PATH="${PATH:+"$PATH:"}$1"
}
# Prepend directory to the PATH
# usage: path_prepend ~/.local/bin
function path_prepend
{
path_remove "$1"
PATH="$1${PATH:+":$PATH"}"
}