zsh: add new functions: git-diff-branch, falias, make_backup, make_venv

pull/6/head
bretello 2022-01-24 11:33:53 +01:00
parent c6d444c709
commit 43426f7ac5
Signed by: brethil
GPG Key ID: 876AAC6290170FE7
1 changed files with 34 additions and 3 deletions

View File

@ -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