dotfiles/zsh/.zshrc

84 lines
2.0 KiB
Bash

autoload compinit
compinit
# Menu driven command completion.
zstyle ':completion:*' menu select
# Make ZSH complete aliases.
setopt COMPLETE_ALIASES
# Allow ZSH to complete in priviliged environments.
zstyle ':completion::complete:*' gain-privileges 1
## case-insensitive (uppercase from lowercase) completion
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}'
autoload -U colors && colors
# When typing a directory name cd to it.
setopt autocd
# Add ~/bin and ~/bin.scripts to my path
export PATH=$PATH:$HOME/bin/:$HOME/bin/scripts/:$HOME/.emacs.d/bin/
# Set the prompt.
export PS1="[%F{6}%n%f@%M %F{4}%(5~|%-1~/…/%3~|%4~)%f] "
# Function to download a full youtube playlist using youtube-dl.
function playlist-dl {
echo "Looking up playlist name..."
pl_line=$(youtube-dl --flat-playlist "$1" | grep "\[download\] Downloading playlist: ")
pl_name=$(echo ${pl_line:33} | tr '/' ' ')
echo "Found playlist by name: $pl_name"
echo "Downloading it into directory: $pl_name"
mkdir "$pl_name"
cd "$pl_name"
youtube-dl --extract-audio --audio-format mp3 -o "%(title)s.%(ext)s" "$1"
cd ../
}
function cd-courses {
dir=$(ls ~/Uni | fzf)
cd ~/Uni/$dir
}
function cd-projects {
dir=$(find ~/Projects -maxdepth 3 -type d | fzf)
cd $dir
}
function script-edit {
scripts=$(ls ~/bin/scripts/)"$(echo -e "\nzshrc")"
selected=$(echo $scripts | fzf)
case $selected in
"zshrc")
nvim ~/.zshrc
;;
*)
nvim ~/bin/scripts/$selected
;;
esac
}
function compile {
gcc -no-pie -g -o $2 $1
}
# Set EDITOR to be nvim.
export EDITOR=nvim
# Aliases
alias ls="lsd"
alias grep="grep --color"
alias vim="nvim"
alias vi="nvim"
alias open="xdg-open"
alias gg="git-graph --model simple --color always | less -r"
alias gi="gitinspector --grading=true -f \"java,fxml,css,py,html\" -F html -x author:\"OOP Project Team\""
alias se="script-edit"
alias c="cd-courses"
alias proj="cd-projects"
# Add fish like syntax highlighting to zsh.
source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh