|
# zshrc config file for UNIX and MacOS with using oh-my-zsh, Jan Valosek |
|
# many another useful aliases can be found here - https://www.cyberciti.biz/tips/bash-aliases-mac-centos-linux-unix.html |
|
|
|
# OS specific commands are in case statement below |
|
case `uname` in |
|
Darwin) |
|
# commands for OS X |
|
# Default prompt |
|
PS1='%F{green}%n@%m%f:%F{cyan}%~$%f ' |
|
# Alias for colorful ls output |
|
alias ls='CLICOLOR_FORCE=1 ls -G' |
|
# nano from homebrew |
|
alias nano='${HOMEBREW_CELLAR}/nano/7.1/bin/nano' |
|
|
|
# Path to oh-my-zsh installation |
|
export ZSH="$HOME/.oh-my-zsh" |
|
|
|
# oh-my-zsh plugins |
|
# Standard plugins can be found in $ZSH/plugins/ |
|
# Custom plugins may be added to $ZSH_CUSTOM/plugins/ |
|
plugins=( |
|
git |
|
git-prompt |
|
percol |
|
timer |
|
) |
|
|
|
# Load autosuggestions zsh plugin installed by brew |
|
source /usr/local/share/zsh-autosuggestions/zsh-autosuggestions.zsh |
|
# Load syntax-highlighting zsh plugin installed by brew |
|
source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh |
|
;; |
|
Linux) |
|
# commands for Linux |
|
# Default prompt - color codes - https://jonasjacek.github.io/colors/ |
|
PS1='%F{76}%n@%m%f:%F{74}%~$%f ' |
|
# Alias for colorful ls output |
|
alias ls='ls --color=always' |
|
# alias for venv creation |
|
alias ce='virtualenv -p /usr/bin/python3 venv; echo "venv was created successfully"' |
|
|
|
# Allow moving between words in zsh command using ctrl + left_arrow and ctrl + right_arrow |
|
# (on MacOS, moving can be done by option + left_arrow or right_arrow) |
|
bindkey -e |
|
bindkey '^[[1;5C' forward-word |
|
bindkey '^[[1;5D' backward-word |
|
# Permissions |
|
umask 0002 |
|
|
|
# Path to oh-my-zsh installation |
|
export ZSH="/home/valosek/.oh-my-zsh" |
|
|
|
# Fix folder permission issue cause by zsh plugin zsh-autosuggestions |
|
# https://github.com/ohmyzsh/ohmyzsh/issues/6835#issuecomment-390216875 |
|
ZSH_DISABLE_COMPFIX=true |
|
|
|
# oh-my-zsh plugins |
|
# Standard plugins can be found in $ZSH/plugins/ |
|
# Custom plugins may be added to $ZSH_CUSTOM/plugins/ |
|
plugins=( |
|
git-prompt |
|
percol |
|
timer |
|
zsh-autosuggestions |
|
zsh-syntax-highlighting |
|
) |
|
;; |
|
esac |
|
|
|
HYPHEN_INSENSITIVE="true" |
|
source $ZSH/oh-my-zsh.sh |
|
|
|
# Speed up pasting into zsh terminal |
|
# https://github.com/zsh-users/zsh-autosuggestions/issues/238#issuecomment-389324292 |
|
# https://github.com/zsh-users/zsh-autosuggestions/issues/238 |
|
pasteinit() { |
|
OLD_SELF_INSERT=${${(s.:.)widgets[self-insert]}[2,3]} |
|
zle -N self-insert url-quote-magic # I wonder if you'd need `.url-quote-magic`? |
|
} |
|
pastefinish() { |
|
zle -N self-insert $OLD_SELF_INSERT |
|
} |
|
zstyle :bracketed-paste-magic paste-init pasteinit |
|
zstyle :bracketed-paste-magic paste-finish pastefinish |
|
|
|
# Oh-my-zsh logo |
|
typeset -a RAINBOW |
|
RAINBOW=( |
|
"$(printf '\033[38;5;196m')" |
|
"$(printf '\033[38;5;202m')" |
|
"$(printf '\033[38;5;226m')" |
|
"$(printf '\033[38;5;082m')" |
|
"$(printf '\033[38;5;021m')" |
|
"$(printf '\033[38;5;093m')" |
|
"$(printf '\033[38;5;163m')" |
|
) |
|
RESET=$(printf '\033[0m') |
|
|
|
printf '%s %s__ %s %s %s %s %s__ %s\n' $RAINBOW $RESET |
|
printf '%s ____ %s/ /_ %s ____ ___ %s__ __ %s ____ %s_____%s/ /_ %s\n' $RAINBOW $RESET |
|
printf '%s / __ \\%s/ __ \\ %s / __ `__ \\%s/ / / / %s /_ / %s/ ___/%s __ \\ %s\n' $RAINBOW $RESET |
|
printf '%s/ /_/ /%s / / / %s / / / / / /%s /_/ / %s / /_%s(__ )%s / / / %s\n' $RAINBOW $RESET |
|
printf '%s\\____/%s_/ /_/ %s /_/ /_/ /_/%s\\__, / %s /___/%s____/%s_/ /_/ %s\n' $RAINBOW $RESET |
|
printf '%s %s %s %s /____/ %s %s %s %s\n' $RAINBOW $RESET |
|
printf '\n' |
|
|
|
# Keep 5000 lines of history within the shell and save it to ~/.zsh_history: |
|
HISTSIZE=5000 |
|
SAVEHIST=5000 |
|
HISTFILE=~/.zsh_history |
|
|
|
# Aliases |
|
#alias ll='ls -lath --color=auto' |
|
alias ll='ls -lath' |
|
alias grep='grep --color=auto' |
|
#alias lh='ls -lath | head -10' |
|
#alias lt='ls -lath | tail -10' |
|
# Functions for ls in combination with head or tail commands with definable number of output lines |
|
function lh { if [ "$#" -eq 0 ];then num=10;else num=${1};fi; ls -lath | head -${num} } |
|
function lt { if [ "$#" -eq 0 ];then num=10;else num=${1};fi; ls -lath | tail -${num} } |
|
alias ff='fsleyes_preset' |
|
function column_tsv { column -t -s $'\t' ${1} } |
|
function column_csv { column -t -s $';' ${1} } |
|
|
|
# Functions for fetching useful nifti image header info using SCT |
|
function header { sct_image -i ${1} -header } |
|
function orientation { sct_image -i ${1} -header | grep -E qform_[xyz] | awk '{printf "%s", substr($2, 1, 1)}' } |
|
function pixdim { sct_image -i ${1} -header | grep pixdim } |
|
|
|
# Alias for which command (to have same behaviour as in bash) |
|
# https://stackoverflow.com/a/14196212/12605960 |
|
alias which='whence -p' |
|
|
|
# Preserve user enviroment and config (i.e., zsh shell) also for root user |
|
# https://github.com/ohmyzsh/ohmyzsh/issues/5311#issuecomment-240106715 |
|
alias suroot='sudo -E -s' |
|
|
|
# aliases for venv workflow |
|
# https://www.youtube.com/watch?v=fTs7yAIUiso |
|
#alias ae='deactivate &> /dev/null; source ./venv/bin/activate' |
|
#alias de='deactivate' |
|
|
|
# aliases for venv workflow |
|
# https://www.youtube.com/watch?v=fTs7yAIUiso |
|
# activate venv |
|
alias ae='deactivate &> /dev/null; source ./venv/bin/activate' |
|
# deactivate venv |
|
alias de='deactivate' |
|
# create venv (and install requirements if requirements.txt file exists) |
|
function ce { python3 -m venv venv; echo "venv was created successfully"; if [ -f requirements.txt ]; then echo "requirements.txt file found, installing dependencies..."; source ./venv/bin/activate; pip install -r requirements.txt;fi } |
|
|
|
# Use modern completion system |
|
autoload -Uz compinit |
|
# Ignore insecure directories |
|
compinit -i # Ignore insecure directories |
|
|
|
# Uncomment the following line to enable command auto-correction |
|
setopt correct |
|
|
|
# Auto cd |
|
setopt autocd |
|
|
|
# Shared history between terminals |
|
setopt sharehistory |
|
# History substitution (replacement of !!) |
|
setopt HIST_VERIFY |
|
|
|
# Case insensitive globbing |
|
setopt NO_CASE_GLOB |
|
|
|
# Disable globbing - https://unix.stackexchange.com/a/310553 |
|
setopt +o nomatch |
|
|
|
# Prevent perl language warning (https://gist.github.com/madeagency/79dc86e8aa09aa512af5) |
|
export LC_CTYPE=en_US.UTF-8 |
|
export LC_ALL=en_US.UTF-8 |
|
|
|
# SCT |
|
export PATH="/usr/local/sct/bin:$PATH" |
|
export SCT_DIR=/usr/local/sct |
|
export MPLBACKEND=Agg |
|
|
|
# FSL |
|
export PATH=$PATH:/usr/local/fsl/bin |
|
export FSLDIR=/usr/local/fsl |
|
. ${FSLDIR}/etc/fslconf/fsl.sh |
|
|
|
echo "FSLDIR $FSLDIR" |
|
echo "SCT_DIR $SCT_DIR" |
|
|
|
# Python 3.8 installed from homebrew |
|
export PATH="/opt/homebrew/opt/python@3.8/bin:$PATH" |
|
|
|
# Print currently used python version into CLI |
|
echo "python3 $(python3 -V)" |
Path for FSL does not work in some cases. While using this specification of FSL path, I was not able to run FSLeyes (app crashed due to some errors). I replaced this part of code (lines 168-170) as follows:
source fsl-activator 6.0.5
Now I'm able to run FSL wtihouth any errors.