Skip to content

Commit

Permalink
fish: add basic scmpuff for fish
Browse files Browse the repository at this point in the history
  • Loading branch information
paulirish committed Nov 21, 2017
1 parent 6f54e27 commit 9585ac1
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 1 deletion.
35 changes: 35 additions & 0 deletions fish/conf.d/scmpuff.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
set -x SCMPUFF_GIT_CMD (which git)

if type -q hub
set -x SCMPUFF_GIT_CMD "hub"
end


if not type -q scmpuff
exit 1
end

functions -e git
alias gs=scmpuff_status

function git
type -q $SCMPUFF_GIT_CMD; or set -x SCMPUFF_GIT_CMD (which git)

if test (count $argv) -eq 0
eval $SCMPUFF_GIT_CMD
set -l s $status
return $s
end

switch $argv[1]
case c commit blame log rebase merge
eval command (scmpuff expand -- "$SCMPUFF_GIT_CMD" $argv)
case checkout diff rm reset
eval command (scmpuff expand --relative -- "$SCMPUFF_GIT_CMD" $argv)
case add
eval command (scmpuff expand -- "$SCMPUFF_GIT_CMD" $argv)
scmpuff_status
case '*'
eval command "$SCMPUFF_GIT_CMD" $argv
end
end
4 changes: 3 additions & 1 deletion fish/config.fish
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
set default_user "paulirish"
set default_machine "paulirish-macbookair2"


source ~/.config/fish/path.fish
source ~/.config/fish/aliases.fish
source ~/.config/fish/chpwd.fish
source ~/.config/fish/functions.fish
source ~/.config/fish/chromium.fish
source ~/.config/fish/conf.d/scmpuff.fish

# for things not checked into git..
if test -e "$HOME/.extra.fish";
Expand Down Expand Up @@ -97,4 +99,4 @@ set -gx LESS_TERMCAP_us \e'[04;38;5;146m' # begin underline

# tabtab source for yarn package
# uninstall by removing these lines or running `tabtab uninstall yarn`
[ -f $HOME/.config/yarn/global/node_modules/tabtab/.completions/yarn.fish ]; and . $HOME/.config/yarn/global/node_modules/tabtab/.completions/yarn.fish
[ -f /Users/paulirish/.config/yarn/global/node_modules/tabtab/.completions/yarn.fish ]; and . /Users/paulirish/.config/yarn/global/node_modules/tabtab/.completions/yarn.fish
8 changes: 8 additions & 0 deletions fish/functions/scmpuff_clear_vars.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
function scmpuff_clear_vars
set -l scmpuff_env_char "e"
set -l scmpuff_env_vars (set -x | awk '{print $1}' | grep -E '^'$scmpuff_env_char'\d+')

for v in $scmpuff_env_vars
set -e $v
end
end
20 changes: 20 additions & 0 deletions fish/functions/scmpuff_status.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

function scmpuff_status
scmpuff_clear_vars
set -lx scmpuff_env_char "e"
set -l cmd_output (/usr/bin/env scmpuff status --filelist $argv)
set -l es "$status"

if test $es -ne 0
return $es
end

set -l files (string split \t $cmd_output[1])
for e in (seq (count $files))
set -gx "$scmpuff_env_char""$e" "$files[$e]"
end

for line in $cmd_output[2..-1]
echo $line
end
end

0 comments on commit 9585ac1

Please sign in to comment.