From 5dc11f619c245fbce6e927639bb3cdbe3c6cc12a Mon Sep 17 00:00:00 2001 From: "Marc T. Henry de Frahan" Date: Fri, 5 Apr 2024 13:45:19 -0600 Subject: [PATCH] zsh update (#4) --- .chezmoi.toml.tmpl | 21 +- .chezmoiignore | 1 - .github/workflows/ci.yml | 42 ++++ bin/executable_pyenv_python_install.tmpl | 46 +++++ bin/executable_teatimer.sh | 10 +- conda-env/environment.yml | 3 +- dot_emacs | 25 +-- .../zinit/plugins/hpc/hpc.plugin.zsh.tmpl | 120 ++++++++++++ .../plugins/personal/personal.plugin.zsh.tmpl | 183 +++++++++++++++++ dot_oh-my-zsh/custom/aliases.zsh | 46 ----- dot_oh-my-zsh/custom/functions.zsh | 69 ------- dot_oh-my-zsh/custom/functions_nrel_hpc.zsh | 106 ---------- dot_oh-my-zsh/custom/functions_olcf_hpc.zsh | 20 -- .../custom/iterm2_ssh_switch_tab_color.zsh | 43 ---- dot_ssh/config | 8 - dot_zshenv.tmpl | 49 +---- dot_zshrc | 185 +++++++----------- run_once_after_install-python-setup.sh | 64 ++++++ ...ter_install-spack-packages-cluster.sh.tmpl | 88 +++++---- run_once_before_install-packages-cli.sh | 14 ++ ...nce_before_install-packages-darwin.sh.tmpl | 23 +-- ...once_before_install-packages-linux.sh.tmpl | 13 ++ run_once_before_install-python-venv.sh | 36 ---- 23 files changed, 659 insertions(+), 556 deletions(-) create mode 100644 .github/workflows/ci.yml create mode 100644 bin/executable_pyenv_python_install.tmpl create mode 100644 dot_local/share/zinit/plugins/hpc/hpc.plugin.zsh.tmpl create mode 100644 dot_local/share/zinit/plugins/personal/personal.plugin.zsh.tmpl delete mode 100644 dot_oh-my-zsh/custom/aliases.zsh delete mode 100644 dot_oh-my-zsh/custom/functions.zsh delete mode 100644 dot_oh-my-zsh/custom/functions_nrel_hpc.zsh delete mode 100644 dot_oh-my-zsh/custom/functions_olcf_hpc.zsh delete mode 100644 dot_oh-my-zsh/custom/iterm2_ssh_switch_tab_color.zsh create mode 100644 run_once_after_install-python-setup.sh create mode 100644 run_once_before_install-packages-cli.sh create mode 100644 run_once_before_install-packages-linux.sh.tmpl delete mode 100644 run_once_before_install-python-venv.sh diff --git a/.chezmoi.toml.tmpl b/.chezmoi.toml.tmpl index 7fccded..f5e0895 100644 --- a/.chezmoi.toml.tmpl +++ b/.chezmoi.toml.tmpl @@ -2,9 +2,26 @@ command = "emacs" args = ["-nw"] -{{- $use_zsh_root_dir := promptBoolOnce . "use_zsh_root_dir" "Use ZSH_ROOT_DIR for tmux shell" }} -{{ $email := promptString "email" -}} +{{ $use_zsh_root_dir := promptBoolOnce . "use_zsh_root_dir" "Use ZSH_ROOT_DIR for tmux shell" }} +{{ $email := promptStringOnce . "email" "email" -}} +{{ $test_machine := promptBoolOnce . "test_machine" "test_machine" }} + +{{ $nrel_hpc := false -}} +{{ $nrel_cluster := env "NREL_CLUSTER" | quote -}} +{{- if or (eq (env "NREL_CLUSTER") "eagle") (eq (env "NREL_CLUSTER") "ellis") (eq (env "NREL_CLUSTER") "kestrel") -}} +{{ $nrel_hpc = true -}} +{{- end -}} + +{{ $ornl_hpc := false -}} +{{- if eq (env "LMOD_SYSTEM_NAME") "frontier" -}} +{{ $ornl_hpc = true -}} +{{- end -}} [data] use_zsh_root_dir = {{ $use_zsh_root_dir }} email = {{ $email | quote }} + test_machine = {{ $test_machine }} + spack_packages = false + nrel_hpc = {{ $nrel_hpc }} + nrel_cluster = {{ $nrel_cluster }} + ornl_hpc = {{ $ornl_hpc }} \ No newline at end of file diff --git a/.chezmoiignore b/.chezmoiignore index 9abcd84..7b36f1b 100644 --- a/.chezmoiignore +++ b/.chezmoiignore @@ -7,7 +7,6 @@ terminal-app .config/karabiner .config/iterm2 .hammerspoon -.oh-my-zsh/custom/iterm2_ssh_switch_tab_color.zsh .vscode bin/keyremap.sh Library diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..8b51fb6 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,42 @@ +name: dotfiles-CI + +on: + workflow_dispatch: + push: + branches: [main] + pull_request: + branches: [main] + schedule: + - cron: "0 5 * * 1" + +concurrency: + group: ${{github.ref}}-${{github.head_ref}}-ci + cancel-in-progress: true + +jobs: + Dotfiles: + runs-on: ${{matrix.os}} + strategy: + matrix: + os: [ubuntu-latest, macos-latest] + include: + - os: macos-latest + install_deps: brew install chezmoi + - os: ubuntu-latest + install_deps: sudo apt-get update && sudo apt install zsh -y && sh -c "$(curl -fsLS get.chezmoi.io)" -- -b $HOME/.local/bin && export PATH="${HOME}/.local/bin:$PATH" + steps: + - name: Dependencies + run: | + ${{matrix.install_deps}} + - name: Install + run: | + export CHEZMOI_BRANCH=${{ github.head_ref || github.ref_name }} + chezmoi init https://github.com/marchdf/dotfiles.git --branch ${CHEZMOI_BRANCH} --promptBool test_machine=t,"Use ZSH_ROOT_DIR for tmux shell"=f --promptString email="" + chezmoi data + chezmoi apply + - name: Cold start zsh + run: | + time zsh -i -c exit + - name: Warm start zsh + run: | + time zsh -i -c exit diff --git a/bin/executable_pyenv_python_install.tmpl b/bin/executable_pyenv_python_install.tmpl new file mode 100644 index 0000000..0e02e11 --- /dev/null +++ b/bin/executable_pyenv_python_install.tmpl @@ -0,0 +1,46 @@ +#!/usr/bin/env bash + +if [[ ! -x "$(command -v pyenv)" ]]; then + echo "Please install pyenv" + exit 1 +fi + +{{- if eq .nrel_cluster "eagle" }} +source /nopt/nrel/ecom/hpacf/env.sh +module use ${HOME}/modules/linux-centos7-skylake_avx512 +module load gcc +module load binutils +module load git +module load gnutls +module load libtool +module load bzip2 +module load libffi +module load openssl +module load sqlite +export LDFLAGS="-L${OPENSSL_ROOT_DIR}/lib -L${LIBFFI_ROOT_DIR}/lib64 -L${BZIP2_ROOT_DIR}/lib -L${SQLITE_ROOT_DIR}/lib" +export CPPFLAGS="-I${OPENSSL_ROOT_DIR}/include -I${LIBFFI_ROOT_DIR}/include -I${BZIP2_ROOT_DIR}/include -I${SQLITE_ROOT_DIR}/include" +{{- else if eq .nrel_cluster "ellis" }} +MODULES_DATE=2023-05-11 +source /data/ssd1/software/${MODULES_DATE}/env.sh +module load gcc +module load binutils +module load git +module load gnutls +module load libtool +module load bzip2 +module load libffi +module load sqlite +export LDFLAGS="-L${LIBFFI_ROOT_DIR}/lib64 -L${BZIP2_ROOT_DIR}/lib -L${SQLITE_ROOT_DIR}/lib" +export CPPFLAGS="-I${LIBFFI_ROOT_DIR}/include -I${BZIP2_ROOT_DIR}/include -I${SQLITE_ROOT_DIR}/include" +{{- end }} +export PYTHON_CONFIGURE_OPTS="--enable-optimizations --with-lto" +export PYTHON_CFLAGS="-mtune=native" + + +PYTHON_VERSION="${1}" +if [ ! -z "$python_version" ] +then + pyenv install +else + pyenv install -s ${PYTHON_VERSION} +fi diff --git a/bin/executable_teatimer.sh b/bin/executable_teatimer.sh index 6d2f43d..8aeafad 100644 --- a/bin/executable_teatimer.sh +++ b/bin/executable_teatimer.sh @@ -18,15 +18,19 @@ if [ "$(uname)" == "Darwin" ]; then # Make sure sound is enabled osascript -e "set Volume 2" - + + # Doesn't work with ventura # Make sure you installed terminal-notifier with homebrew # Also increase the notification banner time by doing: # defaults write com.apple.notificationcenterui bannerTime 15 # taken from: https://9to5mac.com/2014/01/30/how-to-change-os-x-banner-notification-duration-using-terminal/ - terminal-notifier -title "Your tea is ready!" -message "" -sound default -contentImage "$HOME/bin/tea.jpg"; + # terminal-notifier -title "Your tea is ready!" -message "" -sound default -contentImage "$HOME/bin/tea.jpg"; + + # Display notification + osascript -e 'display notification "--" with title "Your tea is ready"' # Make my own sound aiff with the old system beep? and play it like this - #afplay /System/Library/Sounds/Funk.aiff + afplay /System/Library/Sounds/Funk.aiff # Make sure sound is disabled (but wait for previous command to end) gsleep 1s; diff --git a/conda-env/environment.yml b/conda-env/environment.yml index b69c294..1701b1f 100644 --- a/conda-env/environment.yml +++ b/conda-env/environment.yml @@ -7,7 +7,7 @@ channels: - conda-forge - defaults dependencies: - - python=3.10 + - python=3.11 - black - ipython - line_profiler @@ -22,6 +22,5 @@ dependencies: - seaborn - snakeviz - sphinx - - toml - yt prefix: /home/mhenryde/miniconda3/envs/main diff --git a/dot_emacs b/dot_emacs index 91ac856..1163578 100644 --- a/dot_emacs +++ b/dot_emacs @@ -151,18 +151,19 @@ (add-to-list 'lsp-file-watch-ignored-directories "[/\\\\]tmp_build_dir\\'") (add-to-list 'lsp-file-watch-ignored-directories "[/\\\\]spack-build-.+\\'") (add-to-list 'lsp-file-watch-ignored-directories "[/\\\\].spack-env\\'") - (add-to-list 'lsp-file-watch-ignored-directories "[/\\\\]spack-manager/.cache\\'") - (add-to-list 'lsp-file-watch-ignored-directories "[/\\\\]spack-manager/.tmp\\'") - (add-to-list 'lsp-file-watch-ignored-directories "[/\\\\]spack-manager/configs\\'") - (add-to-list 'lsp-file-watch-ignored-directories "[/\\\\]spack-manager/docs\\'") - (add-to-list 'lsp-file-watch-ignored-directories "[/\\\\]spack-manager/env-templates\\'") - (add-to-list 'lsp-file-watch-ignored-directories "[/\\\\]spack-manager/golds\\'") - (add-to-list 'lsp-file-watch-ignored-directories "[/\\\\]spack-manager/repos\\'") - (add-to-list 'lsp-file-watch-ignored-directories "[/\\\\]spack-manager/scripts\\'") - (add-to-list 'lsp-file-watch-ignored-directories "[/\\\\]spack-manager/spack\\'") - (add-to-list 'lsp-file-watch-ignored-directories "[/\\\\]spack-manager/spack-scripting\\'") - (add-to-list 'lsp-file-watch-ignored-directories "[/\\\\]spack-manager/stage\\'") - (add-to-list 'lsp-file-watch-ignored-directories "[/\\\\]spack-manager/tests\\'") + (add-to-list 'lsp-file-watch-ignored-directories "[/\\\\]exawind-manager/.cache\\'") + (add-to-list 'lsp-file-watch-ignored-directories "[/\\\\]exawind-manager/.tmp\\'") + (add-to-list 'lsp-file-watch-ignored-directories "[/\\\\]exawind-manager/configs\\'") + (add-to-list 'lsp-file-watch-ignored-directories "[/\\\\]exawind-manager/docs\\'") + (add-to-list 'lsp-file-watch-ignored-directories "[/\\\\]exawind-manager/env-templates\\'") + (add-to-list 'lsp-file-watch-ignored-directories "[/\\\\]exawind-manager/golds\\'") + (add-to-list 'lsp-file-watch-ignored-directories "[/\\\\]exawind-manager/repos\\'") + (add-to-list 'lsp-file-watch-ignored-directories "[/\\\\]exawind-manager/scripts\\'") + (add-to-list 'lsp-file-watch-ignored-directories "[/\\\\]exawind-manager/spack\\'") + (add-to-list 'lsp-file-watch-ignored-directories "[/\\\\]exawind-manager/spack-manager\\'") + (add-to-list 'lsp-file-watch-ignored-directories "[/\\\\]exawind-manager/spack-scripting\\'") + (add-to-list 'lsp-file-watch-ignored-directories "[/\\\\]exawind-manager/stage\\'") + (add-to-list 'lsp-file-watch-ignored-directories "[/\\\\]exawind-manager/tests\\'") ;; Increase garbage collection threshold ;; https://emacs-lsp.github.io/lsp-mode/page/performance/ diff --git a/dot_local/share/zinit/plugins/hpc/hpc.plugin.zsh.tmpl b/dot_local/share/zinit/plugins/hpc/hpc.plugin.zsh.tmpl new file mode 100644 index 0000000..851f591 --- /dev/null +++ b/dot_local/share/zinit/plugins/hpc/hpc.plugin.zsh.tmpl @@ -0,0 +1,120 @@ +# -*- mode: sh; sh-indentation: 4; indent-tabs-mode: nil; sh-basic-offset: 4; -*- + +# Copyright (c) 2024 Marc Henry de Frahan + +# According to the Zsh Plugin Standard: +# https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html + +0=${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}} +0=${${(M)0:#/*}:-$PWD/$0} + +# Then ${0:h} to get hpc's directory + +if [[ ${zsh_loaded_plugins[-1]} != */personal && -z ${fpath[(r)${0:h}]} ]] { + fpath+=( "${0:h}" ) +} + +# Standard hash for plugins, to not pollute the namespace +typeset -gA Plugins +Plugins[PERSONAL_DIR]="${0:h}" + +{{- if .nrel_hpc }} +# Custom for NREL HPC machines + +# Set scratch +if [ -d "/scratch/${USER}" ]; then + export SCRATCH="/scratch/${USER}" +fi + +# Set the modules +{{- if eq .nrel_cluster "eagle" }} +source /nopt/nrel/utils/lmod/lmod/init/zsh +source /nopt/nrel/ecom/hpacf/env.sh +module use ${HOME}/modules/linux-centos7-skylake_avx512/gcc-9.3.0 +export TMPDIR=${SCRATCH}/.tmp +{{- else if eq .nrel_cluster "ellis" }} +MODULES_DATE=2023-05-11 +source /data/ssd1/software/${MODULES_DATE}/env.sh +export TMPDIR=/data/ssd1/home/${USER}/.tmp +{{- else if eq .nrel_cluster "kestrel" }} +source /opt/cray/pe/lmod/lmod/init/zsh +source /nopt/nrel/apps/env.sh +export TMPDIR=${SCRATCH}/.tmp +{{- end }} + +umask u=rwx,go=rx,o=rx + +function load_custom_modules { + + { + module purge + module load gcc + module load binutils + module load bzip2 + module load cmake + module load ffmpeg/4.2.2 + module load git + module load gnutls + module load htop + module load image-magick + module load libffi + module load libtool + module load py-setuptools-scm + module load sqlite + module load tmux + {{- if eq .nrel_cluster "eagle" }} + module load python/3.7.7 + module load mpt + module load openssl + module load texlive + {{- else if eq .nrel_cluster "ellis" }} + module load python/3.10.10 + {{- end }} + + module load emacs/28.2 + module load ccls + } &> /dev/null +} + +function pv510server() { + module load paraview/5.10.1-server + srun -n $1 -c 1 --cpu_bind=cores pvserver +} + +function pv510gui() { + module load paraview/5.10.1-gui + vglrun paraview +} + +function pvtunnel() { + ssh -L 11111:$1:11111 mhenryde@$1 +} + +{{ end }} + +{{- if .ornl_hpc }} +# Custom for OLCF HPC machines +function load_custom_modules { + { + module load DefApps-spi/default + module load cmake + module load emacs + module load go + module load htop + module load imagemagick + module load tmux + + module load cray-python + + } &> /dev/null +} +{{ end }} + +{{- if or (.nrel_hpc) (.ornl_hpc) }} +load_custom_modules +{{ end }} + +# Use alternate vim marks [[[ and ]]] as the original ones can +# confuse nested substitutions, e.g.: ${${${VAR}}} + +# vim:ft=zsh:tw=80:sw=4:sts=4:et:foldmarker=[[[,]]] diff --git a/dot_local/share/zinit/plugins/personal/personal.plugin.zsh.tmpl b/dot_local/share/zinit/plugins/personal/personal.plugin.zsh.tmpl new file mode 100644 index 0000000..6ae68b1 --- /dev/null +++ b/dot_local/share/zinit/plugins/personal/personal.plugin.zsh.tmpl @@ -0,0 +1,183 @@ +# -*- mode: sh; sh-indentation: 4; indent-tabs-mode: nil; sh-basic-offset: 4; -*- + +# Copyright (c) 2024 Marc Henry de Frahan + +# According to the Zsh Plugin Standard: +# https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html + +0=${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}} +0=${${(M)0:#/*}:-$PWD/$0} + +# Then ${0:h} to get plugin's directory + +if [[ ${zsh_loaded_plugins[-1]} != */personal && -z ${fpath[(r)${0:h}]} ]] { + fpath+=( "${0:h}" ) +} + +# Standard hash for plugins, to not pollute the namespace +typeset -gA Plugins +Plugins[PERSONAL_DIR]="${0:h}" + +# Aliases + +alias ..="cd .." +alias ..2="cd ../.." +alias ..3="cd ../../.." +alias ..4="cd ../../../.." +alias ..5="cd ../../../../.." +alias ge="$EMACS_PLUGIN_LAUNCHER --no-wait" +alias e="$EMACS_PLUGIN_LAUNCHER -nw" +alias ek='emacsclient -e "(kill-emacs)"' +alias rmeps="rm *.eps" +alias rmpng="rm *.png" +alias rmpdf="rm -i *.pdf" +alias sshot="import ~/Desktop/screenshot.jpg" # screenshot (pick area to grab) +alias empty_space="printf ''\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n''" +alias lt="ls -lt" + +# Improving CLI +if [[ -x "$(command -v htop)" ]]; then alias top="htop"; fi +if [[ -x "$(command -v bat)" ]]; then alias cat="bat"; fi +if [[ -x "$(command -v prettyping)" ]]; then alias ping="prettyping"; fi +if [[ -x "$(command -v tldr)" ]]; then alias help="tldr"; fi + +# Weather using https://github.com/chubin/wttr.in +alias weather="curl wttr.in/\?m" + +# upgrade all python packages with pip. +# from http://mikegrouchy.com/blog/2014/06/pro-tip-pip-upgrade-all-python-packages.html +# periodically check this to make sure that pip didn't add this new feature +alias pip2_upgrade_all="pip2 freeze --local | grep -v '^\-e' | cut -d = -f 1 | xargs pip2 install -U" +alias pip3_upgrade_all="pip3 freeze --local | grep -v '^\-e' | cut -d = -f 1 | xargs pip3 install -U" + +# Mass renaming of files +# e.g. mmv *.dat *.dat_old +autoload -U zmv +alias mmv="noglob zmv -W" + +# Cluster aliases +if [[ -x "$(command -v qstat)" ]]; then + alias qs="qstat -u $USER"; + alias job_node_ids="qstat -u $USER -f | grep -e 'Job\ Id\|exec_host\|Job_Name'" +fi + +if [[ -x "$(command -v squeue)" ]]; then + alias qs="squeue -u $USER -o '%12i %.9P %20j %.2t %.10M %.6D %r %N'" + alias qnodes="sinfo -o '%24P %.5a %.12l %.16F'" +fi + +# Functions + +# print each directory of argument $PATH on its own line +function prettypath() { echo ${1-$PATH} | sed 's/:/\n/g'; } + +# Calls the teatimer script +function tt() { ~/bin/teatimer.sh "$@" &} + +# Calls the pdf2eps script +function pdf2eps() { ~/bin/pdf2eps.sh "$@" &} + +# refresh directory (if the directory was deleted from underneath us +# and we are still in it, try to re-cd to the directory) +function recd() { cd `pwd`; } + +# Diff two files using emacs ediff +# From: https://defunitive.wordpress.com/2011/07/23/invoking-emacs-ediff-from-the-command-line/ +function ediff() { + if [ "X${2}" = "X" ]; then + echo "USAGE: ediff " + else + # The --eval flag takes lisp code and evaluates it with emacs + "$EMACS_PLUGIN_LAUNCHER" -nw --eval "(ediff-files \"$1\" \"$2\")" + fi +} + +# Load spack environment if you want it. I do this instead of loading +# it by default because it would slow down terminal startup time +function load_spack(){ + if [ -d "$SPACK_DIR" ]; then + export SPACK_ROOT=${SPACK_DIR} + . ${SPACK_ROOT}/share/spack/setup-env.sh + fi +} + +# Grep through all python scrips in home directory +function grep_python() { + grep -r --include=\*.py --exclude-dir=.virtualenvs --exclude-dir=.emacs.d --exclude-dir=spack --exclude-dir=.oh-my-zsh "${1}" ${HOME} +} + +# runs TensorBoard with a comma-separated list of all provided logdirs +# usage: multitb LOGDIR [LOGDIR...] +# from: https://github.com/tensorflow/tensorboard/issues/179 +multitb() ( + set -eu + if [ $# -eq 0 ]; then + printf >&2 'fatal: provide at least one logdir\n' + return 1 + fi + tmpdir="$(mktemp -d)" + for arg; do + case "${arg}" in + /*) ln -s "${arg}" "${tmpdir}/" ;; + *) ln -s "${PWD}/${arg}" "${tmpdir}/" ;; + esac + done + exit_code=0 + \command ls -l "${tmpdir}" + printf 'tensorboard --logdir %s\n' "${tmpdir}" + tensorboard --logdir "${tmpdir}" || exit_code=$? + # This really should be 'find -H "${tmpdir}" -type l -delete` to + # account for logdirs whose names start with `.`, which should + # behave correctly on any POSIX system, but it is much more clear + # that the version below cannot under any circumstances delete the + # underlying data (e.g., with non-POSIX-compliant `find`(1)). + rm "${tmpdir}"/* + rmdir "${tmpdir}" + return "${exit_code}" +) + +{{- if eq .chezmoi.os "darwin" }} +# iTerm2 window/tab color commands +# Requires iTerm2 >= Build 1.0.0.20110804 +# http://code.google.com/p/iterm2/wiki/ProprietaryEscapeCodes +# Forked from: https://gist.github.com/wadey/1140259 +tab-color() { + echo -ne "\033]6;1;bg;red;brightness;$1\a" + echo -ne "\033]6;1;bg;green;brightness;$2\a" + echo -ne "\033]6;1;bg;blue;brightness;$3\a" +} +tab-reset() { + echo -ne "\033]6;1;bg;*;default\a" +} + +# Change the color of the tab when using SSH +# reset the color after the connection closes +color-ssh() { + if [[ -n "$ITERM_SESSION_ID" ]]; then + trap "tab-reset" INT EXIT + if [[ "$*" =~ "el1|el2|el3|ed1|dav1|dav2|dav3" ]]; then + tab-color 24 90 169 + elif [[ "$*" =~ "kl1|kl2" ]]; then + tab-color 244 125 35 + elif [[ "$*" =~ "f10|frontier|andes|summit|crusher|ascent|olcf" ]]; then + tab-color 102 44 155 + elif [[ "$*" =~ "ellis" ]]; then + tab-color 162 29 33 + elif [[ "$*" =~ "machine3a|machine3b" ]]; then + tab-color 180 56 148 + else + tab-color 0 140 72 + fi + fi + ssh $* +} +compdef _ssh color-ssh=ssh + +alias ssh=color-ssh + +{{- end }} + +# Use alternate vim marks [[[ and ]]] as the original ones can +# confuse nested substitutions, e.g.: ${${${VAR}}} + +# vim:ft=zsh:tw=80:sw=4:sts=4:et:foldmarker=[[[,]]] diff --git a/dot_oh-my-zsh/custom/aliases.zsh b/dot_oh-my-zsh/custom/aliases.zsh deleted file mode 100644 index 4125a49..0000000 --- a/dot_oh-my-zsh/custom/aliases.zsh +++ /dev/null @@ -1,46 +0,0 @@ -# These are my general aliases - -alias ..="cd .." -alias ..2="cd ../.." -alias ..3="cd ../../.." -alias ..4="cd ../../../.." -alias ..5="cd ../../../../.." -alias e="$EMACS_PLUGIN_LAUNCHER -nw" -alias ek='emacsclient -e "(kill-emacs)"' -alias rmeps="rm *.eps" -alias rmpng="rm *.png" -alias rmpdf="rm -i *.pdf" -alias sshot="import ~/Desktop/screenshot.jpg" # screenshot (pick area to grab) -alias empty_space="printf ''\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n''" -alias lt="ls -lt" - -# Improving CLI -if [[ -x "$(command -v htop)" ]]; then alias top="htop"; fi -if [[ -x "$(command -v bat)" ]]; then alias cat="bat"; fi -if [[ -x "$(command -v prettyping)" ]]; then alias ping="prettyping"; fi -if [[ -x "$(command -v tldr)" ]]; then alias help="tldr"; fi - -# Weather using https://github.com/chubin/wttr.in -alias weather="curl wttr.in/\?m" - -# upgrade all python packages with pip. -# from http://mikegrouchy.com/blog/2014/06/pro-tip-pip-upgrade-all-python-packages.html -# periodically check this to make sure that pip didn't add this new feature -alias pip2_upgrade_all="pip2 freeze --local | grep -v '^\-e' | cut -d = -f 1 | xargs pip2 install -U" -alias pip3_upgrade_all="pip3 freeze --local | grep -v '^\-e' | cut -d = -f 1 | xargs pip3 install -U" - -# Mass renaming of files -# e.g. mmv *.dat *.dat_old -autoload -U zmv -alias mmv="noglob zmv -W" - -# Cluster aliases -if [[ -x "$(command -v qstat)" ]]; then - alias qs="qstat -u $USER"; - alias job_node_ids="qstat -u $USER -f | grep -e 'Job\ Id\|exec_host\|Job_Name'" -fi - -if [[ -x "$(command -v squeue)" ]]; then - alias qs="squeue -u $USER -o '%12i %.9P %20j %.2t %.10M %.6D %r %N'" - alias qnodes="sinfo -o '%24P %.5a %.12l %.16F'" -fi diff --git a/dot_oh-my-zsh/custom/functions.zsh b/dot_oh-my-zsh/custom/functions.zsh deleted file mode 100644 index fc37e29..0000000 --- a/dot_oh-my-zsh/custom/functions.zsh +++ /dev/null @@ -1,69 +0,0 @@ -# These are my custom functions - -# print each directory of argument $PATH on its own line -function prettypath() { echo ${1-$PATH} | sed 's/:/\n/g'; } - -# Calls the teatimer script -function tt() { ~/bin/teatimer.sh "$@" &} - -# Calls the pdf2eps script -function pdf2eps() { ~/bin/pdf2eps.sh "$@" &} - -# refresh directory (if the directory was deleted from underneath us -# and we are still in it, try to re-cd to the directory) -function recd() { cd `pwd`; } - -# Diff two files using emacs ediff -# From: https://defunitive.wordpress.com/2011/07/23/invoking-emacs-ediff-from-the-command-line/ -function ediff() { - if [ "X${2}" = "X" ]; then - echo "USAGE: ediff " - else - # The --eval flag takes lisp code and evaluates it with emacs - e --eval "(ediff-files \"$1\" \"$2\")" - fi -} - -# Load spack environment if you want it. I do this instead of loading -# it by default because it would slow down terminal startup time -function load_spack(){ - if [ -d "$SPACK_DIR" ]; then - export SPACK_ROOT=${SPACK_DIR} - . ${SPACK_ROOT}/share/spack/setup-env.sh - fi -} - -# Grep through all python scrips in home directory -function grep_python() { - grep -r --include=\*.py --exclude-dir=.virtualenvs --exclude-dir=.emacs.d --exclude-dir=spack --exclude-dir=.oh-my-zsh "${1}" ${HOME} -} - -# runs TensorBoard with a comma-separated list of all provided logdirs -# usage: multitb LOGDIR [LOGDIR...] -# from: https://github.com/tensorflow/tensorboard/issues/179 -multitb() ( - set -eu - if [ $# -eq 0 ]; then - printf >&2 'fatal: provide at least one logdir\n' - return 1 - fi - tmpdir="$(mktemp -d)" - for arg; do - case "${arg}" in - /*) ln -s "${arg}" "${tmpdir}/" ;; - *) ln -s "${PWD}/${arg}" "${tmpdir}/" ;; - esac - done - exit_code=0 - \command ls -l "${tmpdir}" - printf 'tensorboard --logdir %s\n' "${tmpdir}" - tensorboard --logdir "${tmpdir}" || exit_code=$? - # This really should be 'find -H "${tmpdir}" -type l -delete` to - # account for logdirs whose names start with `.`, which should - # behave correctly on any POSIX system, but it is much more clear - # that the version below cannot under any circumstances delete the - # underlying data (e.g., with non-POSIX-compliant `find`(1)). - rm "${tmpdir}"/* - rmdir "${tmpdir}" - return "${exit_code}" -) diff --git a/dot_oh-my-zsh/custom/functions_nrel_hpc.zsh b/dot_oh-my-zsh/custom/functions_nrel_hpc.zsh deleted file mode 100644 index e5ba823..0000000 --- a/dot_oh-my-zsh/custom/functions_nrel_hpc.zsh +++ /dev/null @@ -1,106 +0,0 @@ -# These are my custom aliases for my NREL HPC machines -if [ "${NREL_CLUSTER}" = "eagle" ] || [ "${NREL_CLUSTER}" = "rhodes" ] || [ "${NREL_CLUSTER}" = "ellis" ]; then - - function load_custom_modules { - - { - module purge - module load gcc - module load mpt - module load binutils - module load bzip2 - module load cmake - module load ffmpeg/4.2.2 - module load git - module load gnutls - module load htop - module load image-magick - module load libffi - module load libtool - module load openssl - module load python/3.7.7 - module load py-setuptools-scm - module load sqlite - module load texlive - module load tmux - - module load emacs/28.2 - module load ccls - } &> /dev/null - } - - function load_spack_python3 { - - { - module load python/3.7.7 - while read -r line ; do - module load $line - done < <(module --raw --redirect avail | grep -o 'py-\S*') - } &> /dev/null - } - - function pv59server() { - source /nopt/nrel/ecom/exawind/exawind/scripts/exawind-env-gcc.sh - case $# in - "0" ) - srun -n 1 -c 1 --cpu_bind=cores /nopt/nrel/ecom/exawind/exawind/install/paraview/5.9.0/bin/pvserver - ;; - "1" ) - srun -n $1 -c 1 --cpu_bind=cores /nopt/nrel/ecom/exawind/exawind/install/paraview/5.9.0/bin/pvserver - ;; - esac - } - - function pv59gui() { - source /nopt/nrel/ecom/exawind/exawind/scripts/exawind-env-gcc.sh - vglrun /nopt/nrel/ecom/exawind/exawind/install/paraview/5.9.0/bin/paraview - } - - function pv510gui() { - module load paraview/5.10.1-gui - vglrun paraview - } - - function pv58server() { - source /nopt/nrel/ecom/exawind/exawind/scripts/exawind-env-gcc.sh - module load paraview/5.8.1-server - case $# in - "0" ) - srun -n 1 -c 1 --cpu_bind=cores pvserver - ;; - "1" ) - srun -n $1 -c 1 --cpu_bind=cores pvserver - ;; - esac - } - - function pv58gui() { - source /nopt/nrel/ecom/exawind/exawind/scripts/exawind-env-gcc.sh - module load paraview/5.8.1-gui - vglrun paraview - } - - function pvtunnel() { - ssh -L 11111:$1:11111 mhenryde@$1 - } - - function pyenv_python_install(){ - module load gcc - module load mpt - module load binutils - module load git - module load gnutls - module load libtool - module load texlive - module load bzip2 - module load libffi - module load openssl - module load sqlite - export LDFLAGS="-L${OPENSSL_ROOT_DIR}/lib -L${LIBFFI_ROOT_DIR}/lib64 -L${BZIP2_ROOT_DIR}/lib -L${SQLITE_ROOT_DIR}/lib" - export CPPFLAGS="-I${OPENSSL_ROOT_DIR}/include -I${LIBFFI_ROOT_DIR}/include -I${BZIP2_ROOT_DIR}/include -I${SQLITE_ROOT_DIR}/include" - export PYTHON_CONFIGURE_OPTS="--enable-optimizations --with-lto" - export PYTHON_CFLAGS="-mtune=native" - pyenv install - } - -fi diff --git a/dot_oh-my-zsh/custom/functions_olcf_hpc.zsh b/dot_oh-my-zsh/custom/functions_olcf_hpc.zsh deleted file mode 100644 index 81785d7..0000000 --- a/dot_oh-my-zsh/custom/functions_olcf_hpc.zsh +++ /dev/null @@ -1,20 +0,0 @@ -# These are my custom aliases for my OLCF HPC machines -if [ "${LMOD_SYSTEM_NAME}" = "frontier" ]; then - - function load_custom_modules { - - { - module load DefApps-spi/default - module load cmake - module load emacs - module load go - module load htop - module load imagemagick - module load tmux - - module load cray-python - - } &> /dev/null - } - -fi diff --git a/dot_oh-my-zsh/custom/iterm2_ssh_switch_tab_color.zsh b/dot_oh-my-zsh/custom/iterm2_ssh_switch_tab_color.zsh deleted file mode 100644 index 10a6d6a..0000000 --- a/dot_oh-my-zsh/custom/iterm2_ssh_switch_tab_color.zsh +++ /dev/null @@ -1,43 +0,0 @@ -#Usage: -# source iterm2.zsh -# -# Forked from: https://gist.github.com/wadey/1140259 -# - - -# iTerm2 window/tab color commands -# Requires iTerm2 >= Build 1.0.0.20110804 -# http://code.google.com/p/iterm2/wiki/ProprietaryEscapeCodes -tab-color() { - echo -ne "\033]6;1;bg;red;brightness;$1\a" - echo -ne "\033]6;1;bg;green;brightness;$2\a" - echo -ne "\033]6;1;bg;blue;brightness;$3\a" -} -tab-reset() { - echo -ne "\033]6;1;bg;*;default\a" -} - -# Change the color of the tab when using SSH -# reset the color after the connection closes -color-ssh() { - if [[ -n "$ITERM_SESSION_ID" ]]; then - trap "tab-reset" INT EXIT - if [[ "$*" =~ "navier|other_*_machine" ]]; then - tab-color 24 90 169 - elif [[ "$*" =~ "cori|edison" ]]; then - tab-color 244 125 35 - elif [[ "$*" =~ "machine1a|machine1b" ]]; then - tab-color 102 44 155 - elif [[ "$*" =~ "machine2a|machine2b" ]]; then - tab-color 162 29 33 - elif [[ "$*" =~ "machine3a|machine3b" ]]; then - tab-color 180 56 148 - else - tab-color 0 140 72 - fi - fi - ssh $* -} -compdef _ssh color-ssh=ssh - -alias ssh=color-ssh diff --git a/dot_ssh/config b/dot_ssh/config index ca0d5b7..8908d2d 100644 --- a/dot_ssh/config +++ b/dot_ssh/config @@ -42,14 +42,6 @@ host dav3 User mhenryde hostname dav3.hpc.nrel.gov -host merlin - User mhenryde - hostname merlin.hpc.nrel.gov - -host rhodes - User mhenryde - hostname rhodes.hpc.nrel.gov - host ellis User mhenryde hostname ellis.hpc.nrel.gov diff --git a/dot_zshenv.tmpl b/dot_zshenv.tmpl index fa6a0f4..345d5c7 100644 --- a/dot_zshenv.tmpl +++ b/dot_zshenv.tmpl @@ -44,15 +44,10 @@ fi export COMBUSTION_DIR="${HOME}/combustion" export MASA_HOME="${COMBUSTION_DIR}/install/MASA" -# Zplug -if [ -d "${HOME}/.zplug" ]; then - export ZPLUG_HOME="${HOME}/.zplug" -fi - -# spack-manager -if [ -d "${HOME}/exawind/spack-manager" ]; then - export SPACK_MANAGER=${HOME}/exawind/spack-manager - source ${SPACK_MANAGER}/start.sh +# exawind-manager +if [ -d "${HOME}/exawind/exawind-manager" ]; then + export EXAWIND_MANAGER=${HOME}/exawind/exawind-manager + source ${EXAWIND_MANAGER}/start.sh fi # pyenv @@ -67,6 +62,9 @@ if [ -d "${HOME}/.poetry" ]; then export PATH="$HOME/.poetry/bin:$PATH" fi +# zoxide +export _ZO_DATA_DIR=$HOME/.local/share + {{- if eq .chezmoi.os "darwin" }} # paths for Mac OSX @@ -82,36 +80,3 @@ export TMPDIR=/tmp alias vlc="{HOME}/Applications/VLC.app/Contents/MacOS/VLC" {{- end }} - - -# paths for NREL HPC -if [ "${NREL_CLUSTER}" = "eagle" ] || [ "${NREL_CLUSTER}" = "rhodes" ] || [ "${NREL_CLUSTER}" = "ellis" ]; then - - # Set scratch - if [ -d "/scratch/${USER}" ]; then - export SCRATCH="/scratch/${USER}" - fi - - # Set the modules - if [ "${NREL_CLUSTER}" = "eagle" ]; then - source /nopt/nrel/utils/lmod/lmod/init/zsh - source /nopt/nrel/ecom/hpacf/env.sh - module use ${HOME}/modules/linux-centos7-skylake_avx512/gcc-9.3.0 - export TMPDIR=${SCRATCH}/.tmp - elif [ "${NREL_CLUSTER}" = "rhodes" ]; then - source /opt/base/env.sh - elif [ "${NREL_CLUSTER}" = "ellis" ]; then - MODULES_DATE=2023-05-11 - source /data/ssd1/software/${MODULES_DATE}/env.sh - export TMPDIR=/data/ssd1/home/${USER}/.tmp - fi - - # Load some custom modules - . ${HOME}/.oh-my-zsh/custom/functions_nrel_hpc.zsh - load_custom_modules - - # Nek5000 - export PATH="${HOME}/Nek5000/bin:${PATH}" - - -fi diff --git a/dot_zshrc b/dot_zshrc index 264ae22..9ef97e3 100644 --- a/dot_zshrc +++ b/dot_zshrc @@ -1,10 +1,3 @@ - -# paths for OLCF HPC, putting this in zshenv doesn't work -if [ "${LMOD_SYSTEM_NAME}" = "frontier" ]; then - . ${HOME}/.oh-my-zsh/custom/functions_olcf_hpc.zsh - load_custom_modules -fi - # Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc. # Initialization code that may require console input (password prompts, [y/n] # confirmations, etc.) must go above this block; everything else may go below. @@ -12,119 +5,80 @@ if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]] source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" fi -# If you come from bash you might have to change your $PATH. -# export PATH=$HOME/bin:/usr/local/bin:$PATH +### Added by Zinit's installer +if [[ ! -f $HOME/.local/share/zinit/zinit.git/zinit.zsh ]]; then + print -P "%F{33} %F{220}Installing %F{33}ZDHARMA-CONTINUUM%F{220} Initiative Plugin Manager (%F{33}zdharma-continuum/zinit%F{220})…%f" + command mkdir -p "$HOME/.local/share/zinit" && command chmod g-rwX "$HOME/.local/share/zinit" + command git clone https://github.com/zdharma-continuum/zinit "$HOME/.local/share/zinit/zinit.git" && \ + print -P "%F{33} %F{34}Installation successful.%f%b" || \ + print -P "%F{160} The clone has failed.%f%b" +fi + +source "$HOME/.local/share/zinit/zinit.git/zinit.zsh" +autoload -Uz _zinit +(( ${+_comps} )) && _comps[zinit]=_zinit + +# Load a few important annexes, without Turbo +# (this is currently required for annexes) +zinit light-mode for \ + zdharma-continuum/zinit-annex-as-monitor \ + zdharma-continuum/zinit-annex-bin-gem-node \ + zdharma-continuum/zinit-annex-patch-dl \ + zdharma-continuum/zinit-annex-rust + +### End of Zinit's installer chunk + +# towards the beginning to make sure some software is loaded +zinit lucid light-mode for "hpc" + +zinit ice lucid depth"1" +zinit light romkatv/powerlevel10k + +zinit wait lucid light-mode \ + dl'https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/plugins/emacs/emacsclient.sh' \ + atclone'chmod +x emacsclient.sh' \ + atpull'%atclone' \ + for "OMZP::emacs" + +zinit wait lucid light-mode for \ + "OMZP::fzf" \ + has'fzf' @Aloxaf/fzf-tab \ + "OMZP::git" \ + "OMZP::poetry" \ + "OMZP::pyenv" \ + "OMZP::tmux" \ + "OMZP::zoxide" + +zinit ice lucid from"gh-r" as"command" \ + mv"vivid-*/vivid -> vivid" \ + atload'export LS_COLORS="$(vivid generate one-dark)"; zstyle ":completion:*" list-colors "${(s.:.)LS_COLORS}"' +zinit light sharkdp/vivid + +# towards the end because it assumes some things are set in other plugins +zinit wait lucid light-mode for "personal" # Path to your oh-my-zsh installation. export ZSH=$HOME/.oh-my-zsh -# Set name of the theme to load --- if set to "random", it will -# load a random theme each time oh-my-zsh is loaded, in which case, -# to know which specific one was loaded, run: echo $RANDOM_THEME -# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes -ZSH_THEME="robbyrussell" - -# Set list of themes to pick from when loading at random -# Setting this variable when ZSH_THEME=random will cause zsh to load -# a theme from this variable instead of looking in ~/.oh-my-zsh/themes/ -# If set to an empty array, this variable will have no effect. -# ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" ) - -# If this variable is set the random theme won't choose any of the -# themes specified in this array. This is useful if you know -# specifically the themes that you don't like or don't work correctly -# in your environment. NOTE: if the ZSH_THEME_RANDOM_CANDIDATES -# variable is set (see above), this setting has no effect. -ZSH_THEME_RANDOM_IGNORED=( "dallas" "juanghurtado" ) - -# Uncomment the following line to use case-sensitive completion. -# CASE_SENSITIVE="true" - -# Uncomment the following line to use hyphen-insensitive completion. -# Case-sensitive completion must be off. _ and - will be interchangeable. -# HYPHEN_INSENSITIVE="true" - -# Uncomment the following line to disable bi-weekly auto-update checks. -# DISABLE_AUTO_UPDATE="true" - -# Uncomment the following line to automatically update without prompting. -# DISABLE_UPDATE_PROMPT="true" - -# Uncomment the following line to change how often to auto-update (in days). -# export UPDATE_ZSH_DAYS=13 - -# Uncomment the following line if pasting URLs and other text is messed up. -# DISABLE_MAGIC_FUNCTIONS=true - -# Uncomment the following line to disable colors in ls. -# DISABLE_LS_COLORS="true" - -# Uncomment the following line to disable auto-setting terminal title. -# DISABLE_AUTO_TITLE="true" - -# Uncomment the following line to enable command auto-correction. +# OMZL options +zstyle ':omz:lib:theme-and-appearance' gnu-ls yes ENABLE_CORRECTION="true" CORRECT_IGNORE_FILE='.*' -# Uncomment the following line to display red dots whilst waiting for completion. -# COMPLETION_WAITING_DOTS="true" - -# Uncomment the following line if you want to disable marking untracked files -# under VCS as dirty. This makes repository status check for large repositories -# much, much faster. -# DISABLE_UNTRACKED_FILES_DIRTY="true" - -# Uncomment the following line if you want to change the command execution time -# stamp shown in the history command output. -# You can set one of the optional three formats: -# "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd" -# or set a custom format using the strftime function format specifications, -# see 'man strftime' for details. -# HIST_STAMPS="mm/dd/yyyy" - -# Would you like to use another custom folder than $ZSH/custom? -# ZSH_CUSTOM=/path/to/new-custom-folder - # Which plugins would you like to load? # Standard plugins can be found in ~/.oh-my-zsh/plugins/* # Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/ # Example format: plugins=(rails git textmate ruby lighthouse) # Add wisely, as too many plugins slow down shell startup. -plugins=(battery emacs git screen tmux fzf poetry pyenv) +plugins=() source $ZSH/oh-my-zsh.sh # User configuration -# export MANPATH="/usr/local/man:$MANPATH" - # better terminal colors export TERM=xterm-256color -# You may need to manually set your language environment -# export LANG=en_US.UTF-8 - -# Preferred editor for local and remote sessions -# if [[ -n $SSH_CONNECTION ]]; then -# export EDITOR='vim' -# else -# export EDITOR='mvim' -# fi - -# Compilation flags -# export ARCHFLAGS="-arch x86_64" - -# Set personal aliases, overriding those provided by oh-my-zsh libs, -# plugins, and themes. Aliases can be placed here, though oh-my-zsh -# users are encouraged to define aliases within the ZSH_CUSTOM folder. -# For a full list of active aliases, run `alias`. -# -# Example aliases -# alias zshconfig="mate ~/.zshrc" -# alias ohmyzsh="mate ~/.oh-my-zsh" - - -# # This is a bit sneaky... but nice! # Separate up arrow lookback for local and global ZSH history # http://superuser.com/questions/446594/separate-up-arrow-lookback-for-local-and-global-zsh-history/691603 @@ -154,28 +108,29 @@ bindkey "^[[1;5B" down-line-or-history # [CTRL] + Cursor down bindkey "^P" up-line-or-beginning-search # bindkey "^N" down-line-or-beginning-search -# zplug -if [ -d "${ZPLUG_HOME}" ]; then - source "${ZPLUG_HOME}/init.zsh" - zplug "skywind3000/z.lua" - zplug "Aloxaf/fzf-tab" - zplug "romkatv/powerlevel10k", as:theme, depth:1 - zplug load - if ! zplug check; then - zplug install - fi -fi - -# Better history +# History HISTFILE=~/.zsh_history HISTSIZE=1000000 SAVEHIST=$HISTSIZE setopt HIST_IGNORE_ALL_DUPS setopt HIST_FIND_NO_DUPS -if [ "${NREL_CLUSTER}" = "eagle" ] || [ "${NREL_CLUSTER}" = "rhodes" ] || [ "${NREL_CLUSTER}" = "ellis" ]; then - umask u=rwx,go=rx,o=rx +# zsh history backups +export HIST_BACKUP_DIR="${HOME}/.zsh_history_backups" +if [ ! -d "${HIST_BACKUP_DIR}" ]; then + mkdir "${HIST_BACKUP_DIR}" fi +function backup_zsh_history () { + if [ -d "${HIST_BACKUP_DIR}" ]; then + HISTFILE_BAK="${HIST_BACKUP_DIR}/zsh_history_$(date +\%Y_\%m_\%d).bak" + if [ ! -f "${HISTFILE_BAK}" ]; then + cp "${HISTFILE}" "${HISTFILE_BAK}" + fi + fi +} + +backup_zsh_history + # To customize prompt, run `p10k configure` or edit ~/.p10k.zsh. [[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh diff --git a/run_once_after_install-python-setup.sh b/run_once_after_install-python-setup.sh new file mode 100644 index 0000000..946affe --- /dev/null +++ b/run_once_after_install-python-setup.sh @@ -0,0 +1,64 @@ +#!/usr/bin/env bash + +# start clean +# rm -rf $(pyenv root) +# curl -sSL https://install.python-poetry.org | POETRY_VERSION=1.7.0 POETRY_HOME=${HOME}/.poetry python3 - --uninstall + + +# Make sure python3 installation worked +if ! command -v python3 >/dev/null 2>&1; then + echo "Please install python3" + exit 1 +fi + +# Install pyenv and a sane python +if [[ ! -x "$(command -v pyenv)" ]]; then + curl https://pyenv.run | bash +fi + +export PYENV_ROOT="${HOME}/.pyenv" +if [ -d "${PYENV_ROOT}" ]; then + command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH" + eval "$(pyenv init -)" +fi + +PYTHON_VERSION="3.11.1" +${HOME}/bin/pyenv_python_install ${PYTHON_VERSION} + +# Install poetry with the pyenv python +if [[ ! -x "$(command -v poetry)" ]]; then + curl -sSL https://install.python-poetry.org | PYENV_VERSION=${PYTHON_VERSION} POETRY_VERSION=1.7.0 POETRY_HOME=${HOME}/.poetry python3 - +fi + +# Create a sane dotfiles venv +export PYENV_VERSION=${PYTHON_VERSION} +export WORKON_HOME=${HOME}/.virtualenvs +venv_name="dotfiles" +venv_location="${WORKON_HOME}/${venv_name}" + +echo "Installing dotfiles venv at ${venv_location} with $(python --version)" + +python -m venv "${venv_location}" +source ${venv_location}/bin/activate +python -m pip install --upgrade pip +pip install --requirement=/dev/stdin <> "${ENV_DIR}/spack.yaml" -fi +ENV_DIR="${SPACK_DIR}/var/spack/environments/${ENV_NAME}" +cmd "spack env activate --create ${ENV_NAME}" + + +cmd "spack add emacs@29.2+tls+native+treesitter+json%gcc" +# cmd "spack add emacs@28.2+tls+json%gcc" +# cmd "spack add ccls%gcc" cmd "spack concretize -f" -cmd "spack install" -cmd "spack module tcl refresh -y" +cmd "spack env deactivate" + +# MODULE_DIR="${HOME}/modules" + +# cmd "mkdir -p ${MODULE_DIR}" +# cmd "quick-create -n ${ENV_NAME}" +# cmd "quick-activate ${ENV_DIR}" + + +# if [ ! -z $(grep -L "modules:" "${ENV_DIR}/spack.yaml") ]; then +# echo "Adding modules to spack.yaml" +# echo " modules: +# default: +# roots: +# tcl: ${MODULE_DIR} +# tcl: +# projections: +# all: '{compiler.name}-{compiler.version}/{name}/{version}/{hash:4}' +# hash_length: 0 +# all: +# conflict: +# - '{name}' +# environment: +# set: +# '{name}_ROOT_DIR': '{prefix}' +# include: [emacs, ccls] +# exclude: ['%gcc']" >> "${ENV_DIR}/spack.yaml" +# fi + +# cmd "spack concretize -f" +# cmd "spack install" +# cmd "spack module tcl refresh -y" -cmd "touch ${MODULE_DIR}/linux-centos7-skylake_avx512/gcc-9.3.0/ccls/.version" -cmd "rm -rf ~/.lmod.d/.cache" +# cmd "touch ${MODULE_DIR}/linux-centos7-skylake_avx512/gcc-9.3.0/ccls/.version" +# cmd "rm -rf ~/.lmod.d/.cache" {{ end -}} \ No newline at end of file diff --git a/run_once_before_install-packages-cli.sh b/run_once_before_install-packages-cli.sh new file mode 100644 index 0000000..e73ecb8 --- /dev/null +++ b/run_once_before_install-packages-cli.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +if [ ! -d "${HOME}/.oh-my-zsh" ]; then + sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended --keep-zshrc +fi + +if [[ ! -x "$(command -v poetry)" ]]; then + curl -sSL https://install.python-poetry.org | POETRY_VERSION=1.7.0 POETRY_HOME=${HOME}/.poetry python3 - +fi + +if [[ ! -x "$(command -v zoxide)" ]]; then + curl -sS https://raw.githubusercontent.com/ajeetdsouza/zoxide/main/install.sh | bash +fi + diff --git a/run_once_before_install-packages-darwin.sh.tmpl b/run_once_before_install-packages-darwin.sh.tmpl index 4cf5ec3..61b8677 100644 --- a/run_once_before_install-packages-darwin.sh.tmpl +++ b/run_once_before_install-packages-darwin.sh.tmpl @@ -3,9 +3,12 @@ brew bundle --no-lock --file=/dev/stdin </dev/null 2>&1; then - echo "Please install python3" - exit 1 -fi - -export WORKON_HOME=${HOME}/.virtualenvs -venv_name="dotfiles" -venv_location="${WORKON_HOME}/${venv_name}" - -python3 -m venv "${venv_location}" -source ${venv_location}/bin/activate -python3 -m pip install --upgrade pip -pip3 install --requirement=/dev/stdin <