diff --git a/toCopy/gitconfig b/copy/gitconfig similarity index 100% rename from toCopy/gitconfig rename to copy/gitconfig diff --git a/toCopy/gitignore b/copy/gitignore similarity index 100% rename from toCopy/gitignore rename to copy/gitignore diff --git a/toCopy/sshconfig b/copy/sshconfig similarity index 100% rename from toCopy/sshconfig rename to copy/sshconfig diff --git a/install b/install index 4cc8697..f5fe482 100755 --- a/install +++ b/install @@ -14,10 +14,10 @@ echo ">>> Installing Linuxbrew - Please Wait! <<<" [[ ! -d "/home/linuxbrew/.linuxbrew" ]] && ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/install)" && echo "> Linuxbrew installed" || echo "> Linuxbrew already installed" echo ">>> Copying Gitconfig - Please Wait! <<<" -sudo cp ${HOME}/.config/dotfiles/toCopy/gitconfig /etc/gitconfig +sudo cp ${HOME}/.config/dotfiles/copy/gitconfig /etc/gitconfig echo ">>> Copying Gitignore - Please Wait! <<<" -sudo cp ${HOME}/.config/dotfiles/toCopy/gitignore /etc/gitignore +sudo cp ${HOME}/.config/dotfiles/copy/gitignore /etc/gitignore echo ">>> Copying SSH Config - Please Wait! <<<" -sudo cp ${HOME}/.config/dotfiles/toCopy/sshconfig /etc/ssh/ssh_config +sudo cp ${HOME}/.config/dotfiles/copy/sshconfig /etc/ssh/ssh_config diff --git a/zsh/.zshrc b/zsh/.zshrc index 0272d80..1aee8bb 100644 --- a/zsh/.zshrc +++ b/zsh/.zshrc @@ -1,36 +1,24 @@ -if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then - source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" +if [[ -r "$HOME/.cache/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then + source "$HOME/.cache/p10k-instant-prompt-${(%):-%n}.zsh" fi -source "$ZDOTDIR/libraries/export.zsh" -source "$ZDOTDIR/libraries/dircolor.zsh" +source $ZDOTDIR/exports.zsh +source $ZDOTDIR/dircolor.zsh -source "/usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh" -source "/usr/share/zsh-theme-powerlevel10k/powerlevel10k.zsh-theme" +source $share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh +source $share/zsh-theme-powerlevel10k/powerlevel10k.zsh-theme autoload -Uz compinit if [[ -n $HOME/.cache/zsh/compdump(#qN.mh+24) ]]; then compinit -d $HOME/.cache/zsh/compdump; else compinit -d $HOME/.cache/zsh/compdump -C; fi -for file in $ZDOTDIR/libraries/source/*.zsh; do source "$file"; done -for file in $ZDOTDIR/libraries/plugins/*.zsh; do source "$file"; done +for file in $ZDOTDIR/libs/*.zsh; do source "$file"; done +for file in $ZDOTDIR/plgs/*.zsh; do source "$file"; done -source "/usr/share/fzf/completion.zsh" -source "/usr/share/fzf/key-bindings.zsh" -source "/usr/share/doc/pkgfile/command-not-found.zsh" -source "$ZDOTDIR/libraries/tmux/tmux.zsh" - -# Use lf to switch directories and bind it to ctrl-o -lfcd () { - tmp="$(mktemp)" - lf -last-dir-path="$tmp" "$@" - if test -f "$tmp"; then - dir="$(cat "$tmp")" - rm -f "$tmp" - [ -d "$dir" ] && [ "$dir" != "$(pwd)" ] && cd "$dir" - fi -} -bindkey -s '^o' 'lfcd\n' +source $fzf/completion.zsh +source $fzf/key-bindings.zsh +source $share/doc/pkgfile/command-not-found.zsh +source $ZDOTDIR/tmux/tmux.zsh [[ ! -f $ZDOTDIR/.p10k.zsh ]] || source $ZDOTDIR/.p10k.zsh -source "/usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" +source $share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh diff --git a/zsh/libraries/dircolor.zsh b/zsh/dircolor.zsh similarity index 100% rename from zsh/libraries/dircolor.zsh rename to zsh/dircolor.zsh diff --git a/zsh/libraries/export.zsh b/zsh/exports.zsh similarity index 87% rename from zsh/libraries/export.zsh rename to zsh/exports.zsh index 21c30e9..3f2bc32 100644 --- a/zsh/libraries/export.zsh +++ b/zsh/exports.zsh @@ -1,8 +1,8 @@ -# Local Path Additions +#local export path=($path $HOME/.config/dotfiles/bin /opt/phalcon-devtools) export PTOOLSPATH="/opt/phalcon-devtools/" -# Stuff for Homebrew +#homebrew export path=($path /home/linuxbrew/.linuxbrew/{sbin,bin}) export fpath=($fpath /home/linuxbrew/.linuxbrew/share/zsh/site-functions) export manpath=($manpath /home/linuxbrew/.linuxbrew/share/man) @@ -13,3 +13,6 @@ export XDG_DATA_DIRS=($XDG_DATA_DIRS /home/linuxbrew/.linuxbrew/share) export GEM_HOME=$(ruby -e 'print Gem.user_dir') export path=($path $GEM_HOME/bin) +#share +export share="/usr/share" +export fzf="$share/fzf" diff --git a/zsh/libraries/source/clipboard.zsh b/zsh/libs/clipboard.zsh similarity index 100% rename from zsh/libraries/source/clipboard.zsh rename to zsh/libs/clipboard.zsh diff --git a/zsh/libraries/source/completion.zsh b/zsh/libs/completion.zsh similarity index 100% rename from zsh/libraries/source/completion.zsh rename to zsh/libs/completion.zsh diff --git a/zsh/libraries/source/directories.zsh b/zsh/libs/directories.zsh similarity index 100% rename from zsh/libraries/source/directories.zsh rename to zsh/libs/directories.zsh diff --git a/zsh/libraries/source/functions.zsh b/zsh/libs/functions.zsh similarity index 100% rename from zsh/libraries/source/functions.zsh rename to zsh/libs/functions.zsh diff --git a/zsh/libraries/source/grep.zsh b/zsh/libs/grep.zsh similarity index 100% rename from zsh/libraries/source/grep.zsh rename to zsh/libs/grep.zsh diff --git a/zsh/libraries/source/history.zsh b/zsh/libs/history.zsh similarity index 100% rename from zsh/libraries/source/history.zsh rename to zsh/libs/history.zsh diff --git a/zsh/libraries/source/key-bindings.zsh b/zsh/libs/key-bindings.zsh similarity index 100% rename from zsh/libraries/source/key-bindings.zsh rename to zsh/libs/key-bindings.zsh diff --git a/zsh/libraries/source/misc.zsh b/zsh/libs/misc.zsh similarity index 100% rename from zsh/libraries/source/misc.zsh rename to zsh/libs/misc.zsh diff --git a/zsh/libraries/source/termsupport.zsh b/zsh/libs/termsupport.zsh similarity index 100% rename from zsh/libraries/source/termsupport.zsh rename to zsh/libs/termsupport.zsh diff --git a/zsh/libraries/plugins/aliases.zsh b/zsh/plgs/aliases.zsh similarity index 100% rename from zsh/libraries/plugins/aliases.zsh rename to zsh/plgs/aliases.zsh diff --git a/zsh/plgs/appup.zsh b/zsh/plgs/appup.zsh new file mode 100644 index 0000000..6670696 --- /dev/null +++ b/zsh/plgs/appup.zsh @@ -0,0 +1,117 @@ +# Docker +_appup_docker () { + if hash docker-compose >/dev/null 2>&1; then + # Check if docker-machine has been started + if hash docker-machine >/dev/null 2>&1; then + if docker-machine status | grep -qi "Stopped"; then + read -q "REPLY?Docker Machine is not running, would you like to start it? [y/n] " + echo "" + + if [[ "$REPLY" == "y" ]]; then + docker-machine start default && eval $(docker-machine env default) + echo "" + else + return + fi + fi + fi + + # Check YAML extension + compose_file='' + compose_project_file='' + + if [ -e "docker-compose.yml" ]; then + compose_file='docker-compose.yml' + elif [ -e "docker-compose.yaml" ]; then + compose_file='docker-compose.yaml' + fi + + # will look for docker-compose..yml + if [ -n "$2" ]; then + if [ -e "docker-compose.$2.yml" ]; then + compose_project_file="docker-compose.$2.yml" + elif [ -e "docker-compose.$2.yaml" ]; then + compose_project_file="docker-compose.$2.yaml" + fi + + if [ -n "$compose_project_file" ]; then + # Override project name from custom env + if [ -e ".env.$2" ]; then + project=$(source ".env.$2"; echo $COMPOSE_PROJECT_NAME) + + if [ -n $project ]; then + docker-compose -p "${project}" -f "$compose_file" -f "$compose_project_file" $1 "${@:3}" + return + fi + fi + + docker-compose -f "$compose_file" -f "$compose_project_file" $1 "${@:3}" + return + fi + fi + + docker-compose $1 "${@:2}" + else + echo >&2 "Docker compose file found but docker-compose is not installed." + fi +} + +# Vagrant +_appup_vagrant () { + if hash vagrant >/dev/null 2>&1; then + vagrant $1 "${@:2}" + else + echo >&2 "Vagrant file found but vagrant is not installed." + fi +} + +up () { + if [ -e "docker-compose.yml" ] || [ -e "docker-compose.yaml" ]; then + _appup_docker up "$@" + elif [ -e "Vagrantfile" ]; then + _appup_vagrant up "$@" + elif hash up >/dev/null 2>&1; then + env up "$@" + fi +} + +down () { + if [ -e "docker-compose.yml" ] || [ -e "docker-compose.yaml" ]; then + _appup_docker down "$@" + elif [ -e "Vagrantfile" ]; then + _appup_vagrant destroy "$@" + elif hash down >/dev/null 2>&1; then + env down "$@" + fi +} + +start () { + if [ -e "docker-compose.yml" ] || [ -e "docker-compose.yaml" ]; then + _appup_docker start "$@" + elif [ -e "Vagrantfile" ]; then + _appup_vagrant up "$@" + elif hash start >/dev/null 2>&1; then + env start "$@" + fi +} + +restart () { + if [ -e "docker-compose.yml" ] || [ -e "docker-compose.yaml" ]; then + _appup_docker restart "$@" + elif [ -e "Vagrantfile" ]; then + _appup_vagrant reload "$@" + elif hash start >/dev/null 2>&1; then + env start "$@" + fi +} + +stop () { + if [ -e "docker-compose.yml" ] || [ -e "docker-compose.yaml" ]; then + _appup_docker stop "$@" + elif [ -e "Vagrantfile" ]; then + _appup_vagrant halt "$@" + elif hash stop >/dev/null 2>&1; then + env stop "$@" + fi +} + diff --git a/zsh/libraries/plugins/extract.zsh b/zsh/plgs/extract.zsh similarity index 100% rename from zsh/libraries/plugins/extract.zsh rename to zsh/plgs/extract.zsh diff --git a/zsh/libraries/plugins/gitignore.zsh b/zsh/plgs/gitignore.zsh similarity index 100% rename from zsh/libraries/plugins/gitignore.zsh rename to zsh/plgs/gitignore.zsh diff --git a/zsh/libraries/plugins/systemctl.zsh b/zsh/plgs/systemctl.zsh similarity index 100% rename from zsh/libraries/plugins/systemctl.zsh rename to zsh/plgs/systemctl.zsh diff --git a/zsh/libraries/tmux/tmux-extra.conf b/zsh/tmux/tmux-extra.conf similarity index 100% rename from zsh/libraries/tmux/tmux-extra.conf rename to zsh/tmux/tmux-extra.conf diff --git a/zsh/libraries/tmux/tmux.conf b/zsh/tmux/tmux.conf similarity index 100% rename from zsh/libraries/tmux/tmux.conf rename to zsh/tmux/tmux.conf diff --git a/zsh/libraries/tmux/tmux.zsh b/zsh/tmux/tmux.zsh similarity index 100% rename from zsh/libraries/tmux/tmux.zsh rename to zsh/tmux/tmux.zsh