Skip to content

Instantly share code, notes, and snippets.

@RamonGilabert
Last active October 29, 2016 21:25
Show Gist options
  • Save RamonGilabert/da807d70c771a9f6daf6 to your computer and use it in GitHub Desktop.
Save RamonGilabert/da807d70c771a9f6daf6 to your computer and use it in GitHub Desktop.
set fish_greeting Welcome\x20\x1b\x5b32mRamon!
alias gst='git status'
alias gco='git checkout'
alias gl='git pull'
alias gpom="git pull origin master"
alias gd='git diff | mate'
alias gnb='git branch'
alias gba='git branch -a'
alias gb='git checkout -b'
alias del='git branch -d'
function gc
git add --all; git commit -m "$argv";
end
function gp
set branch (git rev-parse --abbrev-ref HEAD)
if test (echo $argv | wc -w) -ge 1
git push -u origin $argv
else
git push -u origin $branch
end
end
function gcp
git add --all; git commit -m "$argv";gp
end
function swift22
/Library/Developer/Toolchains/swift-latest.xctoolchain/usr/bin/swift
end
set normal (set_color normal)
set magenta (set_color magenta)
set purple (set_color purple)
set green (set_color green)
set red (set_color red)
set gray (set_color -o black)
function git_is_repo -d "Check if directory is a repository"
test -d .git; or command git rev-parse --git-dir >/dev/null ^/dev/null
end
function git_branch_name -d "Get current branch name"
git_is_repo; and begin
command git symbolic-ref --short HEAD
end
end
function __simple_ass_prompt_git -d "Display the actual git branch"
set -l ref
if git_is_repo
printf 'on '
set_color purple
printf '%s ' (git_branch_name)
set_color normal
end
end
function rehash
. ~/.config/fish/config.fish
end
function fish_prompt
set_color red
printf '→ '
set_color $fish_color_cwd
printf '%s ' (prompt_pwd)
set_color normal
__simple_ass_prompt_git
if test $VIRTUAL_ENV
printf "on (%s) " (set_color blue)(basename $VIRTUAL_ENV)(set_color normal)
end
printf '◦ '
set_color normal
end
function subl -d "Open Sublime Text"
set -l opts
set -l files
set -l projects
for file in $argv
switch $file
case '-*'
set opts $opts $file
case '.*' '*'
set files $files $file
end
end
if [ (count $files) -eq 1 ]
set projects (find $files[1] -name "*.sublime-project" -maxdepth 1 2> /dev/null)
end
if [ (count $projects) -eq 1 ]
set argv $opts $projects[1]
end
if begin; which subl > /dev/null 2>&1; and test -x (which subl); end
command subl $argv
else if test -d "/Applications/Sublime Text.app"
"/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" $argv
else
echo "No Sublime Text installation found" >&2
return 1
end
end
function xc
if test (echo $argv | wc -w) -ge 1
open -a "Xcode" $argv
else
set currentDirectory (ls -fd -1 $PWD/*{xcworkspace,xcodeproj})
if test (echo $currentDirectory[1] | wc -w) -ge 1
if [ $currentDirectory[1] != "." ]
open -a "Xcode" $currentDirectory[1]
else
set subDirectories (ls -fd -1 $PWD/*/*{xcworkspace,xcodeproj})
if test (echo $subDirectories[1] | wc -w) -ge 1
if [ $subDirectories[1] != "." ]
open -a "Xcode" $subDirectories[1]
else
echo "No xcworkspace/xcodeproj file found in the current directory."
end
end
end
else
echo "No xcworkspace/xcodeproj file found in the current directory."
end
end
end
. ~/.config/fish/s.fish
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment