forked from CodelyTV/dotly
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
53b89bc
commit 16e5fc6
Showing
34 changed files
with
652 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
[scripts/*] | ||
indent_style = space | ||
indent_size = 2 | ||
|
||
[.zshrc] | ||
indent_style = space | ||
indent_size = 2 | ||
|
||
[*.md] | ||
indent_style = space | ||
indent_size = 2 | ||
|
||
[*.json] | ||
indent_style = space | ||
indent_size = 2 | ||
|
||
[karabiner.json] | ||
indent_size = 4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
shell/zsh/**/**.zwc | ||
shell/zsh/**/**.zwc.old |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[submodule "modules/zimfw"] | ||
path = modules/zimfw | ||
url = [email protected]:zimfw/zimfw.git | ||
[submodule "modules/dotbot"] | ||
path = modules/dotbot | ||
url = [email protected]:anishathalye/dotbot.git | ||
ignore = dirty | ||
[submodule "modules/z"] | ||
path = modules/z | ||
url = [email protected]:rupa/z.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2018 Rafa Gomez [email protected] | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Useful when you c&p commands from the internet :P | ||
|
||
"$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
source "$DOTLY_PATH/scripts/core/_main.sh" | ||
|
||
##? Usage: | ||
##? dot | ||
##? dot <context> | ||
##? dot <context> <cmd> [<args>...] | ||
|
||
list_command_paths() { | ||
find "$DOTFILES_PATH/scripts" -maxdepth 2 -perm +111 -type f | | ||
grep -v core | | ||
sort | ||
} | ||
|
||
fzf_prompt() { | ||
local paths="$1" | ||
|
||
match="$(echo "$paths" | | ||
xargs -I % sh -c 'echo "$(basename $(dirname %)) $(basename %)"' | | ||
fzf --height 100% --preview 'dot $(echo {} | cut -d" " -f 1) $(echo {} | cut -d" " -f 2) -h | bat --style=numbers')" | ||
printf "$match " | ||
read args | ||
if coll::is_empty "$args"; then | ||
dot $match | ||
else | ||
dot $match "$args" | ||
fi | ||
} | ||
|
||
if args::has_no_args "$@"; then | ||
fzf_prompt "$(list_command_paths)" | ||
elif args::total_is 1 "$@"; then | ||
fzf_prompt "$(list_command_paths | grep "/$1/")" | ||
else | ||
context="$1" | ||
command="$2" | ||
|
||
shift 2 | ||
export DOT_TRACE=${TRACE:-false} | ||
|
||
"${DOTFILES_PATH}/scripts/${context}/${command}" "$@" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
source "$DOTFILES_PATH/scripts/core/_main.sh" | ||
|
||
##? Checkout alias | ||
#?? 1.0.0 | ||
##? | ||
##? Usage: | ||
##? git-co <thing> | ||
|
||
docs::eval "$@" | ||
|
||
git checkout $thing |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
source "$DOTFILES_PATH/scripts/core/_main.sh" | ||
|
||
##? Reset the status to the last commit | ||
#?? 1.0.0 | ||
##? | ||
##? Usage: | ||
##? git-discard | ||
|
||
docs::eval "$@" | ||
|
||
git add -A | ||
git reset --hard >/dev/null 2>&1 | ||
echo 'All changes has been discarded!' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
source "$DOTFILES_PATH/scripts/core/_main.sh" | ||
|
||
##? Delete the last commit, but not the files | ||
#?? 1.0.0 | ||
##? | ||
##? Usage: | ||
##? git-undo | ||
|
||
docs::eval "$@" | ||
|
||
git reset HEAD~1 --mixed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
##? Setups the environment | ||
##? | ||
##? Usage: | ||
##? install | ||
|
||
red='\033[0;31m' | ||
green='\033[0;32m' | ||
purple='\033[0;35m' | ||
normal='\033[0m' | ||
|
||
_w() { | ||
local -r text="${1:-}" | ||
echo -e "$text" | ||
} | ||
_a() { _w " > $1"; } | ||
_e() { _a "${red}$1${normal}"; } | ||
_s() { _a "${green}$1${normal}"; } | ||
_q() { read -rp "🤔 $1: " "$2"; } | ||
|
||
current_timestamp() { date +%s; } | ||
|
||
create_dotfiles_dir() { | ||
if [ -d "$1" ]; then | ||
local -r backup_path="$1.$(current_timestamp).back" | ||
|
||
_e "The path '$1' already exist" | ||
_s "Creating a backup in '$backup_path'" | ||
|
||
mv "$1" "$backup_path" | ||
else | ||
_a "Ok! dotfiles wll be located in: ${purple}$DOTFILES_PATH${normal}" | ||
fi | ||
|
||
mkdir -p "$1" | ||
} | ||
|
||
_w " ┌────────────────────────────────────┐" | ||
_w "~ │ 🚀 Welcome to the ${green}dotly${normal} installer! │ ~" | ||
_w " └────────────────────────────────────┘" | ||
_w | ||
_q "Where do you want your dotfiles to be located? (default ~/.dotfiles2)" "DOTFILES_PATH" | ||
DOTFILES_PATH="${DOTFILES_PATH:-$HOME/.dotfiles2}" | ||
DOTFILES_PATH="$(eval echo "$DOTFILES_PATH")" | ||
|
||
export DOTFILES_PATH="$DOTFILES_PATH" | ||
export DOTLY_PATH="$DOTFILES_PATH/modules/dotly" | ||
|
||
create_dotfiles_dir "$DOTFILES_PATH" | ||
cd "$DOTFILES_PATH" | ||
|
||
_a "Initializing your dotfiles git repository" | ||
git init >/dev/null | ||
|
||
_a "Cloning dotly" | ||
git submodule add "https://github.com/CodelyTV/dotly.git" "$DOTLY_PATH" >/dev/null 2>&1 | ||
|
||
_a "Installing dotly dependencies" | ||
git submodule update --init --recursive >/dev/null 2>&1 | ||
|
||
cd "$DOTLY_PATH" | ||
|
||
# While debugging | ||
git switch first-version >/dev/null 2>&1 | ||
|
||
"$PWD/bin/dot" self install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/usr/bin/env bash | ||
|
||
if ! ${DOT_MAIN_SOURCED:-false}; then | ||
source "$DOTLY_PATH/scripts/core/log.sh" | ||
source "$DOTLY_PATH/scripts/core/platform.sh" | ||
|
||
readonly DOT_MAIN_SOURCED=true | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
#!/usr/bin/env bash | ||
|
||
log::ansi() { | ||
local bg=false | ||
case "$@" in | ||
*reset*) | ||
echo "\e[0m" | ||
return 0 | ||
;; | ||
*black*) color=30 ;; | ||
*red*) color=31 ;; | ||
*green*) color=32 ;; | ||
*yellow*) color=33 ;; | ||
*blue*) color=34 ;; | ||
*purple*) color=35 ;; | ||
*cyan*) color=36 ;; | ||
*white*) color=37 ;; | ||
esac | ||
case "$@" in | ||
*regular*) mod=0 ;; | ||
*bold*) mod=1 ;; | ||
*underline*) mod=4 ;; | ||
esac | ||
case "$@" in | ||
*background*) bg=true ;; | ||
*bg*) bg=true ;; | ||
esac | ||
|
||
if $bg; then | ||
echo "\e[${color}m" | ||
else | ||
echo "\e[${mod:-0};${color}m" | ||
fi | ||
} | ||
|
||
if [ -z ${DOT_LOG_FILE+x} ]; then | ||
readonly DOT_LOG_FILE="/tmp/$(basename "$0").log" | ||
fi | ||
|
||
_log() { | ||
local template=$1 | ||
shift | ||
if ${log_to_file:-false}; then | ||
echoerr -e $(printf "$template" "$@") | tee -a "$DOT_LOG_FILE" >&2 | ||
else | ||
echoerr -e $(printf "$template" "$@") | ||
fi | ||
} | ||
|
||
_header() { | ||
local TOTAL_CHARS=60 | ||
local total=$TOTAL_CHARS-2 | ||
local size=${#1} | ||
local left=$((($total - $size) / 2)) | ||
local right=$(($total - $size - $left)) | ||
printf "%${left}s" '' | tr ' ' = | ||
printf " $1 " | ||
printf "%${right}s" '' | tr ' ' = | ||
} | ||
|
||
log::header() { _log "\n$(log::ansi bold)$(log::ansi purple)$(_header "$1")$(log::ansi reset)\n"; } | ||
log::success() { _log "$(log::ansi green)✔ %s$(log::ansi reset)\n" "$@"; } | ||
log::error() { _log "$(log::ansi red)✖ %s$(log::ansi reset)\n" "$@"; } | ||
log::warning() { _log "$(log::ansi yellow)➜ %s$(log::ansi reset)\n" "$@"; } | ||
log::note() { _log "$(log::ansi blue)%s$(log::ansi reset)\n" "$@"; } | ||
|
||
die() { | ||
log::error "$@" | ||
exit 42 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
platform::command_exists() { | ||
type "$1" >/dev/null | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
source "$DOTLY_PATH/scripts/core/_main.sh" | ||
source "$DOTLY_PATH/scripts/self/utils/install.sh" | ||
|
||
##? Install dotly and setup dotfiles | ||
#?? 1.0.0 | ||
##? | ||
##? Usage: | ||
##? install | ||
|
||
if ! platform::command_exists zsh; then | ||
log::note "Zsh not installed, installing" | ||
|
||
"$DOTLY_PATH/bin/dot" package add zsh | ||
else | ||
log::note "Zsh already installed!" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/bin/user/env bash | ||
|
||
install_macos_custom() { | ||
# Install brew if not installed | ||
if ! [ -x "$(command -v brew)" ]; then | ||
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" | ||
fi | ||
|
||
# All apps (This line is 2 times because there are dependencies between brew cask and brew) | ||
brew bundle --file="$DOTLY_PATH/mac/brew/Brewfile" || true | ||
brew bundle --file="$DOTLY_PATH/mac/brew/Brewfile" | ||
|
||
# Correct paths (so, we handle all with $PATH) | ||
sudo truncate -s 0 /etc/paths | ||
|
||
# Custom macOS "defaults" | ||
sh "$DOTLY_PATH/mac/mac-os.sh" | ||
} | ||
|
||
install_linux_custom() { | ||
echo | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
alias ..="cd .." | ||
alias ...="cd ../.." | ||
alias ll="exa -l" | ||
alias la="exa -la" | ||
|
||
# Jumps | ||
alias ~="cd ~" | ||
alias tmp="cd ~/Desktop/tmp" | ||
alias c='cd ~/Code' | ||
alias mines="cd ~/Code/mines" | ||
alias dotfiles="cd ~/.dotfiles" | ||
alias codely="cd ~/Code/codely" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
alias gaa="git add -A" | ||
alias gc="dot git commit" | ||
alias gca="git add --all && git commit --amend --no-edit" | ||
alias gco="git checkout" | ||
alias gd="dot git pretty-diff" | ||
alias gs="git status -sb" | ||
alias gf="git fetch --all -p" | ||
alias gps="git push" | ||
alias gpsf="git push --force" | ||
alias gpl="git pull --rebase --autostash" | ||
alias gb="git branch" | ||
alias gl="dot git pretty-log" |
Oops, something went wrong.