dotfiles/zsh/.zshrc

84 lines
2.0 KiB
Bash
Raw Normal View History

2022-02-06 19:45:28 +01:00
autoload compinit
2020-11-02 18:46:24 +01:00
2022-02-06 19:45:28 +01:00
compinit
2020-11-02 18:46:24 +01:00
# 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
2022-02-06 19:45:28 +01:00
## 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
2020-11-02 18:46:24 +01:00
2022-02-06 19:45:28 +01:00
# 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] "
2020-11-02 18:46:24 +01:00
# Function to download a full youtube playlist using youtube-dl.
function playlist-dl {
echo "Looking up playlist name..."
2022-02-06 19:45:28 +01:00
pl_line=$(youtube-dl --flat-playlist "$1" | grep "\[download\] Downloading playlist: ")
pl_name=$(echo ${pl_line:33} | tr '/' ' ')
2020-11-02 18:46:24 +01:00
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"
2022-02-06 19:45:28 +01:00
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
2020-11-02 18:46:24 +01:00
}
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"
2022-02-06 19:45:28 +01:00
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"
2020-11-02 18:46:24 +01:00
# Add fish like syntax highlighting to zsh.
source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh