Last active
December 3, 2019 20:46
-
-
Save gmolveau/482fbeb36c107e65fee3cab31bc0588a to your computer and use it in GitHub Desktop.
my .zshrc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export ZSH=$HOME/.oh-my-zsh | |
### REQUIREMENTS | |
function reinstall() { | |
echo "installing oh-my-zsh \n" | |
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" | |
echo "installing plugins \n" | |
curl -L https://iterm2.com/shell_integration/zsh -o ~/.iterm2_shell_integration.zsh | |
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting | |
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions | |
} | |
# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes | |
ZSH_THEME="robbyrussell" | |
# Standard plugins can be found in ~/.oh-my-zsh/plugins/* | |
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/ | |
# Add wisely, as too many plugins slow down shell startup. | |
plugins=( | |
git | |
python | |
zsh-autosuggestions | |
zsh-syntax-highlighting | |
) | |
source $ZSH/oh-my-zsh.sh | |
# Sublime Text configuration | |
# on Mac OSX : ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /usr/local/bin/sublime | |
export EDITOR='sublime -w' | |
export LC_ALL=en_US.UTF-8 | |
# Custom aliases and functions | |
alias ll="ls -alh" | |
alias myip="dig +short myip.opendns.com @resolver1.opendns.com" | |
alias delete_ds_store="find . -name '.DS_Store' -type f -delete" | |
alias shrug='echo -E "¯\_(ツ)_/¯" | tee /dev/tty | pbcopy' | |
# cd to the parent directory of a file, usefull when drag-dropping a file into the terminal | |
function fcd () { [ -f "$1" ] && { cd "$(dirname "$1")"; } || { cd "$1"; } ; pwd; } | |
# create a new directory and enter it - mkdir + cd | |
function mkd () { | |
mkdir -p "$@" && cd "$_"; | |
} | |
# rename files to underscore-only no accent | |
function fformat () { | |
for f in *; do pre="${f%.*}"; suf="${f##*.}"; mv "$f" $(echo $pre | iconv -f utf8 -t ascii//TRANSLIT | sed -E 's/[^[:alnum:]]+/_/g' <<<"$s").${suf}; done | |
# example : "MRC1 _ l'étude çours-f.25122019.pptx" >>> "MRC1_l_etude_cours_f_25122019.pptx" | |
} | |
# wrapper for easy extraction of compressed files | |
function extract () { | |
if [ -f $1 ] ; then | |
case $1 in | |
*.tar.xz) tar xvJf $1 ;; | |
*.tar.bz2) tar xvjf $1 ;; | |
*.tar.gz) tar xvzf $1 ;; | |
*.bz2) bunzip2 $1 ;; | |
*.rar) unrar e $1 ;; | |
*.gz) gunzip $1 ;; | |
*.tar) tar xvf $1 ;; | |
*.tbz2) tar xvjf $1 ;; | |
*.tgz) tar xvzf $1 ;; | |
*.apk) unzip $1 ;; | |
*.epub) unzip $1 ;; | |
*.xpi) unzip $1 ;; | |
*.zip) unzip $1 ;; | |
*.war) unzip $1 ;; | |
*.jar) unzip $1 ;; | |
*.Z) uncompress $1 ;; | |
*.7z) 7z x $1 ;; | |
*) echo "don't know how to extract '$1'..." ;; | |
esac | |
else | |
echo "'$1' is not a valid file!" | |
fi | |
} | |
# create a random temp folder and cd into it | |
function tmp { | |
cd $(mktemp -d /tmp/$1.XXXX) | |
} | |
function cjd () { # https://johnnydecimal.com/concepts/working-at-the-terminal/ | |
pushd ~/Nextcloud/Documents/*/*/${1}* | |
} | |
function youtube-mp3 () { | |
youtube-dl --ignore-errors -f bestaudio --extract-audio --audio-format mp3 --audio-quality 0 -o '~/Music/%(title)s.%(ext)s' "$1" | |
} | |
function youtube-mp4() { | |
youtube-dl --write-auto-sub -no-playlist -f 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/mp4' -o '~/Movies/%(title)s.%(ext)s' "$1" | |
} | |
function pdfcompress() { | |
# https://gist.github.com/ahmed-musallam/27de7d7c5ac68ecbd1ed65b6b48416f9 | |
gs -q -dNOPAUSE -dBATCH -dSAFER -sDEVICE=pdfwrite -dCompatibilityLevel=1.3 -dPDFSETTINGS=/screen -dEmbedAllFonts=true -dSubsetFonts=true -dColorImageDownsampleType=/Bicubic -dColorImageResolution=144 -dGrayImageDownsampleType=/Bicubic -dGrayImageResolution=144 -dMonoImageDownsampleType=/Bicubic -dMonoImageResolution=144 -sOutputFile=compressed.$1 $1; | |
} | |
# PATH update | |
export PATH=$PATH:/usr/local/bin:/usr/local/sbin | |
# User binaries | |
export USER_BIN=$HOME/bin | |
export PATH=$PATH:$USER_BIN | |
# Golang configuration | |
export GOPATH=$HOME/go | |
export GOBIN=$GOPATH/bin | |
export PATH=$PATH:$GOBIN | |
# Rust configuration | |
export CARGO_BIN=$HOME/.cargo/bin | |
export PATH=$PATH:$CARGO_BIN | |
# Pip binaries | |
export PIP_BIN=$HOME/Library/Python/3.7/bin | |
export PATH=$PATH:$PIP_BIN | |
# Node configuration (LTS with brew) | |
export NODE_BIN=/usr/local/opt/node@10/bin | |
export PATH=$PATH:$NODE_BIN | |
test -e "${HOME}/.iterm2_shell_integration.zsh" && source "${HOME}/.iterm2_shell_integration.zsh" | |
autoload -Uz compinit && compinit -i |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment