From 17f92c388a740f94c51b92bd12f8d2ac0da0491e Mon Sep 17 00:00:00 2001 From: Grant Hunter Date: Mon, 4 Jul 2022 15:16:44 -0600 Subject: [PATCH] update zsh and emacs config --- emacs.d/.gitignore | 6 +- emacs.d/init.el | 676 ++++++++++++++++++++++++++------------------- zshrc | 52 ++-- 3 files changed, 434 insertions(+), 300 deletions(-) diff --git a/emacs.d/.gitignore b/emacs.d/.gitignore index 243561d..0b81801 100644 --- a/emacs.d/.gitignore +++ b/emacs.d/.gitignore @@ -6,4 +6,8 @@ recentf .cache/ .lsp-session-v1 auto-save-list/ -.mc-lists.el \ No newline at end of file +.mc-lists.el +eln-cache/ +history +*.eld +straight/ diff --git a/emacs.d/init.el b/emacs.d/init.el index cac51bd..d0266bd 100644 --- a/emacs.d/init.el +++ b/emacs.d/init.el @@ -1,248 +1,19 @@ -;; This is only needed once, near the top of the file - -(eval-when-compile - (require 'package) - (setq package-archives '(("gnu" . "https://elpa.gnu.org/packages/") - ("melpa" . "https://melpa.org/packages/"))) - (package-install 'use-package) - (require 'use-package)) - -(package-initialize) - - - -;; This is only needed once, near the top of the file -(eval-when-compile - (require 'use-package)) - -(use-package all-the-icons - :ensure t - :if (display-graphic-p)) - -(use-package yasnippet - :ensure t - :init - (yas-global-mode 1)) - -(use-package pyvenv - :ensure t - :init - (setenv "WORKON_HOME" "~/.pyenv/versions")) - -(use-package lsp-mode - :ensure t - :init - (setq lsp-keymap-prefix "C-c l" - lsp-use-plists t) - :hook ((js-mode . lsp-deferred) - (rust-mode . lsp-deferred) - (python-mode . lsp-deferred) - (swift-mode . lsp-deferred)) - :commands (lsp lsp-deferred) - :config - (setq lsp-idle-delay 0.500)) - -;; (use-package lsp-jedi -;; :ensure t -;; :config -;; (with-eval-after-load "lsp-mode" -;; (add-to-list 'lsp-disabled-clients 'pyls) -;; (add-to-list 'lsp-enabled-clients 'jedi))) -;; (use-package lsp-pyright -;; :ensure t -;; :hook (python-mode . (lambda () -;; (require 'lsp-pyright) -;; (lsp-deferred)))) -(use-package lsp-python-ms - :ensure t - :init (setq lsp-python-ms-auto-install-server t) - :hook (python-mode . (lambda () - (require 'lsp-python-ms) - (lsp-deferred)))) -(use-package python-black - :ensure t - :after python - :hook (python-mode . python-black-on-save-mode-enable-dwim)) - -(use-package python-isort - :ensure t - :after python - :hook (python-mode . python-isort-on-save-mode)) - -(use-package lsp-sourcekit - :ensure t - :after lsp-mode - :config - (setq lsp-sourcekit-executable "/usr/local/bin/sourcekit-lsp")) -(use-package lsp-ui - :ensure t - :commands lsp-ui-mode - :config - (define-key lsp-ui-mode-map [remap xref-find-definitions] #'lsp-ui-peek-find-definitions) - (define-key lsp-ui-mode-map [remap xref-find-references] #'lsp-ui-peek-find-references)) - -(use-package company - :ensure t - :hook (after-init-hook . global-company-mode) - :init - (setq company-dabbrev-downcase nil - company-idle-delay 0.0 - company-minimum-prefix-length 1 - company-format-margin-function nil) - - (global-company-mode t) - :config - (push 'company-lsp company-backends)) - -(use-package helm - :ensure t - :bind(("M-x" . helm-M-x) - ("C-x b" . helm-mini) - ("C-x C-b" . helm-buffers-list) - ("C-x C-f" . helm-find-files) - ("C-x C-r" . helm-recentf) - ("M-y" . helm-show-kill-ring)) - :config - (require 'helm-config) - (helm-mode 1) - (setq helm-autoresize-max-height 20) - (setq helm-autoresize-max-height 20) - (helm-autoresize-mode 1) - :commands helm-lsp-workspace-symbol - ) -(use-package helm-lsp - :ensure t - :commands helm-lsp-workspace-symbol) - -(use-package helm-projectile - :ensure t) - -(use-package helm-swoop - :ensure t - :bind(("C-s" . helm-swoop) - ("M-i" . helm-swoop-back-to-last-point)) - :config - (define-key helm-swoop-map (kbd "C-r") 'helm-previous-line) - (define-key helm-swoop-map (kbd "C-s") 'helm-next-line) - (define-key helm-multi-swoop-map (kbd "C-r") 'helm-previous-line) - (define-key helm-multi-swoop-map (kbd "C-s") 'helm-next-line) - (setq helm-swoop-split-window-function 'helm-default-display-buffer) - (setq helm-swoop-pre-input-function - (lambda () "")) - ) - -(use-package projectile - :ensure t - :config - (setq projectile-enable-caching t - projectile-indexing-method 'alien - projectile-completion-system 'helm - projectile-switch-project-action 'helm-projectile - projectile-globally-ignored-files - (append '(".pyc" - ".class" - "~" - "node_modules" - ".cache" - "package.json" - "package-lock.json") - projectile-globally-ignored-files)) - (projectile-mode) - (helm-projectile-on) - (define-key projectile-mode-map (kbd "C-c p") 'projectile-command-map)) - -(use-package markdown-mode - :ensure t - :commands (markdown-mode gfm-mode) - :mode (("README\\.md\\'" . gfm-mode) - ("\\.md\\'" . markdown-mode) - ("\\.markdown\\'" . markdown-mode)) - :init (setq markdown-command "multimarkdown")) -(use-package grip-mode - :ensure t) - -(use-package org - :ensure t - :bind(("C-c l" . org-store-link) - ("C-c a" . org-agenda) - ("C-c c" . org-capture)) - :config - (setq org-log-done t - org-agenda-files (list "~/org/notes.org") - org-default-notes-file "~/org/notes.org")) - -(use-package semantic - :ensure t - :config - (semantic-mode 1) - (global-semantic-stickyfunc-mode 1) - ) - -(use-package material-theme - :ensure t) - -;;(font-lock-add-keywords 'lisp-mode '(("\'.*\'" 0 'font-lock-single-quote-string-face t))) - -(use-package multiple-cursors - :ensure t - :bind( - ("C-}" . mc/mark-next-like-this) - ("C-{" . mc/mark-previous-like-this) - ("C-|" . mc/mark-all-like-this) - )) - -(use-package ace-window - :ensure t - :bind (("M-o" . ace-window))) - -(use-package powerline - :ensure t) - - -(use-package flycheck - :ensure t) -(use-package rainbow-delimiters - :ensure t) -(use-package magit - :ensure t - :bind (("C-c m" . magit-status))) - -(use-package crux - :ensure t - :bind (("C-c r" . crux-rename-file-and-buffer))) - -(use-package diff-hl - :ensure t - :config - (global-diff-hl-mode)) - -(use-package toml-mode - :ensure t) -(use-package rust-mode - :ensure t) -(use-package terraform-mode - :ensure t) -(use-package company-terraform - :ensure t) -(use-package jinja2-mode - :ensure t) -(use-package json-mode - :ensure t) -(use-package json-snatcher - :ensure t) - - -(use-package yaml-mode - :ensure t) - -(add-to-list 'auto-mode-alist '("\\.lisp\\'" . emacs-lisp-mode)) -(require 'uniquify) - -(setq inhibit-splash-screen t) -(setq inhibit-startup-message t) -(setq frame-title-format "%F %b ") -(setq uniquify-buffer-name-style 'forward) +(setq-default auto-save-file-name-transforms `((".*" ,temporary-file-directory t)) + backup-directory-alist `((".*" . ,temporary-file-directory)) + undo-tree-history-directory-alist `((".*" . ,temporary-file-directory)) + confirm-kill-emacs 'y-or-n-p frame-title-format "%F %b " gc-cons-threshold (* (* 1 + 128) + 1024 + 1024) ;; 100mb + indent-tabs-mode nil inhibit-splash-screen t inhibit-startup-message t + lazy-highlight-cleanup nil make-backup-files nil read-process-output-max (* 1 (* 1024 + 1024)) + ;; 1mb + ring-bell-function 'ignore uniquify-buffer-name-style 'forward + use-package-always-ensure t vc-follow-symlinks t warning-minimum-level + :error whitespace-line-column 500) +(fset 'yes-or-no-p 'y-or-n-p) (show-paren-mode) (menu-bar-mode -1) (tool-bar-mode -1) @@ -250,38 +21,366 @@ (global-auto-revert-mode t) (global-linum-mode) -(global-whitespace-mode) -(put 'narrow-to-region 'disabled nil) -(put 'dired-find-alternate-file 'disabled nil) +;;keybindings +(global-set-key (kbd "C-x p") 'previous-multiframe-window) -(setq gc-cons-threshold 100000000) -(setq make-backup-files nil) -(setq backup-directory-alist - `((".*" . ,temporary-file-directory))) -(setq auto-save-file-name-transforms - `((".*" ,temporary-file-directory t))) -(setq vc-follow-symlinks t) -(setq confirm-kill-emacs 'y-or-n-p) -(setq ring-bell-function 'ignore) -(setq lazy-highlight-cleanup nil) -(setq whitespace-line-column 500) -(setq read-process-output-max (* 1024 1024)) -(setq-default indent-tabs-mode - nil) -(fset 'yes-or-no-p 'y-or-n-p) +(setq package-archives '(("elpa" . "https://elpa.gnu.org/packages/") + ("melpa" . "https://melpa.org/packages/") + ("nongnu" . "https://elpa.nongnu.org/nongnu/"))) +(defvar bootstrap-version) +(let ((bootstrap-file (expand-file-name "straight/repos/straight.el/bootstrap.el" + user-emacs-directory)) + (bootstrap-version 5)) + (unless (file-exists-p bootstrap-file) + (with-current-buffer (url-retrieve-synchronously + "https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el" + 'silent 'inhibit-cookies) + (goto-char (point-max)) + (eval-print-last-sexp))) + (load bootstrap-file nil 'nomessage)) +(require 'package) +(unless (package-installed-p 'use-package) + (package-refresh-contents) + (package-install 'use-package)) -(add-hook 'before-save-hook 'delete-trailing-whitespace) + +;; Integrates `straight' directly into the `use-package' package through the +;; `:straight' expression. +(straight-use-package 'use-package) + +(use-package + delight) +(use-package + material-theme) (if (daemonp) - (add-hook 'after-make-frame-functions - (lambda (frame) - (select-frame frame) - (load-theme 'material t) - (set-frame-size (selected-frame) 150 48))) - (load-theme 'material t)) + (add-hook 'after-make-frame-functions (lambda (frame) + (select-frame frame) + (load-theme 'material t) + (set-frame-size (selected-frame) 150 48))) + (load-theme 'material t)) + +(use-package + whitespace + :config (add-hook 'before-save-hook 'delete-trailing-whitespace)) + + +(use-package + eldoc + :delight) + +(use-package + password-store) +(setq auth-sources '(password-store)) + +(use-package + all-the-icons + :if (display-graphic-p)) + +(use-package + yasnippet-snippets + :after yasnippet + :config (yasnippet-snippets-initialize)) + +(use-package + yasnippet + :delight yas-minor-mode + :hook (yas-minor-mode . gh/disable-yas-if-no-snippets) + :config (yas-global-mode) + :preface (defun gh/disable-yas-if-no-snippets () + (when (and yas-minor-mode + (null (yas--get-snippet-tables))) + (yas-minor-mode -1)))) + +(use-package + lsp-mode + :delight lsp-mode + :init (setq lsp-keymap-prefix "C-c l" lsp-use-plists t) + :hook ((js-mode . lsp-deferred) + (rust-mode . lsp-deferred) + (python-mode . lsp-deferred) + (swift-mode . lsp-deferred) + (sh-mode . lsp-deferred)) + :commands (lsp lsp-deferred) + :config (setq lsp-idle-delay 0.500) + :custom (lsp-enable-folding nil) + (lsp-enable-links nil) + (lsp-enable-snippet nil)) + +(use-package + python + :after lsp-mode + :ensure flycheck + :delight "Py" + :preface (defun python-remove-unused-imports() + "Remove unused imports and unused variables with autoflake." + (interactive) + (if (executable-find "autoflake") + (progn (shell-command (format "autoflake --remove-all-unused-imports -i %s" + (shell-quote-argument (buffer-file-name)))) + (revert-buffer t t t)) + (warn + "[✗] python-mode: Cannot find autoflake executable."))) + :custom (flycheck-pylintrc "~/.pylintrc") + (flycheck-python-pylint-executable "/usr/bin/pylint")) + +(use-package + pyvenv + :init (setenv "WORKON_HOME" "~/.pyenv/versions")) + +(use-package + lsp-pyright + :after lsp-mode + :config (setq lsp-pyright-venv-path "~/.pyenv/version") + :if (executable-find "pyright") + ;; To properly load `lsp-pyright', the `require' instruction is important. + :hook (python-mode . (lambda () + (require 'lsp-pyright) + (lsp-deferred)))) +(use-package + blacken + :after lsp-mode + :delight + :hook (python-mode . blacken-mode) + :custom (blacken-skip-string-nomalization t) + (blacken-line-length 99) + (blacken-allow-py36 t)) + +(use-package + py-isort + :hook ((python-mode . pyvenv-mode))) + +(use-package + lsp-sourcekit + :after lsp-mode + :config (setq lsp-sourcekit-executable "/usr/local/bin/sourcekit-lsp")) +(use-package + lsp-ui + :after lsp-mode + :commands lsp-ui-mode + :config (define-key lsp-ui-mode-map [remap xref-find-definitions] #'lsp-ui-peek-find-definitions) + (define-key lsp-ui-mode-map [remap xref-find-references] #'lsp-ui-peek-find-references)) + +(use-package + company + :after lsp-mode + :delight + :hook (after-init-hook . global-company-mode) + :init (setq company-dabbrev-downcase nil company-idle-delay 0.0 company-minimum-prefix-length 1 + company-format-margin-function nil)) + +;; (use-package +;; helm + +;; :delight :bind(("M-x" . helm-M-x) +;; ("C-x b" . helm-mini) +;; ("C-x C-b" . helm-buffers-list) +;; ("C-x C-f" . helm-find-files) +;; ("C-x C-r" . helm-recentf) +;; ("M-y" . helm-show-kill-ring)) +;; :config (require 'helm-config) +;; (helm-mode 1) +;; (setq helm-autoresize-max-height 20) +;; (setq helm-autoresize-max-height 20) +;; (helm-autoresize-mode 1) +;; :commands helm-lsp-workspace-symbol) +;; (use-package +;; helm-lsp +;; :after lsp-mode +;; :commands helm-lsp-workspace-symbol) + +;; (use-package +;; helm-projectile +;; :after projectile +;; :delight) + +;; (use-package +;; helm-swoop +;; :bind(("C-s" . helm-swoop) +;; ("M-i" . helm-swoop-back-to-last-point)) +;; :config (define-key helm-swoop-map (kbd "C-r") 'helm-previous-line) +;; (define-key helm-swoop-map (kbd "C-s") 'helm-next-line) +;; (define-key helm-multi-swoop-map (kbd "C-r") 'helm-previous-line) +;; (define-key helm-multi-swoop-map (kbd "C-s") 'helm-next-line) +;; (setq helm-swoop-split-window-function 'helm-default-display-buffer) +;; (setq helm-swoop-pre-input-function (lambda () ""))) + +(use-package vertico + :straight (:files (:defaults "extensions/*")) + :init + (vertico-mode) + :bind (:map vertico-map + ("RET" . vertico-directory-enter) + ("DEL" . vertico-directory-delete-char) + ) + :custom (vertico-cycle t)) + +(use-package savehist + :init + (savehist-mode)) + +(use-package consult + :after projectile + :bind (;; Related to the control commands. + (" a" . consult-apropos) + ("C-x b" . consult-buffer) + ("C-x M-:" . consult-complex-command) + ("C-c k" . consult-kmacro) + ;; Related to the navigation. + ("M-g a" . consult-org-agenda) + ("M-g e" . consult-error) + ("M-g g" . consult-goto-line) + ("M-g h" . consult-org-heading) + ("M-g i" . consult-imenu) + ("M-g k" . consult-global-mark) + ("M-g l" . consult-line) + ("M-g m" . consult-mark) + ("M-g o" . consult-outline) + ("M-g I" . consult-project-imenu) + ;; Related to the search and selection. + ("M-s G" . consult-git-grep) + ("M-s g" . consult-grep) + ("M-s k" . consult-keep-lines) + ("M-s l" . consult-locate) + ("M-s m" . consult-multi-occur) + ("M-s r" . consult-ripgrep) + ("M-s u" . consult-focus-lines) + ("M-s f" . consult-find)) + :custom + (completion-in-region-function #'consult-completion-in-region) + (consult-narrow-key "<") + (consult-project-root-function #'projectile-project-root) + ;; Provides consistent display for both `consult-register' and the register + ;; preview when editing registers. + (register-preview-delay 0) + (register-preview-function #'consult-register-preview)) + +(use-package + projectile + :delight '(:eval (projectile-project-name)) + :custom + (define-key projectile-mode-map (kbd "C-c p") 'projectile-command-map) + (projectile-enable-caching t projectile-indexing-method 'alien) + (projectile-switch-project-action #'projectile-dired) + :config + (setq projectile-globally-ignored-files (append '(".pyc" ".class" "~" "node_modules" + ".cache" "package.json" + "package-lock.json") + projectile-globally-ignored-files)) + (projectile-global-mode)) + + + +(use-package + markdown-mode + :commands (markdown-mode gfm-mode) + :mode (("README\\.md\\'" . gfm-mode) + ("\\.md\\'" . markdown-mode) + ("\\.markdown\\'" . markdown-mode)) + :init (setq markdown-command "multimarkdown")) +(use-package + grip-mode) + +(use-package + org + :bind(("C-c l" . org-store-link) + ("C-c a" . org-agenda) + ("C-c c" . org-capture)) + :ensure org-contrib + :custom (setq org-default-notes-file (concat org-directory "/notes.org")) + (org-todo-keywords '((sequence "TODO(t)" "STARTED(s)" "NEXT(n)" "SOMEDAY(.)" "WAITING(w)""|" + "DONE(x!)" "CANCELLED(c@)")))) + +(use-package + toc-org + :after org + :hook (org-mode . toc-org-enable)) + +(use-package + flyspell + :ensure nil + :delight + :hook ((text-mode . flyspell-mode) + (prog-mode . flyspell-prog-mode)) + :custom + ;; Add correction to abbreviation table. + (flyspell-abbrev-p t) + (flyspell-default-dictionary "en_CA") + (flyspell-issue-message-flag nil) + (flyspell-issue-welcome-flag nil)) + +(use-package + ispell + :custom (ispell-hunspell-dict-paths-alist '(("en_CA" "/usr/share/hunspell/en_CA.aff"))) + (ispell-silently-savep t) + :config (setenv "LANG" "en_CA") + (setq ispell-program-name "hunspell") + (setq ispell-local-dictionary-alist '(("en_CA" "[[:alpha:]]" "[^[:alpha:]]" "['’-]" t ("-d" + "en_CA" ) + nil utf-8)))) +(use-package + semantic + :config (semantic-mode 1) + (global-semantic-stickyfunc-mode 1)) + + +;;(font-lock-add-keywords 'lisp-mode '(("\'.*\'" 0 'font-lock-single-quote-string-face t))) + +(use-package + multiple-cursors + :bind(("C-}" . mc/mark-next-like-this) + ("C-{" . mc/mark-previous-like-this) + ("C-|" . mc/mark-all-like-this))) + +(use-package + undo-tree + :delight undo-tree-mode + :config (global-undo-tree-mode)) + +(use-package + ace-window + :bind (("M-o" . ace-window))) + +(use-package + flycheck) +(use-package + rainbow-delimiters + :delight) +(use-package + magit + :bind (("C-c m" . magit-status)) + :custom (magit-display-buffer-function #'magit-display-buffer-same-window-except-diff-v1)) + +(use-package + crux + :bind (("C-c r" . crux-rename-file-and-buffer))) + +(use-package + diff-hl + :config (global-diff-hl-mode)) + +(use-package + toml-mode) +(use-package + rust-mode) +(use-package + terraform-mode) +(use-package + company-terraform) +(use-package + jinja2-mode) +(use-package + json-mode) +(use-package + json-snatcher) +(use-package + yaml-mode) + +(add-to-list 'auto-mode-alist '("\\.lisp\\'" . emacs-lisp-mode)) +(require 'uniquify) (add-hook 'eww-mode-hook 'scroll-lock-mode) @@ -296,13 +395,7 @@ (add-hook 'prog-mode-hook 'rainbow-delimiters-mode) -;;Enable powerline -(powerline-center-theme) -(setq powerline-default-separator 'slant) -;keybindings -(global-set-key (kbd "C--") 'undo) -(global-set-key (kbd "C-x p") 'previous-multiframe-window) ;;; init.el ends here (custom-set-variables @@ -315,19 +408,38 @@ '(lsp-ui-doc-show-with-cursor nil) '(lsp-ui-doc-show-with-mouse nil) '(lsp-ui-doc-use-webkit nil) - '(package-selected-packages - '(lsp-sourcekit swift-mode python-isort helm-rg python-black lsp-python-ms all-the-icons lsp-treemacs grip-mode helm-swoop diff-hl diff-hl-mode crux ace-window company-mode django-snippets company helm-lsp company-lsp pyvenv json-snatcher package-lint helm-slime slime slime-company slime-repl-ansi-color helm-projectile web-mode py-autopep8 lsp-ui uniquify lsp-helm lsp-company yaml-mode use-package toml-mode rust-mode rainbow-delimiters projectile powerline multiple-cursors material-theme magit lsp-mode json-mode jinja2-mode gnu-elpa-keyring-update flycheck company-terraform)) + '(package-selected-packages '(password-store slack k8s-mode lsp-sourcekit swift-mode python-isort + helm-rg python-black lsp-python-ms all-the-icons + lsp-treemacs grip-mode helm-swoop diff-hl diff-hl-mode + crux ace-window company-mode django-snippets company + helm-lsp pyvenv json-snatcher package-lint helm-slime + slime slime-company slime-repl-ansi-color + helm-projectile web-mode py-autopep8 lsp-ui uniquify + lsp-helm lsp-company yaml-mode use-package toml-mode + rust-mode rainbow-delimiters projectile powerline + multiple-cursors material-theme magit lsp-mode + json-mode jinja2-mode gnu-elpa-keyring-update flycheck + company-terraform)) '(python-isort-arguments '("--stdout" "--atomic" "-")) + '(warning-suppress-types + '((use-package) + (comp))) '(yas-global-mode t)) (custom-set-faces ;; custom-set-faces was added by Custom. ;; If you edit it by hand, you could mess it up, so be careful. ;; Your init file should contain only one such instance. ;; If there is more than one, they won't work right. - '(company-tooltip ((t (:inherit default :background "#2a4937a43e51")))) - '(company-tooltip-common ((t (:inherit font-lock-constant-face)))) - '(company-tooltip-scrollbar-thumb ((t (:background "#307f3fcf4778")))) - '(company-tooltip-scrollbar-track ((t (:background "#3ad84d6d56b8")))) - '(company-tooltip-selection ((t (:inherit font-lock-function-name-face))))) + '(company-tooltip ((t + (:inherit default + :background "#2a4937a43e51")))) + '(company-tooltip-common ((t + (:inherit font-lock-constant-face)))) + '(company-tooltip-scrollbar-thumb ((t + (:background "#307f3fcf4778")))) + '(company-tooltip-scrollbar-track ((t + (:background "#3ad84d6d56b8")))) + '(company-tooltip-selection ((t + (:inherit font-lock-function-name-face))))) (put 'upcase-region 'disabled nil) (put 'downcase-region 'disabled nil) diff --git a/zshrc b/zshrc index 9fa6fce..3e945a8 100644 --- a/zshrc +++ b/zshrc @@ -80,11 +80,6 @@ source $ZSH/oh-my-zsh.sh # export LANG=en_US.UTF-8 -if [[ -n $SSH_CONNECTION ]]; then - export EDITOR='emacs' -else - export EDITOR='emacs' -fi # Compilation flags # export ARCHFLAGS="-arch x86_64" @@ -102,23 +97,29 @@ fi setopt noincappendhistory setopt nosharehistory -e() {emacsclient -a "" -qc -n "$@" &; disown} +export LSP_USE_PLISTS=true +if [[ -n $SSH_CONNECTION ]]; then + export EDITOR='emacs' +else + export EDITOR='emacs' +fi + +e() { + emacsclient -a "" -qc -n "$@" > /dev/null &; disown +} alias ec="emacsclient -qc -n" export PATH=$PATH:$HOME/.local/bin export PATH=$PATH:$HOME/.pyenv/bin export PATH=$PATH:/usr/local/go/bin +export PATH=$PATH:$HOME/.krew/bin +export PATH=$PATH:$HOME/.linkerd2/bin +export PATH=$PATH:/usr/local/swift/bin eval "$(pyenv init -)" eval "$(pyenv virtualenv-init -)" source <(kubectl completion zsh) -if [[ $(grep -i microsoft /proc/version) ]]; then - echo "running in ms mode" - export DISPLAY=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2}'):0 - cd ~ -fi - export AWS_DEFAULT_REGION=us-east-1 aws-docker-login() { @@ -133,17 +134,34 @@ aws-get-codeartifact() { } aws-login() { + PROFILE="${1:-default}" + echo "logging in for " $PROFILE # Modify the line below based on your needs # aws-azure-login sometimes will prompt for the password every time which is annoying # so this get-caller-identity is a way to test and only prompt for login when required - IDENT=$(aws sts get-caller-identity 2> /dev/null) + IDENT=$(aws sts get-caller-identity --profile $PROFILE 2> /dev/null) if [ $? -ne 0 ]; then - aws-azure-login --no-prompt + aws-azure-login --no-prompt --profile $PROFILE else echo "already logged in to aws as" $(echo $IDENT | jq -r .Arn) fi - aws-docker-login - aws-get-codeartifact } -aws-login +start-dockerd ()( + if [[ ! -f /var/run/docker.pid ]]; then + nohup sudo -b dockerd > /dev/null 2>&1 + fi +) + + +if [[ $(grep -i microsoft /proc/version) ]]; then + echo "running in ms mode" + + start-dockerd + export DISPLAY=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2}'):0 + aws-login + + aws-docker-login > /dev/null + aws-get-codeartifact > /dev/null + +fi