diff --git a/zsh/functions/apt_keys_recovery b/zsh/functions/apt_keys_recovery old mode 100755 new mode 100644 diff --git a/zsh/functions/apt_search_installed b/zsh/functions/apt_search_installed old mode 100755 new mode 100644 diff --git a/zsh/functions/audio_reset b/zsh/functions/audio_reset old mode 100755 new mode 100644 diff --git a/zsh/functions/busybox_ash_shell b/zsh/functions/busybox_ash_shell old mode 100755 new mode 100644 diff --git a/zsh/functions/caller b/zsh/functions/caller old mode 100755 new mode 100644 diff --git a/zsh/functions/chmod_easy b/zsh/functions/chmod_easy old mode 100755 new mode 100644 diff --git a/zsh/functions/chmod_reset b/zsh/functions/chmod_reset old mode 100755 new mode 100644 index 75f5271..82a0eb9 --- a/zsh/functions/chmod_reset +++ b/zsh/functions/chmod_reset @@ -3,7 +3,7 @@ function chmod_reset() { [ -z "$1" ] && echo "path is required" && return 1 || echo "resetting permissions on $1" sudo chown -R "$USER:$USER" "$1" - sudo chmod -R 644 "$1" + sudo chmod -R 600 "$1" sudo chmod -R -x+X "$1" find "$1" -name "*.sh" -exec sudo chmod u+x {} \; find "$1" -name "*.py" -exec sudo chmod u+x {} \; diff --git a/zsh/functions/crontab_backup b/zsh/functions/crontab_backup old mode 100755 new mode 100644 diff --git a/zsh/functions/db_migrate b/zsh/functions/db_migrate old mode 100755 new mode 100644 diff --git a/zsh/functions/disable_accelerometter b/zsh/functions/disable_accelerometter old mode 100755 new mode 100644 index c2c0b8c..d41a6da --- a/zsh/functions/disable_accelerometter +++ b/zsh/functions/disable_accelerometter @@ -1,5 +1,4 @@ - - +#!/usr/bin/env zsh function disable_accelerometter() { xinput &>/dev/null || return 1 diff --git a/zsh/functions/disable_amazon_search b/zsh/functions/disable_amazon_search old mode 100755 new mode 100644 index d148c3b..c77d0aa --- a/zsh/functions/disable_amazon_search +++ b/zsh/functions/disable_amazon_search @@ -1,5 +1,4 @@ - - +#!/usr/bin/env zsh function disable_amazon_search() { gsettings set com.canonical.Unity.Lenses disabled-scopes "['more_suggestions-amazon.scope', 'more_suggestions-u1ms.scope', 'more_suggestions-populartracks.scope', 'music-musicstore.scope', 'more_suggestions-ebay.scope', 'more_suggestions-ubuntushop.scope', 'more_suggestions-skimlinks.scope']" diff --git a/zsh/functions/disable_tracker b/zsh/functions/disable_tracker old mode 100755 new mode 100644 index dee7730..ce63f36 --- a/zsh/functions/disable_tracker +++ b/zsh/functions/disable_tracker @@ -1,5 +1,4 @@ - - +#!/usr/bin/env zsh function disable_tracker() { echo -e "\nHidden=true\n" | sudo tee --append /etc/xdg/autostart/tracker-{extract,miner-apps,miner-fs,miner-user-guides,store}.desktop > /dev/null diff --git a/zsh/functions/dns_local_setup b/zsh/functions/dns_local_setup old mode 100755 new mode 100644 index 16f4ab8..c8d8365 --- a/zsh/functions/dns_local_setup +++ b/zsh/functions/dns_local_setup @@ -1,5 +1,5 @@ #!/usr/bin/env zsh function dns_local_setup() { - bash -c "${DOTFILES}/bash/scripts/dns_local_setup.sh" + bash -c "DOMAIN=mylan ${DOTFILES}/bash/scripts/dns_local_setup.sh" } diff --git a/zsh/functions/dns_systemd_resolved_stop b/zsh/functions/dns_systemd_resolved_stop old mode 100755 new mode 100644 diff --git a/zsh/functions/docker_config_files_sanitize b/zsh/functions/docker_config_files_sanitize old mode 100755 new mode 100644 diff --git a/zsh/functions/docker_container_inspect b/zsh/functions/docker_container_inspect old mode 100755 new mode 100644 diff --git a/zsh/functions/docker_container_ip b/zsh/functions/docker_container_ip old mode 100755 new mode 100644 index b996d03..98fceb9 --- a/zsh/functions/docker_container_ip +++ b/zsh/functions/docker_container_ip @@ -1,5 +1,5 @@ #!/usr/bin/env zsh function docker_container_ip() { - ${DOCKER} inspect -f "{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}" $@ + ${DOCKER} inspect --format '{{ .NetworkSettings.IPAddress }}' "$@" } diff --git a/zsh/functions/docker_container_pid b/zsh/functions/docker_container_pid new file mode 100644 index 0000000..6443ce2 --- /dev/null +++ b/zsh/functions/docker_container_pid @@ -0,0 +1,5 @@ +#!/usr/bin/env zsh + +function docker_container_ip() { + ${DOCKER} inspect --format '{{ .State.Pid }}' "$@" +} diff --git a/zsh/functions/docker_container_remove b/zsh/functions/docker_container_remove old mode 100755 new mode 100644 diff --git a/zsh/functions/docker_container_stop b/zsh/functions/docker_container_stop old mode 100755 new mode 100644 diff --git a/zsh/functions/docker_containers_list b/zsh/functions/docker_containers_list old mode 100755 new mode 100644 diff --git a/zsh/functions/docker_containers_list_detailed b/zsh/functions/docker_containers_list_detailed old mode 100755 new mode 100644 diff --git a/zsh/functions/docker_containers_sanitize b/zsh/functions/docker_containers_sanitize old mode 100755 new mode 100644 diff --git a/zsh/functions/docker_containers_stop b/zsh/functions/docker_containers_stop old mode 100755 new mode 100644 diff --git a/zsh/functions/docker_content_sanitize b/zsh/functions/docker_content_sanitize old mode 100755 new mode 100644 diff --git a/zsh/functions/docker_daemon_config_reset b/zsh/functions/docker_daemon_config_reset old mode 100755 new mode 100644 diff --git a/zsh/functions/docker_exec_interative b/zsh/functions/docker_exec_interative old mode 100755 new mode 100644 diff --git a/zsh/functions/docker_give_me_back_my b/zsh/functions/docker_give_me_back_my old mode 100755 new mode 100644 diff --git a/zsh/functions/docker_image_remove b/zsh/functions/docker_image_remove old mode 100755 new mode 100644 diff --git a/zsh/functions/docker_images_dangling b/zsh/functions/docker_images_dangling old mode 100755 new mode 100644 diff --git a/zsh/functions/docker_images_dangling_sanitize b/zsh/functions/docker_images_dangling_sanitize old mode 100755 new mode 100644 diff --git a/zsh/functions/docker_images_list b/zsh/functions/docker_images_list old mode 100755 new mode 100644 diff --git a/zsh/functions/docker_images_list_detailed b/zsh/functions/docker_images_list_detailed old mode 100755 new mode 100644 diff --git a/zsh/functions/docker_images_sanitize b/zsh/functions/docker_images_sanitize old mode 100755 new mode 100644 diff --git a/zsh/functions/docker_install b/zsh/functions/docker_install old mode 100755 new mode 100644 diff --git a/zsh/functions/docker_install_check b/zsh/functions/docker_install_check old mode 100755 new mode 100644 diff --git a/zsh/functions/docker_install_reset b/zsh/functions/docker_install_reset old mode 100755 new mode 100644 diff --git a/zsh/functions/docker_install_sanitize b/zsh/functions/docker_install_sanitize old mode 100755 new mode 100644 diff --git a/zsh/functions/docker_local_ip_sanitize b/zsh/functions/docker_local_ip_sanitize old mode 100755 new mode 100644 diff --git a/zsh/functions/docker_logs_sanitize b/zsh/functions/docker_logs_sanitize old mode 100755 new mode 100644 diff --git a/zsh/functions/docker_network_ip b/zsh/functions/docker_network_ip old mode 100755 new mode 100644 diff --git a/zsh/functions/docker_running_check b/zsh/functions/docker_running_check old mode 100755 new mode 100644 diff --git a/zsh/functions/dropbox.zsh b/zsh/functions/dropbox_sync similarity index 94% rename from zsh/functions/dropbox.zsh rename to zsh/functions/dropbox_sync index 60f3276..301a9b0 100755 --- a/zsh/functions/dropbox.zsh +++ b/zsh/functions/dropbox_sync @@ -1,3 +1,5 @@ +#!/usr/bin/env zsh + function dropbox_sync() { wait_for=5m diff --git a/zsh/functions/emoji_random b/zsh/functions/emoji_random old mode 100755 new mode 100644 diff --git a/zsh/functions/extract b/zsh/functions/extract old mode 100755 new mode 100644 index e378200..d2119c9 --- a/zsh/functions/extract +++ b/zsh/functions/extract @@ -1,3 +1,5 @@ +#!/usr/bin/env zsh + # # Usage: extract # Description: extracts archived files / mounts disk images diff --git a/zsh/functions/figlet_maker b/zsh/functions/figlet_maker old mode 100755 new mode 100644 index 3572c09..3131faf --- a/zsh/functions/figlet_maker +++ b/zsh/functions/figlet_maker @@ -1,3 +1,5 @@ +#!/usr/bin/env zsh + function figlet_maker() { figlet $1 | sed -e s/$/\ \\\\n\"/g | sed -e s/\^/\@printf\ \"\\\\033\[33m/g | sed -e s/\`/\\\\\`/g echo @printf '"\\033[0m\\n"' diff --git a/zsh/functions/find_text_here b/zsh/functions/find_text_here old mode 100755 new mode 100644 diff --git a/zsh/functions/git.zsh b/zsh/functions/git.zsh deleted file mode 100755 index 0cc3edb..0000000 --- a/zsh/functions/git.zsh +++ /dev/null @@ -1,222 +0,0 @@ -function git_current_commit() { - CURRENT_COMMIT=$(/usr/bin/git rev-parse --short HEAD) - echo $CURRENT_COMMIT -} - -function git_commits_ahead() { - CURRENT_COMMIT=$1 - [[ "$CURRENT_COMMIT" == "" ]] && CURRENT_COMMIT=$(git_current_commit) - /usr/bin/git log --oneline --reverse --ancestry-path $CURRENT_COMMIT..master -} - -function git_next_commit() { - CURRENT_COMMIT=$1 - [[ "$CURRENT_COMMIT" == "" ]] && CURRENT_COMMIT=$(git_current_commit) - NEXT_COMMIT=$(git_commits_ahead | /bin/grep -v $CURRENT_COMMIT | head -n1 | awk '{print $1}') - echo $NEXT_COMMIT -} - -function git_checkout_pristine() { - NEXT_COMMIT=$1 - /usr/bin/git checkout . - /usr/bin/git clean -fdx - /usr/bin/git checkout $NEXT_COMMIT -} - -function go_to_git_next_commit() { - CURRENT_COMMIT=$(git_current_commit) - echo "current commit is $CURRENT_COMMIT..." - NEXT_COMMIT=$(git_next_commit $CURRENT_COMMIT) - echo "next commit is $NEXT_COMMIT..." - git_checkout_pristine $NEXT_COMMIT 1> /dev/null 2>&1 -} - -function git_commit_last_with_file() { - FILE=$1 - - LOG=$2 - if [[ "$LOG" == "" ]]; then - echo "seeking last commit with file $FILE..." - LOG=$USER_TMP/git_commit_last_with_file/ - mkdir -p $LOG - LOG=$LOG/$(date +"%Y%m%d%H%M%S").log - touch $LOG - fi - - LAST_COMMIT=$3 - - CURRENT_COMMIT=$(git_current_commit) - echo $CURRENT_COMMIT >> $LOG - - if [ -f $1 ]; then - echo "file yet found, going head..." - go_to_git_next_commit - if [[ "$?" == "1" ]]; then - echo "git_next_commit returns error, retrying" - sleep 3 - fi - git_commit_last_with_file $FILE $LOG $CURRENT_COMMIT - else - echo "file no more found, going back to $LAST_COMMIT" - git_checkout_pristine $LAST_COMMIT 1> /dev/null 2>&1 - echo "finish" - fi -} - -function git_clone_repos_by_url() { - function start_log_file() { - LOG_FILE=$1 - RANDOM_NUMBER=$(((RANDOM % 14) + 1)) - echo -e ${COLORS[$RANDOM_NUMBER]} >$LOG_FILE 2>&1 - } - - function print_last_line() { - LOG_FILE=$1 - LAST_LINE=$(wc -l <$LOG_FILE) - BEFORE_LAST_LINE=$(($LAST_LINE - 1)) - printf "$(sed -n 1p $LOG_FILE)" - printf "$(sed -n ${BEFORE_LAST_LINE}p $LOG_FILE)" - printf "$(sed -n ${LAST_LINE}p $LOG_FILE)" - printf "\n" - } - - function finalize_log_file() { - LOG_FILE=$1 - ONLY_LAST_LINE=$2 - echo -e "\n"$NC >>$LOG_FILE 2>&1 - if [[ "$ONLY_LAST_LINE" == "only-last-line" ]]; then - print_last_line $LOG_FILE; - return; - fi - /bin/cat $LOG_FILE - } - - function git_clone() { - REPO_NAME=$1 - REPO_SSH_URL=$2 - THIS_LOG=$TMP/$REPO_NAME.log - touch $THIS_LOG - start_log_file $THIS_LOG - - echo -ne "cloning from $REPO_SSH_URL to $DEST/$REPO_NAME" >>$THIS_LOG 2>&1 - - git clone --progress $REPO_SSH_URL $DEST/$REPO_NAME >>$THIS_LOG 2>&1 - - if [[ $(/bin/cat $THIS_LOG | grep -c "make sure you have the correct access rights") > 0 ]]; then - echo -ne "🔒 $REPO_NAME blocked, you can't see this" >>$THIS_LOG 2>&1; - finalize_log_file $THIS_LOG "only-last-line"; - return; - fi - - if [[ $(/bin/cat $THIS_LOG | grep -c "is not an empty directory") > 0 ]]; then - echo -ne "✅ $REPO_NAME repository already exist" >>$THIS_LOG 2>&1; - finalize_log_file $THIS_LOG "only-last-line"; - return; - fi - - finalize_log_file $THIS_LOG - } - - function iterate_page_result() { - PAGE=$1 - /bin/cat $TMP/page_$PAGE.json | sed -r 's/\\"//g' | jq -r -c '.[]' | while read -r item; do - git_clone $(jq -r -c '.name' <<<$item) $(jq -r -c '.ssh_url' <<<$item); - done - } - - function finalize() { - echo "🏁 finished pages downloading" - } - - function fetch() { - URL=$1 - curl -s -u $GITHUB_USER:$TOKEN -D $TMP/page_$PAGE.txt -o $TMP/page_$PAGE.json $URL - } - - function next_page() { - /bin/cat $TMP/page_$PAGE.txt | grep 'link:' | sed -ne 's/.*\(http[^"]*\)>;\srel="next".*/\1/p' - } - - URL=$1 - DEST=$2 - if [[ -z "${URL}" ]]; then echo "URL is required, nothing to do by now"; return; fi - if [[ -z "${DEST}" ]]; then echo "dest path is required, nothing to do by now"; return; fi - - PAGE=$(echo $URL | /bin/sed -E 's/.*[^_]page=([0-9]+).*/\1/g') - if [[ -z "${PAGE}" ]]; then echo "page can't be found, nothing to do by now"; return; fi - - NOW=$(date +"%Y%m%d%H%M%S") - TMP=$USER_TMP/git-clone/$NOW - TOKEN=$(git config github.token) - - echo "🌎 downloading page $PAGE from $URL to $DEST..." - - mkdir -p $TMP - fetch $URL - - iterate_page_result $PAGE $DEST - - NEXT_PAGE=$(next_page) - if [[ -z "${NEXT_PAGE}" ]]; then finalize; return; fi - - git_clone_repos_by_url $NEXT_PAGE $DEST -} - -function git_repo_info() { - [ -d $1 ] && [ -d $1/.git ] && - for r in $(git --git-dir=$1/.git --work-tree=$1 remote); do - echo -n $r";" && - echo -n $(git --git-dir=$1/.git --work-tree=$1 remote get-url --all $r)";" && - echo -ne $1"\n" - done -} - -function git_workspaces_backup() { - [[ "$1" == "" ]] && echo "you need pass the root path and alias for this. i.e.: backup_git_workspaces ~/my_workspace_root_path" && return 1 - - local file=$(last_backup_version git-workspaces csv) - - [ -f $file ] && mv \ - $file $SYNC_DOTFILES/git-workspaces/$(hostname)_$(date +"%Y%m%d%H%M%S").csv - - for d in `find $1 -path '*/.git/config'`; do - d=${d%/.git/config} - git_repo_info $d | tee -a $file &>/dev/null - ; done -} - -function git_workspaces_restore() { - local file=$(last_backup_version git-workspaces csv) - - while read line; do - if [[ `which_shell` == "zsh" ]]; then - parts=("${(@s/;/)line}") - origin_name=${parts[1]} - remote_url=${parts[2]} - local_path=${parts[3]} - else - IFS=';' read -r -a parts <<<"$line" - origin_name=${parts[0]} - remote_url=${parts[1]} - local_path=${parts[2]} - fi - - if [ ! -d $local_path ]; then - echo "origin_name=$origin_name" - echo "remote_url=$remote_url" - echo "local_path=$local_path" - git clone $remote_url $local_path - echo "---" - fi - done <$file -} - -function git_config_mass_replace() { - for DIR in ./*; do - if [ -d "$DIR" ]; then - cd $DIR; - sed -i.bak 's/'$1'/'$2'/g' .git/config; - cd .. - fi - done -} diff --git a/zsh/functions/git_checkout_pristine b/zsh/functions/git_checkout_pristine new file mode 100755 index 0000000..27cc0bd --- /dev/null +++ b/zsh/functions/git_checkout_pristine @@ -0,0 +1,8 @@ +#!/usr/bin/env zsh + +function git_checkout_pristine() { + NEXT_COMMIT=$1 + /usr/bin/git checkout . + /usr/bin/git clean -fdx + /usr/bin/git checkout $NEXT_COMMIT +} diff --git a/zsh/functions/git_clone_repos_by_url b/zsh/functions/git_clone_repos_by_url new file mode 100755 index 0000000..1f6e60f --- /dev/null +++ b/zsh/functions/git_clone_repos_by_url @@ -0,0 +1,100 @@ +#!/usr/bin/env zsh + +function git_clone_repos_by_url() { + function start_log_file() { + LOG_FILE=$1 + RANDOM_NUMBER=$(((RANDOM % 14) + 1)) + echo -e ${COLORS[$RANDOM_NUMBER]} >$LOG_FILE 2>&1 + } + + function print_last_line() { + LOG_FILE=$1 + LAST_LINE=$(wc -l <$LOG_FILE) + BEFORE_LAST_LINE=$(($LAST_LINE - 1)) + printf "$(sed -n 1p $LOG_FILE)" + printf "$(sed -n ${BEFORE_LAST_LINE}p $LOG_FILE)" + printf "$(sed -n ${LAST_LINE}p $LOG_FILE)" + printf "\n" + } + + function finalize_log_file() { + LOG_FILE=$1 + ONLY_LAST_LINE=$2 + echo -e "\n"$NC >>$LOG_FILE 2>&1 + if [[ "$ONLY_LAST_LINE" == "only-last-line" ]]; then + print_last_line $LOG_FILE; + return; + fi + /bin/cat $LOG_FILE + } + + function git_clone() { + REPO_NAME=$1 + REPO_SSH_URL=$2 + THIS_LOG=$TMP/$REPO_NAME.log + touch $THIS_LOG + start_log_file $THIS_LOG + + echo -ne "cloning from $REPO_SSH_URL to $DEST/$REPO_NAME" >>$THIS_LOG 2>&1 + + git clone --progress $REPO_SSH_URL $DEST/$REPO_NAME >>$THIS_LOG 2>&1 + + if [[ $(/bin/cat $THIS_LOG | grep -c "make sure you have the correct access rights") > 0 ]]; then + echo -ne "🔒 $REPO_NAME blocked, you can't see this" >>$THIS_LOG 2>&1; + finalize_log_file $THIS_LOG "only-last-line"; + return; + fi + + if [[ $(/bin/cat $THIS_LOG | grep -c "is not an empty directory") > 0 ]]; then + echo -ne "✅ $REPO_NAME repository already exist" >>$THIS_LOG 2>&1; + finalize_log_file $THIS_LOG "only-last-line"; + return; + fi + + finalize_log_file $THIS_LOG + } + + function iterate_page_result() { + PAGE=$1 + /bin/cat $TMP/page_$PAGE.json | sed -r 's/\\"//g' | jq -r -c '.[]' | while read -r item; do + git_clone $(jq -r -c '.name' <<<$item) $(jq -r -c '.ssh_url' <<<$item); + done + } + + function finalize() { + echo "🏁 finished pages downloading" + } + + function fetch() { + URL=$1 + curl -s -u $GITHUB_USER:$TOKEN -D $TMP/page_$PAGE.txt -o $TMP/page_$PAGE.json $URL + } + + function next_page() { + /bin/cat $TMP/page_$PAGE.txt | grep 'link:' | sed -ne 's/.*\(http[^"]*\)>;\srel="next".*/\1/p' + } + + URL=$1 + DEST=$2 + if [[ -z "${URL}" ]]; then echo "URL is required, nothing to do by now"; return; fi + if [[ -z "${DEST}" ]]; then echo "dest path is required, nothing to do by now"; return; fi + + PAGE=$(echo $URL | /bin/sed -E 's/.*[^_]page=([0-9]+).*/\1/g') + if [[ -z "${PAGE}" ]]; then echo "page can't be found, nothing to do by now"; return; fi + + NOW=$(date +"%Y%m%d%H%M%S") + TMP=$USER_TMP/git-clone/$NOW + TOKEN=$(git config github.token) + + echo "🌎 downloading page $PAGE from $URL to $DEST..." + + mkdir -p $TMP + fetch $URL + + iterate_page_result $PAGE $DEST + + NEXT_PAGE=$(next_page) + if [[ -z "${NEXT_PAGE}" ]]; then finalize; return; fi + + git_clone_repos_by_url $NEXT_PAGE $DEST +} diff --git a/zsh/functions/git_commit_last_with_file b/zsh/functions/git_commit_last_with_file new file mode 100755 index 0000000..ab925c7 --- /dev/null +++ b/zsh/functions/git_commit_last_with_file @@ -0,0 +1,33 @@ +#!/usr/bin/env zsh + +function git_commit_last_with_file() { + FILE=$1 + + LOG=$2 + if [[ "$LOG" == "" ]]; then + echo "seeking last commit with file $FILE..." + LOG=$USER_TMP/git_commit_last_with_file/ + mkdir -p $LOG + LOG=$LOG/$(date +"%Y%m%d%H%M%S").log + touch $LOG + fi + + LAST_COMMIT=$3 + + CURRENT_COMMIT=$(git_current_commit) + echo $CURRENT_COMMIT >> $LOG + + if [ -f $1 ]; then + echo "file yet found, going head..." + go_to_git_next_commit + if [[ "$?" == "1" ]]; then + echo "git_next_commit returns error, retrying" + sleep 3 + fi + git_commit_last_with_file $FILE $LOG $CURRENT_COMMIT + else + echo "file no more found, going back to $LAST_COMMIT" + git_checkout_pristine $LAST_COMMIT 1> /dev/null 2>&1 + echo "finish" + fi +} diff --git a/zsh/functions/git_commits_ahead b/zsh/functions/git_commits_ahead new file mode 100755 index 0000000..304e8e0 --- /dev/null +++ b/zsh/functions/git_commits_ahead @@ -0,0 +1,7 @@ +#!/usr/bin/env zsh + +function git_commits_ahead() { + CURRENT_COMMIT=$1 + [[ "$CURRENT_COMMIT" == "" ]] && CURRENT_COMMIT=$(git_current_commit) + /usr/bin/git log --oneline --reverse --ancestry-path $CURRENT_COMMIT..master +} diff --git a/zsh/functions/git_config_mass_replace b/zsh/functions/git_config_mass_replace new file mode 100755 index 0000000..c2ab82e --- /dev/null +++ b/zsh/functions/git_config_mass_replace @@ -0,0 +1,11 @@ +#!/usr/bin/env zsh + +function git_config_mass_replace() { + for DIR in ./*; do + if [ -d "$DIR" ]; then + cd $DIR; + sed -i.bak 's/'$1'/'$2'/g' .git/config; + cd .. + fi + done +} diff --git a/zsh/functions/git_current_commit b/zsh/functions/git_current_commit new file mode 100755 index 0000000..7e6b2d2 --- /dev/null +++ b/zsh/functions/git_current_commit @@ -0,0 +1,6 @@ +#!/usr/bin/env zsh + +function git_current_commit() { + CURRENT_COMMIT=$(/usr/bin/git rev-parse --short HEAD) + echo $CURRENT_COMMIT +} diff --git a/zsh/functions/git_go_to_next_commit b/zsh/functions/git_go_to_next_commit new file mode 100755 index 0000000..0946bc3 --- /dev/null +++ b/zsh/functions/git_go_to_next_commit @@ -0,0 +1,9 @@ +#!/usr/bin/env zsh + +function git_go_to_next_commit() { + CURRENT_COMMIT=$(git_current_commit) + echo "current commit is $CURRENT_COMMIT..." + NEXT_COMMIT=$(git_next_commit $CURRENT_COMMIT) + echo "next commit is $NEXT_COMMIT..." + git_checkout_pristine $NEXT_COMMIT 1> /dev/null 2>&1 +} diff --git a/zsh/functions/git_next_commit b/zsh/functions/git_next_commit new file mode 100755 index 0000000..f7996ec --- /dev/null +++ b/zsh/functions/git_next_commit @@ -0,0 +1,8 @@ +#!/usr/bin/env zsh + +function git_next_commit() { + CURRENT_COMMIT=$1 + [[ "$CURRENT_COMMIT" == "" ]] && CURRENT_COMMIT=$(git_current_commit) + NEXT_COMMIT=$(git_commits_ahead | /bin/grep -v $CURRENT_COMMIT | head -n1 | awk '{print $1}') + echo $NEXT_COMMIT +} diff --git a/zsh/functions/git_repo_info b/zsh/functions/git_repo_info new file mode 100755 index 0000000..fd869f0 --- /dev/null +++ b/zsh/functions/git_repo_info @@ -0,0 +1,10 @@ +#!/usr/bin/env zsh + +function git_repo_info() { + [ -d $1 ] && [ -d $1/.git ] && + for r in $(git --git-dir=$1/.git --work-tree=$1 remote); do + echo -n $r";" && + echo -n $(git --git-dir=$1/.git --work-tree=$1 remote get-url --all $r)";" && + echo -ne $1"\n" + done +} diff --git a/zsh/functions/git_workspaces_backup b/zsh/functions/git_workspaces_backup new file mode 100755 index 0000000..eb59d4d --- /dev/null +++ b/zsh/functions/git_workspaces_backup @@ -0,0 +1,15 @@ +#!/usr/bin/env zsh + +function git_workspaces_backup() { + [[ "$1" == "" ]] && echo "you need pass the root path and alias for this. i.e.: git_workspaces_backup ~/my_workspace_root_path" && return 1 + + local file=$(last_backup_version git-workspaces csv) + + [ -f $file ] && mv \ + $file $SYNC_DOTFILES/git-workspaces/$(hostname)_$(date +"%Y%m%d%H%M%S").csv + + for d in `find $1 -path '*/.git/config'`; do + d=${d%/.git/config} + git_repo_info $d | tee -a $file &>/dev/null + ; done +} diff --git a/zsh/functions/git_workspaces_restore b/zsh/functions/git_workspaces_restore new file mode 100755 index 0000000..775e076 --- /dev/null +++ b/zsh/functions/git_workspaces_restore @@ -0,0 +1,27 @@ +#!/usr/bin/env zsh + +function git_workspaces_restore() { + local file=$(last_backup_version git-workspaces csv) + + while read line; do + if [[ `which_shell` == "zsh" ]]; then + parts=("${(@s/;/)line}") + origin_name=${parts[1]} + remote_url=${parts[2]} + local_path=${parts[3]} + else + IFS=';' read -r -a parts <<<"$line" + origin_name=${parts[0]} + remote_url=${parts[1]} + local_path=${parts[2]} + fi + + if [ ! -d $local_path ]; then + echo "origin_name=$origin_name" + echo "remote_url=$remote_url" + echo "local_path=$local_path" + git clone $remote_url $local_path + echo "---" + fi + done <$file +} diff --git a/zsh/functions/gnome_conf_sanitize b/zsh/functions/gnome_conf_sanitize old mode 100755 new mode 100644 diff --git a/zsh/functions/gnome_dconf_backup b/zsh/functions/gnome_dconf_backup old mode 100755 new mode 100644 index 4dfb9aa..a18aeb2 --- a/zsh/functions/gnome_dconf_backup +++ b/zsh/functions/gnome_dconf_backup @@ -1,5 +1,5 @@ #!/usr/bin/env zsh function gnome_dconf_backup() { - dconf dump /org/gnome/ > "${SYNC_DOTFILES}/gnome/${TIMESTAMP}.txt" + dconf dump / > "${SYNC_DOTFILES}/gnome/${TIMESTAMP}.txt" } diff --git a/zsh/functions/gnome_dconf_reset b/zsh/functions/gnome_dconf_reset old mode 100755 new mode 100644 index 9bc9e83..96e0e3a --- a/zsh/functions/gnome_dconf_reset +++ b/zsh/functions/gnome_dconf_reset @@ -1,5 +1,5 @@ #!/usr/bin/env zsh function gnome_dconf_reset() { - dconf reset -f /org/gnome/ + dconf reset -f / } diff --git a/zsh/functions/gnome_dconf_restore b/zsh/functions/gnome_dconf_restore old mode 100755 new mode 100644 index 6780e59..79cf6f1 --- a/zsh/functions/gnome_dconf_restore +++ b/zsh/functions/gnome_dconf_restore @@ -3,5 +3,5 @@ function gnome_dconf_restore() { local file=$(last_backup_version gnome txt) gnome_reset - dconf load /org/gnome/ <"$file" + dconf load / <"$file" } diff --git a/zsh/functions/gnome_shell_extensions_install b/zsh/functions/gnome_shell_extensions_install old mode 100755 new mode 100644 diff --git a/zsh/functions/gnome_shell_extensions_reactive b/zsh/functions/gnome_shell_extensions_reactive old mode 100755 new mode 100644 diff --git a/zsh/functions/go_install_tools b/zsh/functions/go_install_tools old mode 100755 new mode 100644 index 28b4f3a..386a0eb --- a/zsh/functions/go_install_tools +++ b/zsh/functions/go_install_tools @@ -1,4 +1,4 @@ - +#!/usr/bin/env zsh function go_install_tools() { echo "installing golang tools..." @@ -6,7 +6,7 @@ function go_install_tools() { curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin - /bin/cat $DOTFILES/go/install.txt | grep -v '#' | while read -r pkg; do + /bin/cat "$DOTFILES/go/install.txt" | grep -v '#' | while read -r pkg; do go install $pkg > /dev/null; done diff --git a/zsh/functions/go_packages_sanitize b/zsh/functions/go_packages_sanitize old mode 100755 new mode 100644 index 46e104e..64f9046 --- a/zsh/functions/go_packages_sanitize +++ b/zsh/functions/go_packages_sanitize @@ -1,10 +1,10 @@ - +#!/usr/bin/env zsh function go_packages_sanitize() { echo "cleaning old golang packages..." - ls $GOPATH/bin | xargs -n1 -I % trash "$GOPATH/bin/%" - find $GOPATH/src -mindepth 2 -maxdepth 2 -type d | grep -vE "$GITHUB_ORG|$GITHUB_USER" | xargs -n1 -I % trash "%" + ls "$GOPATH/bin" | xargs -n1 -I % trash "$GOPATH/bin/%" + find "$GOPATH/src" -mindepth 2 -maxdepth 2 -type d | grep -vE "$GITHUB_ORG|$GITHUB_USER" | xargs -n1 -I % trash "%" echo "cleaning OK" } diff --git a/zsh/functions/google_drive_sync b/zsh/functions/google_drive_sync old mode 100755 new mode 100644 index 2daf883..6b48611 --- a/zsh/functions/google_drive_sync +++ b/zsh/functions/google_drive_sync @@ -1,5 +1,4 @@ - - +#!/usr/bin/env zsh function google_drive_sync() { echo -e "running google drive worker..." diff --git a/zsh/functions/hudctl.zsh b/zsh/functions/hudctl.zsh deleted file mode 100644 index bd5daac..0000000 --- a/zsh/functions/hudctl.zsh +++ /dev/null @@ -1,7 +0,0 @@ -function hudctl() { - CMD=$(echo $@ | cut -c4-) - case $* in - cd* ) cd $(hudctl path "$CMD");; - * ) command hudctl "$@";; - esac; -} diff --git a/zsh/functions/kube_shell b/zsh/functions/kube_shell old mode 100755 new mode 100644 diff --git a/zsh/functions/log b/zsh/functions/log new file mode 100644 index 0000000..b1f2579 --- /dev/null +++ b/zsh/functions/log @@ -0,0 +1,18 @@ +#!/usr/bin/env zsh + +# shellcheck source=/dev/null +. "${DOTFILES}/zsh/init/20_colors.zsh" + +function log() { + level=$1 + shift + . "${DOTFILES}/zsh/functions/log_debug" + . "${DOTFILES}/zsh/functions/log_echo" + . "${DOTFILES}/zsh/functions/log_error" + . "${DOTFILES}/zsh/functions/log_finishing" + . "${DOTFILES}/zsh/functions/log_info" + . "${DOTFILES}/zsh/functions/log_is_command_success" + . "${DOTFILES}/zsh/functions/log_starting" + . "${DOTFILES}/zsh/functions/log_warn" + eval "log_$level '$@'" +} diff --git a/zsh/functions/log_debug b/zsh/functions/log_debug index 2a6e44b..8a6efe7 100644 --- a/zsh/functions/log_debug +++ b/zsh/functions/log_debug @@ -1,6 +1,5 @@ #!/usr/bin/env zsh function log_debug() { - $SHELL_DEBUG || return - log_echo "🐞" "${RED}${ON_YELLOW}" "$@" + log_echo "🐞" "${GREY}" "$@" } diff --git a/zsh/functions/log_echo b/zsh/functions/log_echo index a1e85b1..317ab03 100644 --- a/zsh/functions/log_echo +++ b/zsh/functions/log_echo @@ -1,6 +1,11 @@ #!/usr/bin/env zsh function log_echo() { + $SHELL_DEBUG || return + + local shell + shell="$0" + local icon icon="$1" @@ -18,11 +23,16 @@ function log_echo() { local rpad=0 local space="" local _caller="" + local _caller_end="" local cols=$(tput cols) - $SHELL_STACK && _caller=$(caller) + $SHELL_TRACE && _caller=$(caller) - local output="${icon}${color}$@${reset_color}" + local output="${icon}${color} $@ ${NC}" + + if ! command -v ansi2txt &>/dev/null; then + sudo apt-get install --no-install-recommends --yes colorized-logs 1>/dev/null + fi if [[ $cols -ge 80 ]]; then loutput=$(echo "${output}" | ansi2txt | wc -L) @@ -34,8 +44,10 @@ function log_echo() { rpad=$(($cols-$loutput)) lcaller=$(echo "${_caller}" | ansi2txt | wc -L) rpad=$(($rpad-$lcaller)) - space=${(l:$rpad:: :)} + if [[ "$shell" =~ "zsh" ]]; then + space=${(l:$rpad:: :)} + fi fi - echo ${output}${space}${_caller} + echo -e ${output}${space}${_caller}${_caller_end} } diff --git a/zsh/functions/log_error b/zsh/functions/log_error index 2876307..73d343c 100644 --- a/zsh/functions/log_error +++ b/zsh/functions/log_error @@ -1,6 +1,5 @@ #!/usr/bin/env zsh function log_error() { - $SHELL_DEBUG || return log_echo "💣" "$RED" "$@" } diff --git a/zsh/functions/log_finishing b/zsh/functions/log_finishing index 1eaea4d..5b40cc7 100644 --- a/zsh/functions/log_finishing +++ b/zsh/functions/log_finishing @@ -1,6 +1,5 @@ #!/usr/bin/env zsh function log_finishing() { - $SHELL_DEBUG || return log_echo "🦖" "$PURPLE" "$@" "was finished." } diff --git a/zsh/functions/log_info b/zsh/functions/log_info index 580e4b7..b5e8e48 100644 --- a/zsh/functions/log_info +++ b/zsh/functions/log_info @@ -1,6 +1,5 @@ #!/usr/bin/env zsh function log_info() { - $SHELL_DEBUG || return log_echo "💬" "$CYAN" "$@" } diff --git a/zsh/functions/log_starting b/zsh/functions/log_starting index fe4aae8..304ad37 100644 --- a/zsh/functions/log_starting +++ b/zsh/functions/log_starting @@ -1,6 +1,5 @@ #!/usr/bin/env zsh function log_starting() { - $SHELL_DEBUG || return log_echo "🥚" "$PURPLE" "starting $@..." } diff --git a/zsh/functions/log_warn b/zsh/functions/log_warn index 4711851..d701771 100644 --- a/zsh/functions/log_warn +++ b/zsh/functions/log_warn @@ -1,6 +1,5 @@ #!/usr/bin/env zsh function log_warn() { - $SHELL_DEBUG || return log_echo "🚧" "$YELLOW" "$@" } diff --git a/zsh/functions/ls_2_exa b/zsh/functions/ls_2_exa index 2b98961..f1b29e0 100644 --- a/zsh/functions/ls_2_exa +++ b/zsh/functions/ls_2_exa @@ -1,6 +1,7 @@ #!/usr/bin/env zsh function ls_2_exa() { + command -v exa &> /dev/null || sudo apt-get install exa args="$@" args=$(echo $args | sed 's/A/a/g') eval "exa $args" diff --git a/zsh/functions/mvdir b/zsh/functions/mvdir old mode 100755 new mode 100644 index c429e23..6910790 --- a/zsh/functions/mvdir +++ b/zsh/functions/mvdir @@ -1,4 +1,4 @@ - +#!/usr/bin/env zsh function mvdir() { for last; do true; done; mkdir -p "$last" && mv "$@"; diff --git a/zsh/functions/network_reset_iptables b/zsh/functions/network_reset_iptables old mode 100755 new mode 100644 index 3c36631..485f868 --- a/zsh/functions/network_reset_iptables +++ b/zsh/functions/network_reset_iptables @@ -1,4 +1,4 @@ - +#!/usr/bin/env zsh function network_reset_iptables() { CMDS=(ip6tables iptables) diff --git a/zsh/functions/networks_etup_tunnel b/zsh/functions/networks_etup_tunnel old mode 100755 new mode 100644 index 5146bca..7d2339c --- a/zsh/functions/networks_etup_tunnel +++ b/zsh/functions/networks_etup_tunnel @@ -1,5 +1,4 @@ - - +#!/usr/bin/env zsh function networks_etup_tunnel() { sleep 15s diff --git a/zsh/functions/npm b/zsh/functions/npm new file mode 100644 index 0000000..c387cb3 --- /dev/null +++ b/zsh/functions/npm @@ -0,0 +1,5 @@ +#!/usr/bin/env zsh + +function npm { + run_with_docker "node" "alpine" "npm" $@ +} diff --git a/zsh/functions/php b/zsh/functions/php new file mode 100644 index 0000000..1a8b23d --- /dev/null +++ b/zsh/functions/php @@ -0,0 +1,5 @@ +#!/usr/bin/env zsh + +function npm { + run_with_docker "php" "alpine" "npm" $@ +} diff --git a/zsh/functions/ppa_check b/zsh/functions/ppa_check old mode 100755 new mode 100644 index 7b1a056..09ad917 --- a/zsh/functions/ppa_check +++ b/zsh/functions/ppa_check @@ -1,4 +1,4 @@ - +#!/usr/bin/env zsh function ppa_check() { for f in /etc/apt/sources.list.d/*.list; do diff --git a/zsh/functions/progress_bar b/zsh/functions/progress_bar old mode 100755 new mode 100644 index deef77f..aeb9318 --- a/zsh/functions/progress_bar +++ b/zsh/functions/progress_bar @@ -1,4 +1,4 @@ - +#!/usr/bin/env zsh function progress_bar() { local bar_size=300 diff --git a/zsh/functions/resolvconf_fix b/zsh/functions/resolvconf_fix old mode 100755 new mode 100644 index 214ae81..b7365d5 --- a/zsh/functions/resolvconf_fix +++ b/zsh/functions/resolvconf_fix @@ -1,5 +1,4 @@ - - +#!/usr/bin/env zsh function resolvconf_fix() { if [[ $(cat /etc/resolv.conf | grep -c 'Generated by NetworkManager' | bc) -eq 1 ]]; then diff --git a/zsh/functions/resolvconf_reset b/zsh/functions/resolvconf_reset old mode 100755 new mode 100644 index bec770a..7f7be37 --- a/zsh/functions/resolvconf_reset +++ b/zsh/functions/resolvconf_reset @@ -1,5 +1,4 @@ - - +#!/usr/bin/env zsh function resolvconf_reset() { local resolv_conf="`cat $SYNC_DOTFILES/etc/resolv.conf`" diff --git a/zsh/functions/spaceship_histsize b/zsh/functions/spaceship_histsize old mode 100755 new mode 100644 diff --git a/zsh/functions/spaceship_random_emoji b/zsh/functions/spaceship_random_emoji old mode 100755 new mode 100644 diff --git a/zsh/functions/spinnaker_config_to_env b/zsh/functions/spinnaker_config_to_env old mode 100755 new mode 100644 index 70bbbce..afdc077 --- a/zsh/functions/spinnaker_config_to_env +++ b/zsh/functions/spinnaker_config_to_env @@ -1,6 +1,5 @@ - - +#!/usr/bin/env zsh function spinnaker_config_to_env() { - jq -r '.[] | "\(.name)=\(.value)"' $1 | sort + jq -r '.[] | "\(.name)=\(.value)"' "$1" | sort } diff --git a/zsh/functions/sudo b/zsh/functions/sudo old mode 100755 new mode 100644 index 269c037..19aac6e --- a/zsh/functions/sudo +++ b/zsh/functions/sudo @@ -1,34 +1,18 @@ #!/usr/bin/env zsh -# function sudo() { -# # shellcheck disable=SC2312 -# if [ "$(id -u)" -eq 0 ]; then -# "$@" -# else -# if ! command sudo --non-interactive true 2>/dev/null; then -# log_warn "root privileges are required, please enter your password below. pay attention for what you doing!" -# command sudo --validate -# fi -# command sudo "$@" -# fi -# } - function sudo() { - ( - pid=$(exec sh -c 'echo "$PPID"') - - # If the command takes less than .2s, don't change the theme. - # We could also just match on 'su' and ignore everything else, - # but this also accomodates other long running commands - # like 'sudo sleep 5s'. Modify to taste. + # https://tldp.org/LDP/Bash-Beginners-Guide/html/sect_12_02.html - ( - # sleep .2s - ps -p "$pid" > /dev/null && INHIBIT_THEME_HIST=1 theme.sh red-alert - ) & - trap 'theme.sh "$(theme.sh -l|tail -n1)"' INT + # shellcheck disable=SC2312 + if [ "$(id -u)" -eq 0 ]; then + echo "Hi $USER" + "$@" + else + if ! env sudo --non-interactive true 2>/dev/null; then + log_warn "Root privileges are being requested. Pay attention to what you are doing!" + env sudo --validate + fi env sudo "$@" - theme.sh "$(theme.sh -l|tail -n1)" - ) + fi } diff --git a/zsh/functions/todo_conky b/zsh/functions/todo_conky old mode 100755 new mode 100644 diff --git a/zsh/functions/todo_zsh b/zsh/functions/todo_zsh old mode 100755 new mode 100644 diff --git a/zsh/functions/todotxt_hide_create_date b/zsh/functions/todotxt_hide_create_date old mode 100755 new mode 100644 diff --git a/zsh/functions/todotxt_hide_footer b/zsh/functions/todotxt_hide_footer old mode 100755 new mode 100644 diff --git a/zsh/functions/todotxt_hide_project_and_context_symbols b/zsh/functions/todotxt_hide_project_and_context_symbols old mode 100755 new mode 100644 diff --git a/zsh/functions/todotxt_hide_projects b/zsh/functions/todotxt_hide_projects old mode 100755 new mode 100644 diff --git a/zsh/functions/todotxt_highlight_project_and_context b/zsh/functions/todotxt_highlight_project_and_context old mode 100755 new mode 100644 diff --git a/zsh/functions/vpn_add_route b/zsh/functions/vpn_add_route new file mode 100644 index 0000000..8241e0e --- /dev/null +++ b/zsh/functions/vpn_add_route @@ -0,0 +1,11 @@ +#!/usr/bin/env zsh + +function vpn_add_route() { + local host=$1 + local ips=($(vpn_get_ips $host)) + local local_vpn_ip=${2:=$(vpn_ip)} + + vpn_get_ips $host | while read -r ip; do + vpn_ip_route_add "$ip" "$local_vpn_ip" + done +} diff --git a/zsh/functions/vpn_add_routes b/zsh/functions/vpn_add_routes new file mode 100644 index 0000000..540d6b8 --- /dev/null +++ b/zsh/functions/vpn_add_routes @@ -0,0 +1,49 @@ +#!/usr/bin/env zsh + +function vpn_add_routes() { + local now=$(date +"%Y%m%d%H%M%S") + + local file=${1:=$(last_backup_version vpn-routes csv)} + [ -z "$file" ] && echo "no vpn-routes file found" && return + local new_file=$(echo $file | sed "s/[0-9]\+/${now}/g") + local total=$(wc -l < "$file") + + echo "🛡️ adding my routes from $file to VPN ($total)" + + local local_vpn_ip=${2:=$(vpn_ip)} + [ -z $local_vpn_ip ] && echo "VPN IP not found" && return + + local count=0 + + sudo echo "you give root permission" + + cat $file | while read -r line; do + ((count=count+1)) + + if [[ `which_shell` == "zsh" ]]; then + local parts=("${(@s/;/)line}") + local host=${parts[1]} + local up_at=${parts[2]} + local down_at=${parts[3]} + else + IFS=';' read -r -a parts <<<"$line" + local host=${parts[0]} + local up_at=${parts[1]} + local down_at=${parts[2]} + fi + + [ "$down_at" != "" ] \ + && echo $line | tee -a $new_file &>/dev/null \ + && continue + + vpn_add_route $host + + if [ $? -eq 0 ]; then + echo $host";"$now";" | tee -a $new_file &>/dev/null + else + echo $host";"$up_at";"$now | tee -a $new_file &>/dev/null + fi + + [ `progress_bar` ] && progress_bar $count $total "$host" + done +} diff --git a/zsh/functions/vpn_get_ips b/zsh/functions/vpn_get_ips new file mode 100644 index 0000000..854dddb --- /dev/null +++ b/zsh/functions/vpn_get_ips @@ -0,0 +1,9 @@ +#!/usr/bin/env zsh + +function vpn_get_ips() { + local cmd="nslookup $1 | grep -A 10 'Non-authoritative answer' | \ + grep Address | cut -d' ' -f2" + # echo "$cmd" + eval $cmd +} + diff --git a/zsh/functions/vpn_ip b/zsh/functions/vpn_ip new file mode 100644 index 0000000..049de48 --- /dev/null +++ b/zsh/functions/vpn_ip @@ -0,0 +1,5 @@ +#!/usr/bin/env zsh + +function vpn_ip() { + ip -o addr show up type ppp | /bin/awk '{print $4}' +} diff --git a/zsh/functions/vpn_ip_route_add b/zsh/functions/vpn_ip_route_add new file mode 100644 index 0000000..b17d150 --- /dev/null +++ b/zsh/functions/vpn_ip_route_add @@ -0,0 +1,8 @@ +#!/usr/bin/env zsh + +function vpn_ip_route_add() { + local source_net=$(vpn_ip_subnet $1) + local cmd="sudo ip route add $source_net via $2" + # echo "$cmd" + eval $cmd 2>/dev/null +} diff --git a/zsh/functions/vpn.zsh b/zsh/functions/vpn_ip_subnet old mode 100755 new mode 100644 similarity index 99% rename from zsh/functions/vpn.zsh rename to zsh/functions/vpn_ip_subnet index 1938402..6b3a5a2 --- a/zsh/functions/vpn.zsh +++ b/zsh/functions/vpn_ip_subnet @@ -1,3 +1,5 @@ +#!/usr/bin/env zsh + function vpn_get_ips() { local cmd="nslookup $1 | grep -A 10 'Non-authoritative answer' | \ grep Address | cut -d' ' -f2" diff --git a/zsh/functions/vscode_sanitize b/zsh/functions/vscode_sanitize old mode 100755 new mode 100644 index 661a6e7..cf9a2bc --- a/zsh/functions/vscode_sanitize +++ b/zsh/functions/vscode_sanitize @@ -1,5 +1,4 @@ - - +#!/usr/bin/env zsh function vscode_sanitize() { /bin/rm -rf ~/.config/Code/Backups diff --git a/zsh/functions/wallpapers_reindex b/zsh/functions/wallpapers_reindex old mode 100755 new mode 100644 index 373b82e..6632eea --- a/zsh/functions/wallpapers_reindex +++ b/zsh/functions/wallpapers_reindex @@ -1,5 +1,4 @@ - - +#!/usr/bin/env zsh function wallpapers_reindex() { sh $SYNC_DOTFILES/Pictures/Wallpapers/ubuntu-wallpaper-generator $SYNC_DOTFILES/Pictures/Wallpapers diff --git a/zsh/functions/weather_by_lat_lon b/zsh/functions/weather_by_lat_lon index aee11d1..1a4b439 100644 --- a/zsh/functions/weather_by_lat_lon +++ b/zsh/functions/weather_by_lat_lon @@ -1,7 +1,8 @@ #!/usr/bin/env zsh function weather_by_lat_lon() { - lat_lon=$(my_lat_lon) + # lat_lon=$(my_lat_lon) + lat_lon=$LATLON curl -H 'Accept-Language: pt-br' "wttr.in/${lat_lon}?m2AFnq&format=3" # curl -H 'Accept-Language: pt-br' "wttr.in/${lat_lon}?format='+%c%20%t%60%w&period=60'" # curl -s wttr.in/London:Stockholm:Moscow\?format\="%l:+%c%20%t%60%w&period=60" diff --git a/zsh/functions/zsh_plugins_install b/zsh/functions/zsh_plugins_install old mode 100755 new mode 100644 diff --git a/zsh/functions/zsh_plugins_list b/zsh/functions/zsh_plugins_list old mode 100755 new mode 100644 diff --git a/zsh/functions/zsh_plugins_load b/zsh/functions/zsh_plugins_load old mode 100755 new mode 100644