Skip to content

Instantly share code, notes, and snippets.

@JeanMertz
Created March 5, 2013 08:39
Show Gist options
  • Save JeanMertz/5088848 to your computer and use it in GitHub Desktop.
Save JeanMertz/5088848 to your computer and use it in GitHub Desktop.
function p
cd ~/Projecten/$argv
end
function cs
echo (set_color red) '== SHORTCUTS =='
echo (set_color green) 'Ctrl-F\t' \t (set_color 999) 'command completion (instead of arrow-right)'
end
function dotfiles
if test -z "$argv"
echo (set_color 999)'The following are random notes and remarks for the dotfiles currently in use.
You can read more about these dofiles at http://github.com/JeanMertz/dotfiles-next.'
echo ''
echo (set_color 208333) 'vi-mode.fish' \t (set_color 999) 'add vi-mode to fish shell.'
echo (set_color 999) \t\t\t "To update, use 'dotfiles fish vi-mode update'"
end
# Update vi-mode.fish
if test "$argv" = 'fish vi-mode update'
curl 'https://raw.github.com/DarkStarSword/junk/master/vi-mode.fish' -o ~/.config/fish/vi-mode.fish
end
# Show vi-mode.fish remote
if test "$argv" = 'fish vi-mode remove'
open
curl 'https://raw.github.com/DarkStarSword/junk/master/vi-mode.fish' -o ~/.config/fish/vi-mode.fish
end
end
# https://github.com/fish-shell/fish-shell/pull/354
#
function `
for arg in $argv
echo $arg
end
end
function stheme; subl "~/Library/Application Support/Sublime Text 3/Packages/User/Themes/Espresso Jean.tmTheme"; end
function log; tail -f log/development.log $argv; end
function g; ps aux | grep $argv; end
function r; bundle exec rails $argv; end
function rsp
set zeus_running (ps aux | awk '/[z]eus/ {print $2}')
if test "$zeus_running"
zeus test $argv
else
bundle exec rspec $argv
end
end
function ra
set zeus_running (ps aux | awk '/[z]eus/ {print $2}')
if test "$zeus_running"
zeus rake $argv
else
bundle exec rake $argv
end
end
function rc
set zeus_running (ps aux | awk '/[z]eus/ {print $2}')
if test "$zeus_running"
zeus console $argv
else
bundle exec rails console $argv
end
end
function bu; bundle update $argv; end
function bi; bundle install $argv; end
function gs; git status -sb $argv; end
function gbr; git branch -a $argv; end
function gsg; gittower --status $argv; end
function gd; git diff --color-words $argv; end
function diff; git difftool $argv; end
function gco; git checkout $argv; end
function ga; git add -A $argv; end
function gc
if test "$argv"
git commit -m $argv
else
git commit
end
end
function sabnzbd
if test "$argv[1]" = 'stop'
launchctl stop net.jean.sabnzbd
else
launchctl start net.jean.sabnzbd
end
end
function sickbeard
if test "$argv[1]" = 'stop'
launchctl stop net.jean.sickbeard
else
launchctl start net.jean.sickbeard
end
end
function couchpotato
if test "$argv[1]" = 'stop'
launchctl stop net.jean.couchpotato
else
launchctl start net.jean.couchpotato
end
end
function gl; git l $argv; end
function gpush; git push $argv; end
function gpull; git pull $argv; end
function gcl; git clone $argv; end
function gclk
set -l arg1 $argv[1]
set -e argv[1]
git clone git@git.kabisa.nl:$arg1 $argv
end
function gr; if test "$argv"; git remote $argv; else; git remote -v; end; end
function greset!; if test "$argv"; git checkout -- $argv; else; git reset --hard; end; end
function greset
if test "$argv"
echo "Are you sure you want to reset "(set_color -u yellow)"$argv"(set_color normal)" to HEAD? [Y/n] "
read reset_git
test "$reset_git" = "Y"; and git checkout -- $argv
else
echo "Are you sure you want to reset ALL UNCOMMITED CHANGES to HEAD? [Y/n] "
read reset_git
test "$reset_git" = "Y"; and git reset --hard
end
end
function rb; rbenv version; rbenv gemset active; end
function rr; bundle exec rake routes $argv; end
function s
if test "$argv"
subl $argv
else
if test -f *.sublime-project
subl *.sublime-project
else
subl .
end
end
end
function sedit; s "/Users/Jean/Library/Application Support/Sublime Text 3/Packages/User/Themes/Espresso Jean.tmTheme" "/Users/Jean/Library/Application Support/Sublime Text 3/Packages/Default/Preferences.sublime-settings" "/Users/Jean/Library/Application Support/Sublime Text 3/Packages/User/Preferences.sublime-settings" "/Users/Jean/Library/Application Support/Sublime Text 3/Packages/Ruby/Ruby.tmLanguage" "/Users/Jean/Library/Application Support/Sublime Text 3/Packages/Rails/Ruby on Rails.tmLanguage"; end
function gel; gem list $argv; end
function be; bundle exec $argv; end
function b; bundle $argv; end
function ts; bundle exec rake spec $argv; end
function tc; bundle exec rake cucumber $argv; end
function dbm
if test "$argv[1]" = 'dev'
set -e argv[1]
bundle exec rake db:migrate $argv
else if test "$argv[1]" = 'test'
set -e argv[1]
set -lx RAILS_ENV 'test'
bundle exec rake db:migrate $argv
else
bundle exec rake db:migrate $argv
set -lx RAILS_ENV 'test'
bundle exec rake db:migrate $argv
end
end
function git; hub $argv; end
function l; gls -Ah --color --group-directories-first; end
function ls; gls -oAh --color --group-directories-first $argv | tail -n +2; end
function f; find . -name $argv; end
function fgr; f $argv[1] | xargs grep $argv[2]; end
function psgr; ps aux | grep $argv; end
function ag; command ag -p '~/.config/ack/agignore' -i --hidden --stats $argv; end
function fx
set -l arg1 $argv[1]
set -e argv[1]
f $arg1 | xargs $argv
end
# TODO:
# ruby & rails api documentation alias (docru, docra)
# nagios notifications to iOS (and OS X later)
#
# ODS Gem bouwen die toegevoegd kan worden aan Rails applicaties
# Deze gem doet verschillende status gegevens geven via een API
# zoals up/down, totaal errors, methods beschikbaar stellen voor
# programmeurs om specifieke berichten te versturen naar ODS en Nagios.
# Applicatie versie ook inbouwen via deze Gem.
# Variables for changing highlighting colors
# The colors used by fish for syntax highlighting can be configured by changing the values of a various variables. The value of these variables can be one of the colors accepted by the set_color command. The --bold or -b switches accepted by set_color are also accepted.
# The following variables are available to change the highlighting colors in fish:
set fish_color_normal 999999 # the default color
set fish_color_command 0066FF # the color for commands
set fish_color_quote FFCC00 # the color for quoted blocks of text
set fish_color_redirection normal # the color for IO redirections
set fish_color_end 999999 # the color for process separators like ';' and '&'
set fish_color_error 990000 # the color used to highlight potential errors
set fish_color_param 33CCFF # the color for regular command parameters
set fish_color_comment 666666 # the color used for code comments
set fish_color_match cyan # the color used to highlight matching parenthesis
set fish_color_search_match yellow -b FFCC66 # the color used to highlight history search matches
set fish_color_operator cyan # the color for parameter expansion operators like '*' and '~'
set fish_color_escape cyan # the color used to highlight character escapes like '\n' and '\x70'
set fish_color_cwd green # the color used for the current working directory in the default prompt
set fish_pager_color_prefix cyan # the color of the prefix string, i.e. the string that is to be completed
set fish_pager_color_completion normal # the color of the completion itself
set fish_pager_color_description 555 yellow # the color of the completion description
set fish_pager_color_progress cyan # the color of the progress bar at the bottom left corner
set -x RBENV_ROOT $HOME/.rbenv
set -x PATH /usr/local/heroku/bin /usr/local/bin /usr/local/share/npm/bin $RBENV_ROOT/shims /usr/local/share/python /usr/local/sbin /usr/bin /usr/sbin /bin /sbin /opt/X11/bin /usr/local/Cellar/fishfish/HEAD/bin /usr/local/Cellar/gettext/0.18.1.1/bin
rbenv rehash >/dev/null ^&1
set -x MYVIMRC $HOME/.config/vim/vimrc
set -x PYTHONPATH (brew --prefix)/lib/python2.7/site-packages
# set PAGER to vimpager
set -x VIMPAGER_RC ~/.config/vim/vimpagerrc
set fish_greeting ''
set -x CLICOLOR 1
set BROWSER 'open'
# set -x EDITOR 'vim'
set -x EDITOR 'subl'
# prompt
function prompt_pwd --description "Print the current working directory, shortend to fit the prompt"
set -l path (echo $PWD | awk -F "/" -v user=$USER '{
if ($(NF-1) == user) { print "~/" $NF }
else if ($(NF) == user) { print "~" }
else if (NF>3) { print "../" $(NF-1) "/" $NF }
else { print $0 }
}')
printf '%s%s%s' (set_color 333) $path (set_color normal)
end
# vi-mode
# => https://raw.github.com/DarkStarSword/junk/master/vi-mode.fish
#. ./vi-mode.fish
. /Users/Jean/.config/fish/vi-mode.fish
function fish_user_key_bindings
vi_mode_insert
end
function smiley
switch $status
case '1' '127'
printf '%s%s%s' (set_color -o FF0000) '☹' (set_color normal)
case '*'
printf '%s%s%s' (set_color 006600) '☺' (set_color normal)
end
end
. /Users/Jean/Dropbox/dotfiles-next/config/fish/aliasses.fish
# This is still too slow, need to convert to 100% fish script (or c?)
function rbenv-prompt
if test -n (__rbenv_gemset_active)
printf '%s@%s' (__rbenv_version_name) (__rbenv_gemset_active)
else
printf '%s' (__rbenv_version_name)
end
end
function git-prompt
set -l index 1
for i in (echo (vcprompt -f '%b %r %m%u') | tr ' ' "\n")
if test "$index" = 1
# return if not in git repository
test "$i" = ''; and return
# echo branch name
if test "$i" = 'master'
set -l git_root (git rev-parse --show-toplevel)
if test ! -f "$git_root/.gitmaster"
# set 'master' branch to red, we don't really want to work in this
# branch in most cases. add a ".gitmaster" file in the git root
# to show the master branch in the normal color.
echo " "(set_color -u 7A0B17)"$i"(set_color normal)
else
echo (set_color 999)" $i"
end
else
echo (set_color 999)" $i"
end
set index 2
else if test "$index" = 2
# echo current sha
echo (set_color 111)"$i"
set index 3
else if test "$index" = 3
test "$i" = ''; and return
# show 'dirty branch' indicator
test "$i"; and echo (set_color 444)"✗"
end
end
set -e index
end
function fish_prompt -d "Write out the prompt"
echo (set_color $fish_color_cwd)(prompt_pwd) $vi_mode\n (smiley) (set_color FFCC00)' $' (set_color normal)
z --add "$PWD"
end
function fish_right_prompt -d "Write out the right prompt"
echo (set_color 111) (rbenv-prompt)
echo (git-prompt)
end
#. /Users/Jean/Dropbox/dotfiles-next/config/fish/git.fish
# set fish_git_dirty_color red
# function parse_git_dirty
# git diff --quiet HEAD ^&-
# if test $status = 1
# echo (set_color $fish_git_dirty_color)"Δ"(set_color normal)
# end
# end
# function parse_git_branch
# # git branch outputs lines, the current branch is prefixed with a *
# set -l branch (git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/')
# echo $branch (parse_git_dirty)
# end
# function fish_prompt
# if test -z (git branch --quiet 2>| awk '/fatal:/ {print "no git"}')
# printf '%s%s%s (%s) $ ' (set_color $fish_color_cwd) (prompt_pwd) (set_color normal) (parse_git_branch)
# else
# printf '%s@%s %s%s%s $ ' (whoami) (hostname|cut -d . -f 1) (set_color $fish_color_cwd) (prompt_pwd) (set_color normal)
# end
# end
set fish_git_dirty_color red
function parse_git_dirty
git diff —quiet HEAD ^&-
if test $status = 1
echo (set_color $fish_git_dirty_color)”Δ”(set_color normal)
end
end
function parse_git_branch
# git branch outputs lines, the current branch is prefixed with a *
set -l branch (git branch 2> /dev/null | sed -e ‘/^[^*]/d’ -e ‘s/* \(.*\)/\1/’)
echo $branch (parse_git_dirty)
end
function fish_prompt
if test -z (git branch —quiet 2>| awk ‘/fatal:/ {print “no git”}’)
printf ‘%s@%s %s%s%s (%s) $ ’ (whoami) (hostname|cut -d . -f 1) (set_color $fish_color_cwd) (prompt_pwd) (set_color normal) (parse_git_branch)
else
printf ‘%s@%s %s%s%s $ ’ (whoami) (hostname|cut -d . -f 1) (set_color $fish_color_cwd) (prompt_pwd) (set_color normal)
end
end
function __rbenv_gemset_active
set -l root (pwd)
set -l cwd (pwd)
while test "$root" != "/"
if test -e "$root/.rbenv-gemsets"
set gemset_file "$root/.rbenv-gemsets"
break
end
cd $root/..
set -l root (pwd)
end
cd $cwd
if test -n "$RBENV_GEMSETS"
echo $RBENV_GEMSETS
else if test -n "$gemset_file"
echo (cat $gemset_file | sed 's/ *$//g')
else
echo ''
end
end
function __rbenv_version_name
if test -z "$RBENV_VERSION"
set RBENV_VERSION_FILE (__rbenv_version_file)
set RBENV_VERSION (__rbenv_version_file_read $RBENV_VERSION_FILE; or true)
end
if test -z "$RBENV_VERSION"; or $RBENV_VERSION = 'system'
echo ' system'
return
end
set RBENV_VERSION_PATH "$RBENV_ROOT/versions/$RBENV_VERSION"
if test -d $RBENV_VERSION_PATH
echo $RBENV_VERSION
else
printf ' %s%s%s' (set_color 7A0B17) $RBENV_VERSION (set_color normal)
end
end
function __rbenv_version_file
if test -z $RBENV_DIR
set RBENV_DIR (pwd)
else
if test -d $RBENV_DIR
cd $RBENV_DIR
set RBENV_DIR (pwd)
cd $OLDPWD
else
echo "rbenv: cannot change working directory to \`$RBENV_DIR'"
return 1
end
end
set -l root $RBENV_DIR
set -l cwd (pwd)
while test "$root" != "/"
if test -e "$RBENV_DIR/.ruby-version"
echo "$root/.ruby-version"
return
end
if test -e "$RBENV_DIR/.rbenv-version"
echo "$root/.rbenv-version"
return
end
cd $root/..
set -l root (pwd)
end
cd $cwd
set global_version_file "$RBENV_ROOT/version"
if test -e "$global_version_file"
echo "$global_version_file"
else if test -e "$RBENV_ROOT/global"
echo "$RBENV_ROOT/global"
else if test -e "$RBENV_ROOT/default"
echo "$RBENV_ROOT/default"
else
echo "$global_version_file"
end
end
function __rbenv_version_file_read
#echo (rbenv version-name)
set -l VERSION_FILE "$argv"
if test -e "$VERSION_FILE"
set __rbenv_version (cut -d\ -f1 <$VERSION_FILE; or '')
# set version ''
# while read -a words
# set word "{$words[0]}"
# if test -z "$version"; and -n "$word"
# set version "$word"
# end
# end < <( cat "$VERSION_FILE"; and echo )
if test -n "$__rbenv_version"
echo "$__rbenv_version"
return
end
end
return 1
# VERSION_FILE="$1"
# if [ -e "$VERSION_FILE" ]; then
# # Read and print the first non-whitespace word from the specified
# # version file.
# version=""
# while read -a words; do
# word="${words[0]}"
# if [ -z "$version" ] && [ -n "$word" ]; then
# version="$word"
# fi
# done < <( cat "$VERSION_FILE" && echo )
# if [ -n "$version" ]; then
# echo "$version"
# exit
# fi
# fi
exit 1
# if [ -z "$RBENV_VERSION" ]; then
# RBENV_VERSION_FILE="$(rbenv-version-file)"
# RBENV_VERSION="$(rbenv-version-file-read "$RBENV_VERSION_FILE" || true)"
# fi
# if [ -z "$RBENV_VERSION" ] || [ "$RBENV_VERSION" = "system" ]; then
# echo "system"
# exit
# fi
# RBENV_VERSION_PATH="${RBENV_ROOT}/versions/${RBENV_VERSION}"
# if [ -d "$RBENV_VERSION_PATH" ]; then
# echo "$RBENV_VERSION"
# else
# echo "rbenv: version \`$RBENV_VERSION' is not installed" >&2
# exit 1
# fi
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment