Skip to content

Commit

Permalink
zsh update (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
marchdf authored Apr 5, 2024
1 parent d730d67 commit 5dc11f6
Show file tree
Hide file tree
Showing 23 changed files with 659 additions and 556 deletions.
21 changes: 19 additions & 2 deletions .chezmoi.toml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
1 change: 0 additions & 1 deletion .chezmoiignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
42 changes: 42 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -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
46 changes: 46 additions & 0 deletions bin/executable_pyenv_python_install.tmpl
Original file line number Diff line number Diff line change
@@ -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
10 changes: 7 additions & 3 deletions bin/executable_teatimer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions conda-env/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ channels:
- conda-forge
- defaults
dependencies:
- python=3.10
- python=3.11
- black
- ipython
- line_profiler
Expand All @@ -22,6 +22,5 @@ dependencies:
- seaborn
- snakeviz
- sphinx
- toml
- yt
prefix: /home/mhenryde/miniconda3/envs/main
25 changes: 13 additions & 12 deletions dot_emacs
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down
120 changes: 120 additions & 0 deletions dot_local/share/zinit/plugins/hpc/hpc.plugin.zsh.tmpl
Original file line number Diff line number Diff line change
@@ -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=[[[,]]]
Loading

0 comments on commit 5dc11f6

Please sign in to comment.