From b8f38ee429a65ac795935e9a11222c802cb20d53 Mon Sep 17 00:00:00 2001 From: Sage Vaillancourt Date: Wed, 13 Dec 2023 15:00:04 -0500 Subject: [PATCH] Add stv and ishelp to shell_aliases Fix pushdot and getdot functions --- fake_home/.shell_aliases | 18 ++++++++++++++++++ fake_home/.zshrc | 6 ++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/fake_home/.shell_aliases b/fake_home/.shell_aliases index ecd2d20..3fe6e92 100755 --- a/fake_home/.shell_aliases +++ b/fake_home/.shell_aliases @@ -1,5 +1,23 @@ #!/bin/bash +function ishelp { + [[ "$1" == "help" ]] || [[ "$1" == "-h" ]] || [[ "$1" == "--help" ]] +} + +function stv { + local stash=0 + if ishelp $1; then + echo "Show the diff for the given stash. Default to 0" + return + fi + if [[ "${1:0:1}" == "^" ]]; then + stash=${#1} + elif [[ "$1" != "" ]]; then + stash="$1" + fi + git stash show -p stash@{$stash} +} + function hearch { history 0 | sed 's/[0-9 ]*//' | grep "$@" } diff --git a/fake_home/.zshrc b/fake_home/.zshrc index 4d6640f..990b271 100644 --- a/fake_home/.zshrc +++ b/fake_home/.zshrc @@ -1,3 +1,5 @@ +export SCRIPT_DIR="${0:A:h}" + if test -f /usr/share/doc/fzf/examples/completion.zsh &> /dev/null; then source /usr/share/doc/fzf/examples/completion.zsh fi @@ -65,7 +67,7 @@ if [ "$TERM" = "linux" ]; then fi function pushdot { - cd ~/.dotfiles && + cd "$SCRIPT_DIR" || return 1 if [ $# -eq 0 ]; then git commit -a && git push -u origin master & else @@ -75,7 +77,7 @@ function pushdot { } function getdot { - cd ~/.dotfiles && + cd "$SCRIPT_DIR" || return 1 git pull cd - }