├── config.fish ├── functions ├── rvm.fish └── fish_prompt.fish └── completions └── git.fish /config.fish: -------------------------------------------------------------------------------- 1 | set -x PATH /usr/local/bin ~/bin $PATH 2 | set -x EDITOR "mate -w" 3 | 4 | # RBENV 5 | set PATH $HOME/.rbenv/bin $PATH 6 | set PATH $HOME/.rbenv/shims $PATH 7 | rbenv rehash >/dev/null ^&1 8 | -------------------------------------------------------------------------------- /functions/rvm.fish: -------------------------------------------------------------------------------- 1 | function rvm -d 'Ruby enVironment Manager' 2 | set -l rvm_script '' 3 | if test -e /usr/local/rvm/scripts/rvm 4 | set rvm_script /usr/local/rvm/scripts/rvm 5 | end 6 | if test -e $HOME/.rvm/scripts/rvm 7 | set rvm_script $HOME/.rvm/scripts/rvm 8 | end 9 | set -l env_file (mktemp -t rvm.fish.XXXXXXXXXX) 10 | bash -c 'source '$rvm_script'; rvm "$@"; status=$?; env > "$0"; exit $status' $env_file $argv 11 | and eval (grep '^rvm\|^[^=]*PATH' $env_file | grep -v _clr | sed '/^[^=]*PATH/y/:/ /; s/^/set -xg /; s/=/ /; s/$/ ;/; s/(//; s/)//') 12 | rm -f $env_file 13 | end 14 | -------------------------------------------------------------------------------- /functions/fish_prompt.fish: -------------------------------------------------------------------------------- 1 | set fish_git_dirty_color red 2 | set fish_git_branch_color purple 3 | set fish_ruby_version_color yellow 4 | 5 | function prompt_git_dirty 6 | git diff > /dev/null 2>&1 7 | if test $status != 0 8 | echo ' ✗' 9 | end 10 | end 11 | 12 | function prompt_ruby_version 13 | printf '%s(%s) ' (set_color $fish_ruby_version_color) (ruby --version | cut -d' ' -f1,2) 14 | end 15 | 16 | function prompt_git_branch 17 | set -l branch (git symbolic-ref HEAD 2> /dev/null | cut -d/ -f3-) 18 | if test -n "$branch" 19 | printf "%s[%s%s] " (set_color $fish_git_branch_color) $branch (prompt_git_dirty) 20 | end 21 | end 22 | 23 | function prompt_dollor 24 | printf '%s$ ' (set_color $fish_color_normal) 25 | end 26 | 27 | function fish_prompt 28 | printf '%s%s %s%s %s%s%s%s' (set_color aaaaaa) (hostname|cut -d . -f 1) (set_color 00ffff) (prompt_pwd) (prompt_git_branch) (prompt_ruby_version) (prompt_dollor) 29 | end -------------------------------------------------------------------------------- /completions/git.fish: -------------------------------------------------------------------------------- 1 | # fish completion for git 2 | 3 | function __fish_git_branches 4 | git branch --no-color -a 2>/dev/null | sed 's/^..//' 5 | end 6 | 7 | function __fish_git_local_branches 8 | git branch --no-color 2>/dev/null | sed 's/^..//' 9 | end 10 | 11 | 12 | function __fish_git_tags 13 | git tag 14 | end 15 | 16 | function __fish_git_heads 17 | __fish_git_branches 18 | __fish_git_tags 19 | end 20 | 21 | function __fish_git_remotes 22 | git remote 23 | end 24 | 25 | function __fish_git_ranges 26 | set from (commandline -ot | perl -ne 'my @parts = split(/\.\./); print $parts[0]') 27 | set to (commandline -ot | perl -ne 'my @parts = split(/\.\./); print $parts[1]') 28 | if [ "$from" = "" ] 29 | __fish_git_branches 30 | return 0 31 | end 32 | 33 | for from_ref in (__fish_git_heads | grep -e "$from") 34 | for to_ref in (__fish_git_heads | grep -e "$to") 35 | printf "%s..%s\n" $from_ref $to_ref 36 | end 37 | end 38 | end 39 | 40 | function __fish_git_non_opts 41 | set cmd (commandline -opc) 42 | set -e cmd[1] # git 43 | set -e cmd[1] # git-subcommand 44 | for i in $cmd 45 | echo -n "$i" | grep -v "^-" 46 | end 47 | end 48 | 49 | function __fish_git_push_remote_given 50 | set non_opts (__fish_git_non_opts) 51 | [ (count $non_opts) -ne 0 ] 52 | end 53 | 54 | function __fish_git_needs_command 55 | set cmd (commandline -opc) 56 | if [ (count $cmd) -eq 1 -a $cmd[1] = 'git' ] 57 | return 0 58 | end 59 | return 1 60 | end 61 | 62 | function __fish_git_using_command 63 | set cmd (commandline -opc) 64 | if [ (count $cmd) -gt 1 ] 65 | if [ $argv[1] = $cmd[2] ] 66 | return 0 67 | end 68 | end 69 | return 1 70 | end 71 | 72 | # general options 73 | complete -f -c git -n 'not __fish_git_needs_command' -l help -d 'Display the manual of a git command' 74 | 75 | #### fetch 76 | complete -f -c git -n '__fish_git_needs_command' -a fetch -d 'Download objects and refs from another repository' 77 | complete -f -c git -n '__fish_git_using_command fetch' -a '(__fish_git_remotes)' -d 'Remote' 78 | complete -f -c git -n '__fish_git_using_command fetch' -s q -l quiet -d 'Be quiet' 79 | complete -f -c git -n '__fish_git_using_command fetch' -s v -l verbose -d 'Be verbose' 80 | complete -f -c git -n '__fish_git_using_command fetch' -s a -l append -d 'Append ref names and object names' 81 | # TODO --upload-pack 82 | complete -f -c git -n '__fish_git_using_command fetch' -s f -l force -d 'Force update of local branches' 83 | # TODO other options 84 | 85 | ### remote 86 | complete -f -c git -n '__fish_git_needs_command' -a remote -d 'Manage set of tracked repositories' 87 | complete -f -c git -n '__fish_git_using_command remote' -a '(__fish_git_remotes)' 88 | complete -f -c git -n '__fish_git_using_command remote' -s v -l verbose -d 'Be verbose' 89 | complete -f -c git -n '__fish_git_using_command remote' -a add -d 'Adds a new remote' 90 | complete -f -c git -n '__fish_git_using_command remote' -a rm -d 'Removes a remote' 91 | complete -f -c git -n '__fish_git_using_command remote' -a show -d 'Shows a remote' 92 | complete -f -c git -n '__fish_git_using_command remote' -a prune -d 'Deletes all stale tracking branches' 93 | complete -f -c git -n '__fish_git_using_command remote' -a update -d 'Fetches updates' 94 | # TODO options 95 | 96 | ### show 97 | complete -f -c git -n '__fish_git_needs_command' -a show -d 'Shows the last commit of a branch' 98 | complete -f -c git -n '__fish_git_using_command show' -a '(__fish_git_branches)' -d 'Branch' 99 | # TODO options 100 | 101 | ### show-branch 102 | complete -f -c git -n '__fish_git_needs_command' -a show-branch -d 'Shows the commits on branches' 103 | complete -f -c git -n '__fish_git_using_command show-branch' -a '(__fish_git_heads)' --description 'Branch' 104 | # TODO options 105 | 106 | ### add 107 | complete -c git -n '__fish_git_needs_command' -a add -d 'Add file contents to the index' 108 | # TODO options 109 | 110 | ### checkout 111 | complete -f -c git -n '__fish_git_needs_command' -a checkout -d 'Checkout and switch to a branch' 112 | complete -c git -n '__fish_git_using_command checkout' -a '(__fish_git_branches)' --description 'Branch' 113 | complete -c git -n '__fish_git_using_command checkout' -a '(__fish_git_tags)' --description 'Tag' 114 | complete -c git -n '__fish_git_using_command checkout' -s b -d 'Create a new branch' 115 | # TODO options 116 | 117 | ### apply 118 | complete -f -c git -n '__fish_git_needs_command' -a apply -d 'Apply a patch on a git index file and a working tree' 119 | # TODO options 120 | 121 | ### archive 122 | complete -f -c git -n '__fish_git_needs_command' -a archive -d 'Create an archive of files from a named tree' 123 | # TODO options 124 | 125 | ### bisect 126 | complete -f -c git -n '__fish_git_needs_command' -a bisect -d 'Find the change that introduced a bug by binary search' 127 | # TODO options 128 | 129 | ### branch 130 | complete -f -c git -n '__fish_git_needs_command' -a branch -d 'List, create, or delete branches' 131 | complete -f -c git -n '__fish_git_using_command branch' -a '(__fish_git_branches)' -d 'Branch' 132 | complete -f -c git -n '__fish_git_using_command branch' -s d -d 'Delete Branch' 133 | complete -f -c git -n '__fish_git_using_command branch' -s D -d 'Force deletion of branch' 134 | complete -f -c git -n '__fish_git_using_command branch' -s m -d 'Rename branch' 135 | complete -f -c git -n '__fish_git_using_command branch' -s M -d 'Force renaming branch' 136 | complete -f -c git -n '__fish_git_using_command branch' -s a -d 'Lists both local and remote branches' 137 | 138 | ### cherry-pick 139 | complete -f -c git -n '__fish_git_needs_command' -a cherry-pick -d 'Apply the change introduced by an existing commit' 140 | complete -f -c git -n '__fish_git_using_command cherry-pick' -a '(__fish_git_branches)' -d 'Branch' 141 | # TODO options 142 | 143 | ### clone 144 | complete -f -c git -n '__fish_git_needs_command' -a clone -d 'Clone a repository into a new directory' 145 | # TODO options 146 | 147 | ### commit 148 | complete -c git -n '__fish_git_needs_command' -a commit -d 'Record changes to the repository' 149 | complete -c git -n '__fish_git_using_command commit' -l amend -d 'Amend the log message of the last commit' 150 | # TODO options 151 | 152 | ### diff 153 | complete -c git -n '__fish_git_needs_command' -a diff -d 'Show changes between commits, commit and working tree, etc' 154 | complete -c git -n '__fish_git_using_command diff' -a '(__fish_git_ranges)' -d 'Branch' 155 | complete -c git -n '__fish_git_using_command diff' -l cached -d 'Show diff of changes in the index' 156 | # TODO options 157 | 158 | ### grep 159 | complete -c git -n '__fish_git_needs_command' -a grep -d 'Print lines matching a pattern' 160 | # TODO options 161 | 162 | ### init 163 | complete -f -c git -n '__fish_git_needs_command' -a init -d 'Create an empty git repository or reinitialize an existing one' 164 | # TODO options 165 | 166 | ### log 167 | complete -c git -n '__fish_git_needs_command' -a log -d 'Show commit logs' 168 | complete -c git -n '__fish_git_using_command log' -a '(__fish_git_heads) (__fish_git_ranges)' -d 'Branch' 169 | complete -f -c git -n '__fish_git_using_command log' -l pretty -a 'oneline short medium full fuller email raw format:' 170 | # TODO options 171 | 172 | ### merge 173 | complete -f -c git -n '__fish_git_needs_command' -a merge -d 'Join two or more development histories together' 174 | complete -f -c git -n '__fish_git_using_command merge' -a '(__fish_git_branches)' -d 'Branch' 175 | complete -f -c git -n '__fish_git_using_command merge' -l commit -d "Autocommit the merge" 176 | complete -f -c git -n '__fish_git_using_command merge' -l no-commit -d "Don't autocommit the merge" 177 | complete -f -c git -n '__fish_git_using_command merge' -l stat -d "Show diffstat of the merge" 178 | complete -f -c git -n '__fish_git_using_command merge' -s n -l no-stat -d "Don't show diffstat of the merge" 179 | complete -f -c git -n '__fish_git_using_command merge' -l squash -d "Squash changes from other branch as a single commit" 180 | complete -f -c git -n '__fish_git_using_command merge' -l no-squash -d "Don't squash changes" 181 | complete -f -c git -n '__fish_git_using_command merge' -l ff -d "Don't generate a merge commit if merge is fast forward" 182 | complete -f -c git -n '__fish_git_using_command merge' -l no-ff -d "Generate a merge commit even if merge is fast forward" 183 | 184 | # TODO options 185 | 186 | ### mv 187 | complete -c git -n '__fish_git_needs_command' -a mv -d 'Move or rename a file, a directory, or a symlink' 188 | # TODO options 189 | 190 | ### prune 191 | complete -f -c git -n '__fish_git_needs_command' -a prune -d 'Prune all unreachable objects from the object database' 192 | # TODO options 193 | 194 | ### pull 195 | complete -f -c git -n '__fish_git_needs_command' -a pull -d 'Fetch from and merge with another repository or a local branch' 196 | # TODO options 197 | 198 | ### push 199 | complete -f -c git -n '__fish_git_needs_command' -a push -d 'Update remote refs along with associated objects' 200 | complete -f -c git -n '__fish_git_using_command push; and not __fish_git_push_remote_given' -l all -d 'Push all branches' 201 | complete -f -c git -n '__fish_git_using_command push; and not __fish_git_push_remote_given' -l mirror -d 'Push everything' 202 | complete -f -c git -n '__fish_git_using_command push; and not __fish_git_push_remote_given' -s n -l dry-run -d 'Just say what would be done' 203 | complete -f -c git -n '__fish_git_using_command push; and not __fish_git_push_remote_given' -l tags -d 'Push all tags' 204 | complete -f -c git -n '__fish_git_using_command push; and not __fish_git_push_remote_given' -s f -l force -d 'Force pushing' 205 | 206 | complete -f -c git -n '__fish_git_using_command push; and not __fish_git_push_remote_given' -a '(__fish_git_remotes)' -d 'Push to remote' 207 | 208 | complete -f -c git -n '__fish_git_using_command push; and __fish_git_push_remote_given' -a '(__fish_git_local_branches)' -d 'Push branch' 209 | complete -f -c git -n '__fish_git_using_command push; and __fish_git_push_remote_given' -a '(__fish_git_tags)' -d 'Push tag' 210 | 211 | ### rebase 212 | complete -f -c git -n '__fish_git_needs_command' -a rebase -d 'Forward-port local commits to the updated upstream head' 213 | complete -f -c git -n '__fish_git_using_command rebase' -a '(__fish_git_branches)' -d 'Branch' 214 | # TODO options 215 | 216 | ### reset 217 | complete -c git -n '__fish_git_needs_command' -a reset -d 'Reset current HEAD to the specified state' 218 | complete -f -c git -n '__fish_git_using_command reset' -l hard -d 'Reset files in working directory' 219 | complete -c git -n '__fish_git_using_command reset' -a '(__fish_git_branches)' 220 | # TODO options 221 | 222 | ### revert 223 | complete -f -c git -n '__fish_git_needs_command' -a revert -d 'Revert an existing commit' 224 | # TODO options 225 | 226 | ### rm 227 | complete -c git -n '__fish_git_needs_command' -a rm -d 'Remove files from the working tree and from the index' 228 | # TODO options 229 | 230 | ### status 231 | complete -f -c git -n '__fish_git_needs_command' -a status -d 'Show the working tree status' 232 | # TODO options 233 | 234 | ### tag 235 | complete -f -c git -n '__fish_git_needs_command' -a tag -d 'Create, list, delete or verify a tag object signed with GPG' 236 | complete -f -c git -n '__fish_git_using_command tag; and __fish_not_contain_opt -s d; and __fish_not_contain_opt -s v; and test (count (commandline -opc | grep -v -e \'^-\')) -eq 3' -a '(__fish_git_branches)' -d 'Branch' 237 | complete -f -c git -n '__fish_git_using_command tag' -s d -d 'Remove a tag' 238 | complete -f -c git -n '__fish_git_using_command tag' -s v -d 'Verify signature of a tag' 239 | complete -f -c git -n '__fish_git_using_command tag' -s f -d 'Force overwriting exising tag' 240 | complete -f -c git -n '__fish_git_using_command tag' -s s -d 'Make a GPG-signed tag' 241 | complete -f -c git -n '__fish_contains_opt -s d' -a '(__fish_git_tags)' -d 'Tag' 242 | complete -f -c git -n '__fish_contains_opt -s v' -a '(__fish_git_tags)' -d 'Tag' 243 | # TODO options 244 | 245 | ### config 246 | complete -f -c git -n '__fish_git_needs_command' -a config -d 'Set and read git configuration variables' 247 | # TODO options 248 | 249 | ### format-patch 250 | complete -f -c git -n '__fish_git_needs_command' -a format-patch -d 'Generate patch series to send upstream' 251 | complete -f -c git -n '__fish_git_using_command format-patch' -a '(__fish_git_branches)' -d 'Branch' 252 | 253 | ### aliases (custom user-definer commands) 254 | complete -c git -n '__fish_git_needs_command' -a '(git config --get-regexp alias | sed -e "s/^alias\.\(\S\+\).*/\1/")' -d 'Alias (user-defined command)' --------------------------------------------------------------------------------