From 43426f7ac57c56f3acbd7b5bc92efb7a28a80d4e Mon Sep 17 00:00:00 2001 From: bretello Date: Mon, 24 Jan 2022 11:33:53 +0100 Subject: [PATCH] zsh: add new functions: git-diff-branch, falias, make_backup, make_venv --- functions.zsh | 37 ++++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/functions.zsh b/functions.zsh index bbcf18c..8d576f0 100755 --- a/functions.zsh +++ b/functions.zsh @@ -280,6 +280,11 @@ git-fixup() { git -c sequence.editor=true rebase --interactive --autosquash $1^ } +compdef __git_branch_names git-diff-branch +git-diff-branch() { + git diff $@ +} + if command -v pacman &>/dev/null ; then compdef _pacman_completions_installed_packages pacbins pacbins() { @@ -294,7 +299,33 @@ then } fi -# dotfiles user functions -if [[ -f $HOME/.dotfiles_functions ]]; then - source "$HOME/.dotfiles_functions" +if command -v fzf &>/dev/null ; then + compdef _fzf_complete + falias() { + alias | fzf $@ | cut -d= -f 1 + } fi + +make_backup() { + name="$1" + backup_name="backup_$1_$(date +%Y-%m-%d).tar.gz" + echo "Backing up to $backup_name" + tar -czf "$backup_name" "$1" + echo "done" +} + +make_venv(){ + python -m venv .venv && echo "created venv: .venv" + + read -q source_venv + + if [[ $source_venv == "y" ]]; then + source .venv/bin/activate && echo "sourced venv" + fi + +} + +# # dotfiles user functions +# if [[ -f $HOME/.dotfiles_functions ]]; then +# source "$HOME/.dotfiles_functions" +# fi