Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
13628d1
Paths are now loaded before everything
gtrabanco Feb 13, 2021
2ab33fb
Core update, adding some functions that will be used with other featu…
gtrabanco Mar 28, 2021
dbc9316
Improved output::join with a stackoverflow function in: https://stack…
gtrabanco Mar 28, 2021
addcdbb
Deleted duplicate functions that were in str.sh and output. Added arr…
gtrabanco Mar 28, 2021
db3a6b9
Added closed and unapproved PR #61 because it is needed when I use be…
gtrabanco Mar 28, 2021
4e744a7
Fixed error that all the the time say that script_name where not dis/…
gtrabanco Mar 28, 2021
6fd9349
Fixed the use of refactored function changed to str.sh. Changed outpu…
gtrabanco Mar 28, 2021
7107be1
Added missing autoupdate command for docpars
gtrabanco Mar 28, 2021
145a56c
Fixed all the mess with loader and vars
gtrabanco Mar 28, 2021
5802b61
Added a way to modify DOTFILES_PATH structure when add a feature to d…
gtrabanco Mar 29, 2021
747042a
Fixed error when no subcommand were passed
gtrabanco Mar 29, 2021
639d244
Fixed for non alphanumeric files
gtrabanco Mar 29, 2021
7ebb649
Fixed for non alphanumeric files. No include . and .. directories.
gtrabanco Mar 29, 2021
f85b4bf
Now you can apply directly a symlink docbot file if you know the name…
gtrabanco Mar 29, 2021
5f8e96f
Fixed output::question in macOS now does not print a newline like in …
gtrabanco Mar 31, 2021
659326f
Added new functions to get the current script_name or script_path whe…
gtrabanco Mar 31, 2021
1a6bdb8
Added function to conver mayus to lower
gtrabanco Mar 31, 2021
1975a28
Fixed quotation
gtrabanco Mar 31, 2021
0279d4a
Added ZDOTDIR
gtrabanco Mar 31, 2021
02a7547
Fixed error in path to load zsh loader for DOTLY
gtrabanco Mar 31, 2021
1fbdc5d
Fixed quotation that made loop array not working
gtrabanco Mar 31, 2021
d9e058d
Fix error
gtrabanco Mar 31, 2021
b4f2dec
Reverting changes
gtrabanco Apr 1, 2021
5902a6f
Fixed error with array. Modified templating so now replace directly i…
gtrabanco Apr 1, 2021
c7f92ca
Merge branch 'master' into feature/core
gtrabanco Apr 1, 2021
b5342cf
Added async library
gtrabanco Apr 1, 2021
e2770cc
Splitted symlinks feature that was added in another different script
gtrabanco Apr 1, 2021
e5eba99
Load async functions with the all core functionality
gtrabanco Apr 1, 2021
a4c48cf
Fixed auto init scripts loader
gtrabanco Apr 2, 2021
623262a
Fixed autoload init scripts with bash
gtrabanco Apr 2, 2021
ec37721
Fixed error #93 with bash autocompletions
gtrabanco Apr 2, 2021
ab04c2a
First autouptate version. Help Needed.
gtrabanco Apr 2, 2021
b055d27
Merged feature/async_autoupdate
gtrabanco Apr 2, 2021
a777f45
Deleted some debug information
gtrabanco Apr 2, 2021
dd07b37
Deleted some debug information again due the git reset --hard I have …
gtrabanco Apr 2, 2021
effbfe8
Fixed error with output::yesno which made this function to always ret…
gtrabanco Apr 2, 2021
4d8d2e2
Fix error when try to execute a broken link to init script
gtrabanco Apr 4, 2021
ae4a4df
Fixed the use of files::check_if_path_is_older, refactored files::che…
gtrabanco Apr 4, 2021
b053231
Fixed the use of shift when not necessary
gtrabanco Apr 4, 2021
13b6516
Fixed the usage of variable name path inside 'files::check_if_path_is…
gtrabanco Apr 4, 2021
538f7d3
Replaced 'source' for '.' as posix standard... Delete some debug comm…
gtrabanco Apr 5, 2021
8be2559
Trying to fix error that produce not to enable/disable multiple scrip…
gtrabanco Apr 5, 2021
a9feb37
Fixed that scripts ended in DOTLY_PATH instead of current dir due to …
gtrabanco Apr 7, 2021
87c3b86
Fixed output '1' always executes async. Deleted not necessary functions
gtrabanco Apr 8, 2021
13262d2
Fixed double negation error
gtrabanco Apr 8, 2021
f7a9c7a
Not right idented .sh files in vscode
gtrabanco Apr 8, 2021
f5d9dcd
Restored docpars as should be
gtrabanco Apr 8, 2021
8a06ae8
Remove comments and not necessary comments
gtrabanco Apr 8, 2021
08e1919
Remove source and use '.' which is posix compilant
gtrabanco Apr 8, 2021
4ffe258
Added github api command. Check minor version. Update silently is dif…
gtrabanco Apr 8, 2021
561ff1e
Fixed realtime prompt update
gtrabanco Apr 8, 2021
27335de
Not lifetime cache for github petitions
gtrabanco Apr 8, 2021
c61713e
Added a new line at the end of the file
gtrabanco Apr 8, 2021
367b265
Solved variable names
gtrabanco Apr 9, 2021
ad439a5
Deleted unused function
gtrabanco Apr 9, 2021
105e235
Deleted not neccessary blank line
gtrabanco Apr 10, 2021
75d5cc8
Fixed error in str::join
gtrabanco Apr 10, 2021
20761dd
Added some functions and fixed the cache when call github api to gith…
gtrabanco Apr 10, 2021
bcc9992
Fixed github::get_api_url, not all api calls require a branch
gtrabanco Apr 10, 2021
266c71f
Adapted to changes in github.sh, added function to get latest dotly v…
gtrabanco Apr 10, 2021
2f6692b
Fixed error with variable of github cache path
gtrabanco Apr 10, 2021
cad69c0
Append in the symlinks updater shell command to append autoupdater fi…
gtrabanco Apr 10, 2021
feae8a6
Fixed error in symlinks update that only show one file instead of all…
gtrabanco Apr 10, 2021
55be028
Fixed issue with update symlinks file
gtrabanco Apr 10, 2021
eb0a9db
Removed unnecessary commands to execute because init-scripts folders …
gtrabanco Apr 10, 2021
cdaf469
Added warning when no GITHUB_TOKEN is set
gtrabanco Apr 11, 2021
9876ca2
Repetitive stuff should be in a loop
gtrabanco Apr 11, 2021
f031202
Added support in update symlinks for symlinks, so now scripts and upd…
gtrabanco Apr 12, 2021
864e5c2
Support for symlinks and files as init scripts, so now scripts can al…
gtrabanco Apr 12, 2021
430902c
Fixed error that does not show symlinks in init-scripts folder
gtrabanco Apr 12, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
indent_style = space
indent_size = 2

