Browse Source

Updated julia aliases and features

master
Micah Halter 5 months ago
parent
commit
9e44fcffdc
Signed by: mehalter GPG Key ID: 4224A6EA9A8CAAA8
2 changed files with 83 additions and 10 deletions
  1. +1
    -0
      CHANGELOG.md
  2. +82
    -10
      zsh/.config/zsh/aliases

+ 1
- 0
CHANGELOG.md View File

@ -24,6 +24,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Changed
- Updated `julia` aliases and utilities
- Added Font features to font configuration
- Patched Symbola font with NERD Fonts
- Fix `bemenu` mounting/unmounting scripts


+ 82
- 10
zsh/.config/zsh/aliases View File

@ -113,20 +113,92 @@ jt() {
jupyter console --kernel=$kern
}
# julia functions
# === Julia Utilities: ===
## Call base julia installations or run virtual environment if activated
jl() {
if type julia >/dev/null; then
julia ${@}
else
$JULIA_HOME/julia-${1}/bin/julia ${@:2}
fi
}
## Activate a virtual environment by name (default="env")
jlactivate() {
[ ! -z "$VIRTUAL_ENV" ] && deactivate
venv_dir="$1"
[ -z "$1" ] && venv_dir="env"
[ ! -e "$venv_dir" ] && venv_dir="$JULIA_HOME/environments/$1"
. $venv_dir/bin/activate
[ ! -z "${VIRTUAL_ENV}" ] && deactivate
venv_dir="${1}"
[ -z "${1}" ] && venv_dir="env"
[ ! -e "${venv_dir}" ] && venv_dir="${JULIA_HOME}/environments/${1}"
. ${venv_dir}/bin/activate
}
## Create a new virtual environment by name (default="env")
jlenv() {
venv_dir="$1"
[ -z "$1" ] && venv_dir="env"
julia -e "using VirtualEnv; venv(\"$venv_dir\"; $2)"
if type julia >/dev/null; then
ver=""
venv_dir="${1}"
opts="${2}"
else
ver="${1}"
venv_dir="${2}"
opts="${3}"
fi
[ -z "${venv_dir}" ] && venv_dir="env"
jl ${ver} -e "using VirtualEnv; venv(\"${venv_dir}\"; ${opts})"
}
alias jlsetup='julia -e "using Pkg; Pkg.add(\"Juno\"); Pkg.add(\"Atom\"); Pkg.add(\"IJulia\"); Pkg.add(\"LanguageServer\"); Pkg.add(\"SymbolServer\"); Pkg.add(\"StaticLint\"); Pkg.add(\"Revise\"); Pkg.precompile()"'
## Install basic packages in new Julia virtual environment
jlsetup() { jl ${@} -e 'using Pkg; Pkg.add(["PackageCompiler", "IJulia", "LanguageServer", "SymbolServer", "StaticLint", "Revise"]); Pkg.precompile()' && jlpkginstall && jlkernclean }
## Install jlpkg into virtual environments, don't use for base julia installs
jlpkginstall() {
if type julia >/dev/null; then
jl -e "using Pkg; Pkg.add(\"jlpkg\"); import jlpkg; jlpkg.install(destdir=\"${VIRTUAL_ENV}/bin\",force=true)"
fi
}
## Create a new environment, activate it, and run the setup alias
jlenvsetup() { jlenv ${@} && jlactivate && jlsetup }
## Create a Jupyter kernel for the current environment
jlkern() {
if [ -z "${VIRTUAL_ENV}" ]; then
ver="${1}"
envname="-Base"
[ -n "${2}" ] && envname="-${2}"
name="Julia${envname}"
opts="${3}"
else
ver=""
env=$(basename ${VIRTUAL_ENV})
[[ ${env} == "env" ]] && env=$(basename $(dirname ${VIRTUAL_ENV}))
envname=""
[ -n "${1}" ] && envname="-${1}"
name="Julia-${env}${envname}"
opts="${2}"
fi
envopts=""
[ -n "${JULIA_DEPOT_PATH}" ] && envopts="env=Dict(\"JULIA_DEPOT_PATH\"=>\"${JULIA_DEPOT_PATH}\")"
jl ${ver} -e "using IJulia; installkernel(\"${name}\", \"--project\"${opts}; ${envopts});"
}
## Delete automatic kernels made by IJulia
jlkernclean() { find ${XDG_DATA_HOME}/jupyter/kernels -type d -name 'julia-[0-9]*\.[0-9]*' -exec rm -rf {} + }
## Create a Jupyter kernel for the current environment with a custom system image
alias jlsyskern='[ -f ${VIRTUAL_ENV}/SysImage.so ] && jlkern Sys ", \"-J${VIRTUAL_ENV}/SysImage.so\""'
## Start Julia using the virtual environment's custom system image
alias jlsys='[ -f ${VIRTUAL_ENV}/SysImage.so ] && jl -J${VIRTUAL_ENV}/SysImage.so'
## Start Julia in the virtual environment project
jlsysproj() { [ -n "${VIRTUAL_ENV}" ] && jl --project=${VIRTUAL_ENV} ${@} }
## Run jlpkg in the virtual environment project
jlsyspkg() { [ -n "${VIRTUAL_ENV}" ] && jlpkg --project=${VIRTUAL_ENV} ${@} }
## Build the system image for the current virtual environment
alias jlbuildsysimage='[ -f "${VIRTUAL_ENV}/Project.toml" ] && jlsysproj -e "using PackageCompiler, Pkg; create_sysimage([Symbol(k) for k in keys(Pkg.installed())]; sysimage_path=\"${VIRTUAL_ENV}/SysImage.so\")"'
# git aliases
alias lg='lazygit'


Loading…
Cancel
Save