From f344f2e370fbf88a0306b6a01c99f386a13953c7 Mon Sep 17 00:00:00 2001 From: William Carroll Date: Fri, 23 Jun 2017 13:01:16 -0400 Subject: [PATCH] Adds os detection for bootstrapping configs --- configs/{ => linux}/.xinitrc | 0 configs/{ => os_x}/.slate.js | 0 configs/setup_configs.sh | 87 ++++++++----------- configs/{ => shared}/.ctags | 0 configs/{ => shared}/.emacs | 5 +- configs/{ => shared}/.tmux.conf | 0 configs/{ => shared}/.vimrc | 0 configs/{ => shared}/.zsh_profile | 0 emacs/wc-ansi-term-functions.el | 11 +++ ...ux-256color-italic => tmux-256color-italic | 0 10 files changed, 50 insertions(+), 53 deletions(-) rename configs/{ => linux}/.xinitrc (100%) rename configs/{ => os_x}/.slate.js (100%) rename configs/{ => shared}/.ctags (100%) rename configs/{ => shared}/.emacs (99%) rename configs/{ => shared}/.tmux.conf (100%) rename configs/{ => shared}/.vimrc (100%) rename configs/{ => shared}/.zsh_profile (100%) create mode 100644 emacs/wc-ansi-term-functions.el rename configs/tmux-256color-italic => tmux-256color-italic (100%) diff --git a/configs/.xinitrc b/configs/linux/.xinitrc similarity index 100% rename from configs/.xinitrc rename to configs/linux/.xinitrc diff --git a/configs/.slate.js b/configs/os_x/.slate.js similarity index 100% rename from configs/.slate.js rename to configs/os_x/.slate.js diff --git a/configs/setup_configs.sh b/configs/setup_configs.sh index 734acedf4..28dceff38 100755 --- a/configs/setup_configs.sh +++ b/configs/setup_configs.sh @@ -1,62 +1,47 @@ #!/usr/bin/env bash - pc_settings_path="${HOME}/pc_settings" +configs_dir="${pc_settings_path}/configs" +shared_configs="${configs_dir}/shared" + +if [[ $(uname) == 'Darwin' ]]; then + os_specific_configs="${configs_dir}/os_x" +elif [[ $(uname) == 'Linux' ]]; then + os_specific_configs="${configs_dir}/linux" +fi -config_files=( \ - ".zsh_profile" \ - ".tmux.conf" \ - ".ctags" \ - ".vimrc" \ - ".emacs" \ -) +function symlink_configs () { + configs_dir=$1 + for cf in $(find $configs_dir -type f -name ".*"); do + filename=$(grep -o "[^\/]+$" <<<$cf) + echo "$filename: " -for i in {1..5}; do - cf="${config_files[i]}" - echo "\"${cf}\": " - - if [ -f "${HOME}/${cf}" ] && [ ! -L "${HOME}/${cf}" ]; then - echo -n "Backing up ${cf} ... " && \ - mv "${HOME}/${cf}" "${HOME}/${cf}.bak" && \ - echo "Done." - fi - - if [ -L "${HOME}/${cf}" ]; then - if [ $(readlink "${HOME}/${cf}") = "${pc_settings_path}/configs/${cf}" ]; then - echo "Already properly symlinked to \"${pc_settings_path}/configs\"." - else - echo "Already symlinked but NOT to the proper location. Aborting..." + if [ -f "${HOME}/${filename}" ] && [ ! -L "${HOME}/${filename}" ]; then + echo -n "Backing up ${filename} ... " && \ + mv "${HOME}/${filename}" "${HOME}/${filename}.bak" && \ + echo "Done." fi - else - echo -n "Symlinking to ${pc_settings_path}/configs/${cf} ... " && \ - ln -s "${pc_settings_path}/configs/${cf}" "${HOME}/${cf}" && \ - echo "Done." - fi - echo "" -done + + if [ -L "${HOME}/${filename}" ]; then + if [ $(readlink "${HOME}/${filename}") = $cf ]; then + echo "Already properly symlinked to ${configs_dir}." + else + echo "Already symlinked but NOT to the proper location. Aborting..." + fi + else + echo -n "Symlinking to ${filename} ... " && \ + ln -s $cf "${HOME}/${filename}" && \ + echo "Done." + fi + echo "" + done +} -# Fish Shell is a special case -# cf_dir="${HOME}/.configs/fish" -# cf="config.fish" +# handle shared configs +symlink_configs $shared_configs -# if [ -f "${cf_dir}/${cf}" ] && [ ! -L "${cf_dir}/${cf}" ]; then -# echo -n "Backing up ${cf} ... " && \ -# mv "${cf_dir}/${cf}" "${HOME}/${cf}.bak" && \ -# echo "Done." -# fi - -# if [ -L "${cf_dir}/${cf}" ]; then -# if [ $(readlink "${cf_dir}/${cf}") = "${pc_settings_path}/configs/${cf}" ]; then -# echo "Already properly symlinked to \"${pc_settings_path}/configs\"." -# else -# echo "Already symlinked but NOT to the proper location. Aborting..." -# fi -# else -# echo -n "Symlinking to ${pc_settings_path}/configs/${cf} ... " && \ -# ln -s "${pc_settings_path}/configs/${cf}" "${cf_dir}/${cf}" && \ -# echo "Done." -# fi -# echo "" +# handle os-specific configs +symlink_configs $os_specific_configs diff --git a/configs/.ctags b/configs/shared/.ctags similarity index 100% rename from configs/.ctags rename to configs/shared/.ctags diff --git a/configs/.emacs b/configs/shared/.emacs similarity index 99% rename from configs/.emacs rename to configs/shared/.emacs index 2ff890625..8c66c3c15 100644 --- a/configs/.emacs +++ b/configs/shared/.emacs @@ -246,6 +246,7 @@ :init (load "~/.emacs.d/wc-dired-functions.el") :bind (:map dired-mode-map + ("C-p" . helm-ag-neotree-node) ("e" . wdired-change-to-wdired-mode) ("c" . find-file) ("RET" . dired-find-alternate-file) @@ -337,11 +338,11 @@ ;; center search results (defadvice evil-search-next - (after center-evil-search-next) + (after center-evil-search-next activate) (call-interactively 'evil-scroll-line-to-center)) (defadvice evil-search-previous - (after center-evil-search-previous) + (after center-evil-search-previous activate) (call-interactively 'evil-scroll-line-to-center)) (add-hook 'org-mode-hook 'evil-local-mode)) diff --git a/configs/.tmux.conf b/configs/shared/.tmux.conf similarity index 100% rename from configs/.tmux.conf rename to configs/shared/.tmux.conf diff --git a/configs/.vimrc b/configs/shared/.vimrc similarity index 100% rename from configs/.vimrc rename to configs/shared/.vimrc diff --git a/configs/.zsh_profile b/configs/shared/.zsh_profile similarity index 100% rename from configs/.zsh_profile rename to configs/shared/.zsh_profile diff --git a/emacs/wc-ansi-term-functions.el b/emacs/wc-ansi-term-functions.el new file mode 100644 index 000000000..aae9e0c6c --- /dev/null +++ b/emacs/wc-ansi-term-functions.el @@ -0,0 +1,11 @@ +;; if in a project + ;; if ansi-term is an existing process for the current project + ;; ok + ;; create an ansi-term buffer for the current project + ;; if ansi-term is an open window + ;; if number of open windows == 1, visit MRU source code buffer + ;; if number of open windows > 1, (delete-window ansi-term-window) + ;; if ansi-term is not an open window + ;; open ansi-term other-window +;; else + ;; (message "You are not currently in a project.") diff --git a/configs/tmux-256color-italic b/tmux-256color-italic similarity index 100% rename from configs/tmux-256color-italic rename to tmux-256color-italic