[*.sh]
indent_style = space
indent_size = 2

[.zshrc]
indent_style = space
indent_size = 2
Expand Down
3 changes: 3 additions & 0 deletions dotfiles_template/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.dotly_update_available
.dotly_updated
.cached_github_api_calls
45 changes: 6 additions & 39 deletions dotfiles_template/shell/bash/.bashrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,9 @@ export DOTFILES_PATH="XXX_DOTFILES_PATH_XXX"
export DOTLY_PATH="$DOTFILES_PATH/modules/dotly"
export DOTLY_THEME="codely"

if [[ "$(ps -p $$ -ocomm=)" =~ (bash$) ]]; then
__right_prompt() {
RIGHT_PROMPT=""
[[ -n $RPS1 ]] && RIGHT_PROMPT=$RPS1 || RIGHT_PROMPT=$RPROMPT
if [[ -n $RIGHT_PROMPT ]]; then
n=$(($COLUMNS - ${#RIGHT_PROMPT}))
printf "%${n}s$RIGHT_PROMPT\\r"
fi
}
export PROMPT_COMMAND="__right_prompt"
fi

source "$DOTFILES_PATH/shell/init.sh"

PATH=$(
IFS=":"
echo "${path[*]}"
)
export PATH

themes_paths=(
"$DOTFILES_PATH/shell/bash/themes"
"$DOTLY_PATH/shell/bash/themes"
)

for THEME_PATH in ${themes_paths[@]}; do
THEME_PATH="${THEME_PATH}/$DOTLY_THEME.sh"
[ -f "$THEME_PATH" ] && source "$THEME_PATH" && break
done

for bash_file in "$DOTLY_PATH"/shell/bash/completions/*; do
source "$bash_file"
done

if [ -n "$(ls -A "$DOTFILES_PATH/shell/bash/completions/")" ]; then
for bash_file in "$DOTFILES_PATH"/shell/bash/completions/*; do
source "$bash_file"
done
fi
if [[ -f "$DOTLY_PATH/shell/bash/init-dotly.sh" ]]
then
. "$DOTLY_PATH/shell/bash/init-dotly.sh"
else
echo "\033[0;31m\033[1mDOTLY Could not be loaded\033[0m"
fi
22 changes: 3 additions & 19 deletions dotfiles_template/shell/exports.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
export DOTLY_AUTO_UPDATE_PERIOD_IN_DAYS=7
export DOTLY_AUTO_UPDATE_MODE="minor" # silent, auto, minor*, info, prompt

export JAVA_HOME='/Library/Java/JavaVirtualMachines/amazon-corretto-15.jdk/Contents/Home'
export GEM_HOME="$HOME/.gem"
export GOPATH="$HOME/.go"
Expand All @@ -6,22 +9,3 @@ export FZF_DEFAULT_OPTS='
--color=pointer:#ebdbb2,bg+:#3c3836,fg:#ebdbb2,fg+:#fbf1c7,hl:#8ec07c,info:#928374,header:#fb4934
--reverse
'

export path=(
"$HOME/bin"
"$DOTLY_PATH/bin"
"$DOTFILES_PATH/bin"
"$JAVA_HOME/bin"
"$GEM_HOME/bin"
"$GOPATH/bin"
"$HOME/.cargo/bin"
"/usr/local/opt/ruby/bin"
"/usr/local/opt/python/libexec/bin"
"/opt/homebrew/bin"
"/usr/local/bin"
"/usr/local/sbin"
"/bin"
"/usr/bin"
"/usr/sbin"
"/sbin"
)
Empty file.
Empty file.
18 changes: 18 additions & 0 deletions dotfiles_template/shell/paths.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
export path=(
"$HOME/bin"
"$DOTLY_PATH/bin"
"$DOTFILES_PATH/bin"
"$JAVA_HOME/bin"
"$GEM_HOME/bin"
"$GOPATH/bin"
"$HOME/.cargo/bin"
"/usr/local/opt/ruby/bin"
"/usr/local/opt/python/libexec/bin"
"/opt/homebrew/bin"
"/usr/local/bin"
"/usr/local/sbin"
"/bin"
"/usr/bin"
"/usr/sbin"
"/sbin"
)
29 changes: 6 additions & 23 deletions dotfiles_template/shell/zsh/.zshrc
Original file line number Diff line number Diff line change
@@ -1,26 +1,9 @@
# Uncomment for debuf with `zprof`
# zmodload zsh/zprof

# ZSH Ops
setopt HIST_IGNORE_ALL_DUPS
setopt HIST_FCNTL_LOCK
setopt +o nomatch
# setopt autopushd

# Start zim
source "$ZIM_HOME/init.zsh"

# Async mode for autocompletion
ZSH_AUTOSUGGEST_USE_ASYNC=true
ZSH_HIGHLIGHT_MAXLENGTH=300

source "$DOTFILES_PATH/shell/init.sh"

fpath=("$DOTFILES_PATH/shell/zsh/themes" "$DOTFILES_PATH/shell/zsh/autocompletions" "$DOTLY_PATH/shell/zsh/themes" "$DOTLY_PATH/shell/zsh/completions" $fpath)

autoload -Uz promptinit && promptinit
prompt ${DOTLY_THEME:-codely}

source "$DOTLY_PATH/shell/zsh/bindings/dot.zsh"
source "$DOTLY_PATH/shell/zsh/bindings/reverse_search.zsh"
source "$DOTFILES_PATH/shell/zsh/key-bindings.zsh"
if [[ -f "$DOTLY_PATH/shell/zsh/init-dotly.sh" ]]
then
. "$DOTLY_PATH/shell/zsh/init-dotly.sh"
else
echo "\033[0;31m\033[1mDOTLY Could not be loaded\033[0m"
fi
2 changes: 1 addition & 1 deletion scripts/core/_main.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash

if ! ${DOT_MAIN_SOURCED:-false}; then
for file in $DOTLY_PATH/scripts/core/{args,collections,documentation,dot,git,log,platform,output,str}.sh; do
for file in $DOTLY_PATH/scripts/core/{args,array,async,collections,documentation,dot,files,git,log,platform,output,str}.sh; do
source "$file";
done;
unset file;
Expand Down
6 changes: 6 additions & 0 deletions scripts/core/array.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash

# Usage: array::* "${arr1[@]}" "${arr2[@]}"
array::union() { echo "${@}" | tr ' ' '\n' | sort | uniq; }
array::disjunction() { echo "${@}" | tr ' ' '\n' | sort | uniq -u; }
array::difference() { echo "${@}" | tr ' ' '\n' | sort | uniq -d; }
124 changes: 124 additions & 0 deletions scripts/core/async.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
#!/usr/bin/env bash

# This was literally copied from: https://github.com/zombieleet/async-bash
# check the README.md for information on how to use this script

# set +eu

declare -a JOB_IDS
declare -i JOBS=1;

killJob() {
local jobToKill signal __al__signals isSig

jobToKill="$1"
signal="$2"
signal=${signal^^}

[[ ! $jobToKill =~ ^[[:digit:]]+$ ]] && {
printf "%s\n" "\"$jobToKill\" should be an integer ";
return 1;
}


{
[[ -z "$signal" ]] && {
signal="SIGTERM"
}
} || {
# for loop worked better than read line in this case
__al__signals=$(kill -l);
isSig=0;
for sig in ${__al__signals}; do
[[ ! $sig =~ ^[[:digit:]]+\)$ ]] && {
[[ $signal == $sig ]] && {
isSig=1;
break;
}
}
done

(( isSig != 1 )) && {
signal="SIGTERM"
}
}



for job in ${JOB_IDS[@]};do
# increment job to 1 since array index starts from 0
read -r -d " " -a __kunk__ <<< "${JOB_IDS[$job]}"
(( __kunk__ == jobToKill )) && {
read -r -d " " -a __kunk__ <<< "${JOB_IDS[$job]}"

kill -${signal} %${__kunk__}

status=$?

(( status != 0 )) && {
printf "cannot kill %s %d\n" "${JOB_IDS[$job]}" "${__kunk__}"
return 1;
}

printf "%d killed with %s\n" "${__kunk__}" "${signal}"

return 0;
}
done
}

async() {
local cmdToExec resolve reject _c __temp status

cmdToExec="$1"
resolve="$2"
reject="$3"

[[ -z "$cmdToExec" ]] || [[ -z "$reject" ]] || [[ -z "$resolve" ]] && {
printf "%s\n" "Insufficient number of arguments";
return 1;
}



__temp=( "$cmdToExec" "$reject" "$resolve" )


for _c in "${__temp[@]}"; do
read -r -d " " comm <<<"${_c}"
type "${comm}" &>/dev/null

status=$?

(( status != 0 )) && {
printf "\"%s\" is neither a function nor a recognized cmd\n" "${_c}";
unset _c
return 1;
}
done

unset __temp _c

{
__result=$($cmdToExec)
status=$?

if (( status == 0 ))
then
$resolve "${__result}"
else
$reject "${status}"
fi
unset __result
} &

JOB_IDS+=( "${JOBS} ${cmd}" )

read -r -d " " -a __kunk__ <<< "${JOB_IDS[$(( ${#JOB_IDS[@]} - 1))]}"

#echo ${__kunk__}


: $(( JOBS++ ))

}
28 changes: 28 additions & 0 deletions scripts/core/debug.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env bash

debug::out() {
echo "$@"
}

debug::log() {
[[ ! -z "$DEBUG" ]] && debug::out "$@"
}

debug::logg() {
DEBUG_LEVEL=${DEBUG_LEVEL:-1}
[[ $DEBUG_LEVEL -gt 1 ]] && debug::log $@
}

debug::log_exec() {
debug::log "Executing: ${@[@]}"
eval "${@[@]}"
}

debug::set_variable () {
local var_name="$1"
shift
local values=$@
eval "$var_name=${values[@]}"

debug::logg "Set varible '$var_name' to '${values[@]}'"
}
9 changes: 9 additions & 0 deletions scripts/core/files.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

files::check_if_path_is_older() {
local path_to_check number_of period
path_to_check="$1"
number_of="${2:-0}"
period="${3:-days}"
[[ -e "$path_to_check" ]] && [[ $(date -r "$path_to_check" +%s) -lt $(date -d "now - $number_of $period" +%s) ]]
}
Loading