From aefd589e0df6de3a353e4d94bad07602096b9969 Mon Sep 17 00:00:00 2001 From: ViViDboarder Date: Thu, 23 Mar 2017 15:42:54 -0700 Subject: [PATCH] Refactor and clean up of some of the fish and compilation stuffs --- assets/default/dotfiles/bashrc | 29 +++--- assets/default/fish/.gitignore | 1 + .../pkg/force => fish}/completions/force.fish | 2 + .../pkg/port => fish}/completions/port.fish | 0 .../fish/functions/fish_prompt.fish | 0 .../fish/functions/fish_right_prompt.fish | 0 .../functions/source_synced.fish} | 6 +- assets/default/fish/init.fish | 5 + .../fisherman => fish}/init/alias.fish | 0 .../fisherman => fish}/init/paths.fish | 38 ++++---- assets/default/fisherman/.gitignore | 5 - master-cookbook | 83 +++++----------- no-sudo | 96 +++++++------------ recipes/default/build-fish | 14 +++ recipes/default/{neovim => build-neovim} | 0 .../{compile-install-vim => build-vim} | 0 recipes/default/fish | 5 + recipes/default/fish-install | 5 - recipes/default/fisherman | 16 +--- recipes/default/packages | 2 +- recipes/no-sudo/{fish-install => build-fish} | 0 recipes/no-sudo/{mosh-install => build-mosh} | 0 recipes/no-sudo/{tmux-install => build-tmux} | 0 .../{compile-install-vim => build-vim} | 0 24 files changed, 133 insertions(+), 174 deletions(-) create mode 100644 assets/default/fish/.gitignore rename assets/default/{oh-my-fish/pkg/force => fish}/completions/force.fish (94%) rename assets/default/{oh-my-fish/pkg/port => fish}/completions/port.fish (100%) rename assets/default/{fisherman => }/fish/functions/fish_prompt.fish (100%) rename assets/default/{fisherman => }/fish/functions/fish_right_prompt.fish (100%) rename assets/default/{fisherman/fish/functions/source_config.fish => fish/functions/source_synced.fish} (60%) create mode 100644 assets/default/fish/init.fish rename assets/default/{fisherman/fisherman => fish}/init/alias.fish (100%) rename assets/default/{fisherman/fisherman => fish}/init/paths.fish (67%) delete mode 100644 assets/default/fisherman/.gitignore create mode 100644 recipes/default/build-fish rename recipes/default/{neovim => build-neovim} (100%) rename recipes/default/{compile-install-vim => build-vim} (100%) create mode 100644 recipes/default/fish delete mode 100644 recipes/default/fish-install rename recipes/no-sudo/{fish-install => build-fish} (100%) rename recipes/no-sudo/{mosh-install => build-mosh} (100%) rename recipes/no-sudo/{tmux-install => build-tmux} (100%) rename recipes/no-sudo/{compile-install-vim => build-vim} (100%) diff --git a/assets/default/dotfiles/bashrc b/assets/default/dotfiles/bashrc index d73b0c0..fd1c996 100644 --- a/assets/default/dotfiles/bashrc +++ b/assets/default/dotfiles/bashrc @@ -20,21 +20,14 @@ if [ -d /opt/local ]; then export PATH=/opt/local/bin:/opt/local/sbin:$PATH fi -export GOROOT=/usr/local/go -if [ -d "$GOROOT" ]; then - export PATH=$PATH:$GOROOT/bin -fi - if [[ "$DET_OS" == "linux" ]]; then ANDROID_SDK=$HOME/workspace/adt-bundle-linux/sdk elif [[ "$DET_OS" == "mac" ]]; then ANDROID_SDK=$HOME/workspace/android-sdk-macosx - go_workspace=$HOME/workspace/go_workspace - if [ -d "$go_workspace" ]; then - export GOPATH=$go_workspace - export PATH=$PATH:$GOPATH/bin - fi + # Set GOPATH + GOROOT=/opt/local/lib/go + GOPATH=$HOME/workspace/go_path # Fix Python path on OSX to avoid considering System extras over newer versions # export PATH=$HOME/Library/Python/2.7/bin:$PATH @@ -43,8 +36,20 @@ elif [[ "$DET_OS" == "mac" ]]; then fi # Android paths -export ANDROID_HOME=$ANDROID_SDK -export PATH=$PATH:$ANDROID_SDK/platform-tools:$ANDROID_SDK/tools +if [ -d "$ANDROID_SDK" ]; then + export ANDROID_HOME=$ANDROID_SDK + export PATH=$PATH:$ANDROID_SDK/platform-tools:$ANDROID_SDK/tools +fi + +# Go paths +if [ -d "$GOPATH" ]; then + export GOPATH + export PATH=$PATH:$GOPATH/bin +fi +if [ -d "$GOROOT" ]; then + export GOROOT + export PATH=$PATH:$GOROOT/bin +fi # Home path export PATH=$HOME/bin:$PATH diff --git a/assets/default/fish/.gitignore b/assets/default/fish/.gitignore new file mode 100644 index 0000000..80bc646 --- /dev/null +++ b/assets/default/fish/.gitignore @@ -0,0 +1 @@ +*.local.fish diff --git a/assets/default/oh-my-fish/pkg/force/completions/force.fish b/assets/default/fish/completions/force.fish similarity index 94% rename from assets/default/oh-my-fish/pkg/force/completions/force.fish rename to assets/default/fish/completions/force.fish index ccab2a3..4e84e7a 100644 --- a/assets/default/oh-my-fish/pkg/force/completions/force.fish +++ b/assets/default/fish/completions/force.fish @@ -1,3 +1,5 @@ +# Completions for the Force.com cli + function __fish_force_needs_command set cmd (commandline -opc) if [ (count $cmd) -eq 1 -a $cmd[1] = 'force' ] diff --git a/assets/default/oh-my-fish/pkg/port/completions/port.fish b/assets/default/fish/completions/port.fish similarity index 100% rename from assets/default/oh-my-fish/pkg/port/completions/port.fish rename to assets/default/fish/completions/port.fish diff --git a/assets/default/fisherman/fish/functions/fish_prompt.fish b/assets/default/fish/functions/fish_prompt.fish similarity index 100% rename from assets/default/fisherman/fish/functions/fish_prompt.fish rename to assets/default/fish/functions/fish_prompt.fish diff --git a/assets/default/fisherman/fish/functions/fish_right_prompt.fish b/assets/default/fish/functions/fish_right_prompt.fish similarity index 100% rename from assets/default/fisherman/fish/functions/fish_right_prompt.fish rename to assets/default/fish/functions/fish_right_prompt.fish diff --git a/assets/default/fisherman/fish/functions/source_config.fish b/assets/default/fish/functions/source_synced.fish similarity index 60% rename from assets/default/fisherman/fish/functions/source_config.fish rename to assets/default/fish/functions/source_synced.fish index 78b7644..e9cb827 100644 --- a/assets/default/fisherman/fish/functions/source_config.fish +++ b/assets/default/fish/functions/source_synced.fish @@ -1,7 +1,7 @@ -function source_config +function source_synced # Sources a config file and corresponding local config file if it exists - set shared_config "$fisher_config/init/$argv[1].fish" - set local_config "$fisher_config/init/$argv[1].local.fish" + set -l shared_config "$fish_synced_dir/$argv[1].fish" + set -l local_config "$fish_synced_dir/$argv[1].local.fish" if test -f "$shared_config" source "$shared_config" end diff --git a/assets/default/fish/init.fish b/assets/default/fish/init.fish new file mode 100644 index 0000000..b2028f2 --- /dev/null +++ b/assets/default/fish/init.fish @@ -0,0 +1,5 @@ +set -gx fish_function_path "$fish_synced_dir/functions" $fish_function_path +set -gx fish_complete_path "$fish_synced_dir/completions" $fish_complete_path + +source_synced 'init/alias' +source_synced 'init/paths' diff --git a/assets/default/fisherman/fisherman/init/alias.fish b/assets/default/fish/init/alias.fish similarity index 100% rename from assets/default/fisherman/fisherman/init/alias.fish rename to assets/default/fish/init/alias.fish diff --git a/assets/default/fisherman/fisherman/init/paths.fish b/assets/default/fish/init/paths.fish similarity index 67% rename from assets/default/fisherman/fisherman/init/paths.fish rename to assets/default/fish/init/paths.fish index 1c99844..db6efc6 100644 --- a/assets/default/fisherman/fisherman/init/paths.fish +++ b/assets/default/fish/init/paths.fish @@ -14,37 +14,35 @@ if [ -d /opt/local ] set -gx PATH /opt/local/bin /opt/local/sbin $PATH end -# Google GO -set -gx GOROOT /usr/local/go -if [ -d "$GOROOT" ] - set -gx PATH $PATH $GOROOT/bin -end - if [ $det_os = "linux" ] set android_sdk $HOME/workspace/adt-bundle-linux/sdk else if [ $det_os = "mac" ] set android_sdk $HOME/workspace/android-sdk-macosx - set go_workspace $HOME/workspace/go_workspace - if [ -d "$go_workspace" ] - set -gx GOPATH $go_workspace - set -gx PATH $PATH $GOPATH/bin - end + # Set go paths + set goroot /opt/local/lib/go + set gopath $HOME/workspace/go_path # set PATH $HOME/Library/Python/2.7/bin $PATH # Fix Python path on OSX to avoid considering System extras over newer versions set -gx PYTHONPATH /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages /Library/Python/2.7/site-packages $PYTHONPATH end -# Google cloud sdk -# set sdk_dir "$HOME/workspace/google-cloud-sdk" -# set bin_path "$sdk_dir/bin" -# set -gx PATH $bin_path $PATH -# set -gx PYTHONPATH "$sdk_dir/platform/google_appengine" $PYTHONPATH +# Google GO +if [ -d "$goroot" ] + set -gx GOROOT $goroot + set -gx PATH $PATH $GOROOT/bin +end +if [ -d "$gopath" ] + set -gx GOPATH $gopath + set -gx PATH $PATH $GOPATH/bin +end # Android paths -set -gx ANDROID_HOME $android_sdk -set -gx PATH $PATH $android_sdk/platform-tools $android_sdk/tools +if [ -d "$android_sdk" ] + set -gx ANDROID_HOME $android_sdk + set -gx PATH $PATH $android_sdk/platform-tools $android_sdk/tools +end # Home path set -gx PATH $HOME/bin $PATH @@ -53,3 +51,7 @@ set -gx PATH $HOME/bin $PATH # Increase memory sizes for java using Ant set -gx ANT_OPTS "-Xmx2048m -Xms512m" + +# FZF +set -gx FZF_DEFAULT_COMMAND 'ag -g ""' +set -gx FZF_CTRL_T_COMMAND "$FZF_DEFAULT_COMMAND \$dir" diff --git a/assets/default/fisherman/.gitignore b/assets/default/fisherman/.gitignore deleted file mode 100644 index 0ac9a30..0000000 --- a/assets/default/fisherman/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -cache/ -fisherman/init/*.local.fish -fisherman/completions/* -fisherman/functions/* -fisherman/man/* diff --git a/master-cookbook b/master-cookbook index 607016f..51ae764 100755 --- a/master-cookbook +++ b/master-cookbook @@ -21,24 +21,23 @@ if ! is_installed "packages" || prompt_yn "Reinstall packages?" ; then install_packages=true fi -install_vim_src=false +build_vim=false if [ "$PACKAGE_MANAGER" == 'apt-get' ]; then # Optional - is_installed "vim-from-source" + is_installed "build-vim" if prompt_yn "Compile vim?" ; then - install_vim_src=true + build_vim=true fi fi -install_neovim=false -is_installed "neovim" -if prompt_yn "Install Neovim?" ; then - install_neovim=true +build_neovim=false +if ! command_exist 'nvim' && prompt_yn "Build Neovim?" ; then + build_neovim=true fi -install_vim_settings=false -if ! is_installed "vim-settings" || prompt_yn "Reinstall vim-settings?" ; then - install_vim_settings=true +build_fish=false +if ! command_exist 'fish' && prompt_yn "Build Fish?" ; then + build_fish=true fi # Optional @@ -55,49 +54,34 @@ if prompt_yn "Install Go?" ; then install_golang=true fi -# Optional -install_fish=false -install_ohmyfish=false -install_fisherman=false -is_installed "fish" -is_installed "oh-my-fish" -is_installed "fisherman" -if prompt_yn "Install fish?" ; then - install_fish=true - - if prompt_yn "Install oh-my-fish?" ; then - install_ohmyfish=true - elif prompt_yn "Install Fisherman?" ; then - install_fisherman=true - fi -fi - ### Run recipes -recipe 'dotfiles' -recipe 'bin' -recipe 'git' - -git submodule init -git submodule update - if $install_packages ; then recipe 'packages' set_installed "packages" fi -if $install_vim_src ; then - recipe 'compile-install-vim' - set_installed "vim-from-source" +recipe 'dotfiles' +recipe 'bin' +recipe 'git' +recipe 'vim-settings' +recipe 'fish' + +git submodule init +git submodule update + +if $build_vim ; then + recipe 'build-vim' + set_installed "build-vim" fi -if $install_neovim ; then - recipe 'neovim' +if $build_neovim ; then + recipe 'build-neovim' set_installed "neovim" fi -if $install_vim_settings ; then - recipe 'vim-settings' - set_installed 'vim-settings' +if $build_fish ; then + recipe 'build-fish' + set_installed "build-fish" fi if $install_sfdc ; then @@ -110,21 +94,6 @@ if $install_golang ; then set_installed 'golang' fi -if $install_fish ; then - recipe 'fish-install' - set_installed 'fish' -fi - -if $install_ohmyfish ; then - recipe 'oh-my-fish' - set_installed 'oh-my-fish' -fi - -if $install_fisherman ; then - recipe 'fisherman' - set_installed 'fisherman' -fi - ### Show the Finished banner finished diff --git a/no-sudo b/no-sudo index cdc13bf..c801d16 100755 --- a/no-sudo +++ b/no-sudo @@ -13,59 +13,41 @@ PROJECT_DIR=$(pwd) init_paths_and_vars -install_vim_src=false -is_installed "vim-from-source" -if prompt_yn "Compile vim?" ; then - install_vim_src=true -fi -install_vim_settings=false -if ! is_installed "vim-settings" || prompt_yn "Reinstall vim-settings?" ; then - install_vim_settings=true +build_vim=false +is_installed "build-vim" +if prompt_yn "Build Vim from source?" ; then + build_vim=true fi + install_sfdc=false -is_installed "salesforce" -if prompt_yn "Install Salesforce tools?" ; then +if is_installed "salesforce" || prompt_yn "Install Salesforce tools?" ; then install_sfdc=true fi -install_mosh=false -is_installed "mosh" -if prompt_yn "Install Mosh from source?" ; then - install_mosh=true -fi -install_tmux=false -is_installed "tmux" -if prompt_yn "Install tmux from source?" ; then - install_tmux=true -fi -install_fish=false -install_ohmyfish=false -install_fisherman=false -is_installed "fish" -is_installed "oh-my-fish" -is_installed "fisherman" -if prompt_yn "Install fish?" ; then - install_fish=true - if prompt_yn "Install oh-my-fish?" ; then - install_ohmyfish=true - elif prompt_yn "Install Fisherman?" ; then - install_fisherman=true - fi +build_mosh=false +if ! command_exist 'mosh' && prompt_yn "Install Mosh from source?" ; then + build_mosh=true +fi + +build_tmux=false +if ! command_exist 'tmux' && prompt_yn "Install tmux from source?" ; then + build_tmux=true +fi + +build_fish=false +if ! command_exist 'fish' && prompt_yn "Install fish?" ; then + build_fish=true fi ### Run recipes recipe 'dotfiles' recipe 'bin' recipe 'git' +recipe 'vim-settings' -if $install_vim_src ; then - recipe 'compile-install-vim' - set_installed "vim-from-source" -fi - -if $install_vim_settings ; then - recipe 'vim-settings' - set_installed 'vim-settings' +if $build_vim ; then + recipe 'build-vim' + set_installed "build-vim" fi if $install_sfdc ; then @@ -73,33 +55,23 @@ if $install_sfdc ; then set_installed 'salesforce' fi -if $install_mosh ; then - recipe 'mosh' - set_installed 'mosh-install' +if $build_mosh ; then + recipe 'build-mosh' + set_installed 'build-mosh' fi -if $install_tmux ; then - recipe 'tmux-install' - set_installed 'tmux' +if $build_tmux ; then + recipe 'build-tmux' + set_installed 'build-tmux' fi -if $install_fish ; then - if ! command_exist fish ; then - recipe 'fish-install' - fi - if command_exist fish ; then - set_installed 'fish' - fi +if $build_fish ; then + recipe 'build-fish' + set_installed "build-fish" fi -if $install_ohmyfish ; then - recipe 'oh-my-fish' - set_installed 'oh-my-fish' -fi - -if $install_fisherman ; then - recipe 'fisherman' - set_installed 'fisherman' +if command_exist 'fish' || is_installed 'build-fish' ; then + recipe 'fish' fi ### Show the Finished banner diff --git a/recipes/default/build-fish b/recipes/default/build-fish new file mode 100644 index 0000000..7600736 --- /dev/null +++ b/recipes/default/build-fish @@ -0,0 +1,14 @@ +#! /bin/bash + +log "Compiling and installing fish-shell" + +local fish_shell_dir=$WORKSPACE/fish-shell + +if [ ! -d $fish_shell_dir ]; then + log "Cloning fish-shell" + git clone https://github.com/fish-shell/fish-shell $fish_shell_dir +else + (cd $fish_shell_dir && git pull) +fi + +(cd $fish_shell_dir && ./configure && make && sudo make install) diff --git a/recipes/default/neovim b/recipes/default/build-neovim similarity index 100% rename from recipes/default/neovim rename to recipes/default/build-neovim diff --git a/recipes/default/compile-install-vim b/recipes/default/build-vim similarity index 100% rename from recipes/default/compile-install-vim rename to recipes/default/build-vim diff --git a/recipes/default/fish b/recipes/default/fish new file mode 100644 index 0000000..edb4bcc --- /dev/null +++ b/recipes/default/fish @@ -0,0 +1,5 @@ +#! /bin/bash + +try_link $DEFAULT_ASSETS_PATH $XDG_CONFIG_HOME/fish/synced +add_line "set -gx fish_synced_dir $XDG_CONFIG_HOME/fish/synced " $XDG_CONFIG_HOME/fish/config.fish +add_line "source $XDG_CONFIG_HOME/fish/synced/init.fish " $XDG_CONFIG_HOME/fish/config.fish diff --git a/recipes/default/fish-install b/recipes/default/fish-install deleted file mode 100644 index f46e3fe..0000000 --- a/recipes/default/fish-install +++ /dev/null @@ -1,5 +0,0 @@ -#! /bin/bash - -if ! command_exist fish ; then - sudo_package 'fish' -fi diff --git a/recipes/default/fisherman b/recipes/default/fisherman index c3ed031..6f435aa 100644 --- a/recipes/default/fisherman +++ b/recipes/default/fisherman @@ -1,17 +1,11 @@ #! /bin/bash -if [ ! -d "$fisher_home" ]; then - curl -L install.fisherman.sh | fish -fi +# Install fisherman +curl -Lo ~/.config/fish/functions/fisher.fish --create-dirs git.io/fisher +# Link fisher configs rm -fr "$XDG_CONFIG_HOME/fisherman" try_link "${DEFAULT_ASSETS_PATH}/fisherman" "$XDG_CONFIG_HOME/fisherman" -add_line "source_config paths" $XDG_CONFIG_HOME/fish/config.fish -add_line "source_config alias" $XDG_CONFIG_HOME/fish/config.fish - -# Link functions -mkdir -p $XDG_CONFIG_HOME/fish/functions -for func in ${DEFAULT_ASSETS_PATH}/fish/functions/*.fish; do - try_link "$func" $XDG_CONFIG_HOME/fish/functions/$(basename $func) -done +# Install from fishfile +fish -c 'fisher; exit' diff --git a/recipes/default/packages b/recipes/default/packages index a648f01..dfc810a 100644 --- a/recipes/default/packages +++ b/recipes/default/packages @@ -1,7 +1,7 @@ #! /bin/bash sudo_package_update -sudo_package 'screen tmux htop curl wget mercurial ctags tig pv jq' +sudo_package 'tmux htop curl wget mercurial ctags tig pv jq fish mosh' # Manager specific packages case "$PACKAGE_MANAGER" in diff --git a/recipes/no-sudo/fish-install b/recipes/no-sudo/build-fish similarity index 100% rename from recipes/no-sudo/fish-install rename to recipes/no-sudo/build-fish diff --git a/recipes/no-sudo/mosh-install b/recipes/no-sudo/build-mosh similarity index 100% rename from recipes/no-sudo/mosh-install rename to recipes/no-sudo/build-mosh diff --git a/recipes/no-sudo/tmux-install b/recipes/no-sudo/build-tmux similarity index 100% rename from recipes/no-sudo/tmux-install rename to recipes/no-sudo/build-tmux diff --git a/recipes/no-sudo/compile-install-vim b/recipes/no-sudo/build-vim similarity index 100% rename from recipes/no-sudo/compile-install-vim rename to recipes/no-sudo/build-vim