mirror of https://github.com/bjeanes/dotfiles.git
Added stuff from fish-nuggets and changed behaviour of a few
parent
e5efdafeea
commit
ebd5920356
|
@ -1,2 +1,3 @@
|
|||
fish/fish_history
|
||||
fish/fish_read_history
|
||||
fish/fishd.*
|
|
@ -0,0 +1,3 @@
|
|||
[submodule "fish/nuggets"]
|
||||
path = fish/nuggets
|
||||
url = git://github.com/zmalltalker/fish-nuggets.git
|
2
aliases
2
aliases
|
@ -1,5 +1,5 @@
|
|||
alias gem='sudo gem' # sick of always forgetting sudo
|
||||
alias ls='ls -G'
|
||||
alias ls='ls -FG'
|
||||
alias ll='ls -lah'
|
||||
alias ..='cd ..;' # can then do .. .. .. to move up multiple directories.
|
||||
alias ...='.. ..'
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
#!/usr/bin/env ruby
|
||||
require 'rubygems'
|
||||
|
||||
if ARGV.first == '-l' || ARGV.first == '--list'
|
||||
puts Gem.cache.map{ |s| s[1].name }.uniq.sort.join( "\n" )
|
||||
else
|
||||
gem_name = ARGV.first
|
||||
gem_info = Gem.cache.search( gem_name ).first
|
||||
system "mate #{gem_info.full_gem_path}"
|
||||
end
|
|
@ -0,0 +1,12 @@
|
|||
#!/usr/bin/env ruby
|
||||
require 'rubygems'
|
||||
|
||||
|
||||
if ARGV.first == '-l' || ARGV.first == '--list'
|
||||
puts Gem.cache.map{ |s| s[1].name }.uniq.sort.join( "\n" )
|
||||
else
|
||||
gem_name = ARGV.first
|
||||
gem_info = Gem.cache.search( gem_name ).first
|
||||
doc_file = File.join( gem_info.full_gem_path.gsub(/1\.8\/gems/, "1.8/doc"), 'rdoc/index.html' )
|
||||
system "open #{doc_file}"
|
||||
end
|
|
@ -0,0 +1,15 @@
|
|||
#!/usr/bin/env ruby
|
||||
|
||||
exit(1) unless ARGV[0] && File.exist?(ARGV[0])
|
||||
|
||||
require 'yaml'
|
||||
|
||||
dbs = YAML.load_file(ARGV[0]).collect do |name,info|
|
||||
adapter = info['adapter'] || info[:adapter]
|
||||
db = info['database'] || info[:database]
|
||||
[adapter,db]
|
||||
end.uniq.each do |(adapter,db)|
|
||||
puts "%s\t%s" % [adapter, db]
|
||||
end
|
||||
|
||||
exit 0
|
|
@ -0,0 +1,13 @@
|
|||
function __cache_or_get_cap_completion -d "Create cap completions"
|
||||
mkdir -p "/tmp/cap_completion_cache"
|
||||
set -l hashed_pwd (md5 -q -s (pwd))
|
||||
set -l cap_cache_file "/tmp/cap_completion_cache/$hashed_pwd"
|
||||
|
||||
if not test -f "$cap_cache_file"
|
||||
cap -T 2>&1 | grep "^cap" |cut -d " " -f 2 > "$cap_cache_file"
|
||||
end
|
||||
|
||||
cat "$cap_cache_file"
|
||||
end
|
||||
|
||||
complete -x -c cap -a "(__cache_or_get_cap_completion)" --description 'Capistrano task'
|
|
@ -0,0 +1,5 @@
|
|||
function __gem_names
|
||||
gem list --no-versions | grep -v '*'
|
||||
end
|
||||
|
||||
complete -x -c cdgem -d 'gem name' -a "(__gem_names)"
|
|
@ -0,0 +1 @@
|
|||
complete -x -c createdb -d 'database name' -a "(__db_list_pg | uniq)"
|
|
@ -0,0 +1 @@
|
|||
complete -c cucumber -a "(ls features | sort | grep -vE \"^_\")"
|
|
@ -0,0 +1 @@
|
|||
complete -x -c dropdb -d 'database name' -a "(__db_list_pg | uniq)"
|
|
@ -0,0 +1,3 @@
|
|||
complete -x -c edit_gem -a '(edit_gem --list)' --description 'Ruby Gem'
|
||||
complete -c edit_gem -s l -l list --description "List installed gems"
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
complete -x -c gem_doc -a '(gem_doc --list)' --description 'Ruby Gem'
|
||||
complete -c gem_doc -s l -l list --description "List installed gems"
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
complete -c git-svn -a clone -d "Initialize and fetch revisions"
|
||||
complete -c git-svn -a commit-diff -d "Commit a diff between two trees"
|
||||
complete -c git-svn -a create-ignore -d "Create a .gitignore per svn:ignore"
|
||||
complete -c git-svn -a dcommit -d "Commit several diffs to merge with upstream"
|
||||
complete -c git-svn -a fetch -d "Download new revisions from Subversion"
|
||||
complete -c git-svn -a find-rev -d "Translate between Subversion revision numbers and tree-ish"
|
||||
complete -c git-svn -a info -d "Show info about the latest Subversion revision"
|
||||
complete -c git-svn -a init -d "Initialize a repo for tracking (requires URL argument)"
|
||||
complete -c git-svn -a log -d "Show commit logs"
|
||||
complete -c git-svn -a migrate -d "Migrate configuration/metadata/layout from previous versions of git-svn"
|
||||
complete -c git-svn -a propget -d "Print the value of a property on a file or directory"
|
||||
complete -c git-svn -a proplist -d "List all properties of a file or directory"
|
||||
complete -c git-svn -a rebase -d "Fetch and rebase your working directory"
|
||||
complete -c git-svn -a set-tree -d "Set a Subversion repository to a git tree-ish"
|
||||
complete -c git-svn -a show-externals -d "Show svn:externals listings"
|
||||
complete -c git-svn -a show-ignore -d "Show svn:ignore listings"
|
|
@ -0,0 +1,226 @@
|
|||
# fish completion for git
|
||||
|
||||
function __fish_git_branches
|
||||
git branch --no-color -a 2>/dev/null | sed 's/^..//'
|
||||
end
|
||||
|
||||
function __fish_git_tags
|
||||
git tag
|
||||
end
|
||||
|
||||
function __fish_git_heads
|
||||
__fish_git_branches
|
||||
__fish_git_tags
|
||||
end
|
||||
|
||||
function __fish_git_remotes
|
||||
git remote
|
||||
end
|
||||
|
||||
function __fish_git_ranges
|
||||
set from (commandline -ot | perl -ne 'my @parts = split(/\.\./); print $parts[0]')
|
||||
set to (commandline -ot | perl -ne 'my @parts = split(/\.\./); print $parts[1]')
|
||||
if [ "$from" = "" ]
|
||||
__fish_git_branches
|
||||
return 0
|
||||
end
|
||||
|
||||
for from_ref in (__fish_git_heads | grep -e "$from")
|
||||
for to_ref in (__fish_git_heads | grep -e "$to")
|
||||
printf "%s..%s\n" $from_ref $to_ref
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function __fish_git_needs_command
|
||||
set cmd (commandline -opc)
|
||||
if [ (count $cmd) -eq 1 -a $cmd[1] = 'git' ]
|
||||
return 0
|
||||
end
|
||||
return 1
|
||||
end
|
||||
|
||||
function __fish_git_using_command
|
||||
set cmd (commandline -opc)
|
||||
if [ (count $cmd) -gt 1 ]
|
||||
if [ $argv[1] = $cmd[2] ]
|
||||
return 0
|
||||
end
|
||||
end
|
||||
return 1
|
||||
end
|
||||
|
||||
# general options
|
||||
complete -f -c git -n 'not __fish_git_needs_command' -l help -d 'Display the manual of a git command'
|
||||
|
||||
#### fetch
|
||||
complete -f -c git -n '__fish_git_needs_command' -a fetch -d 'Download objects and refs from another repository'
|
||||
complete -f -c git -n '__fish_git_using_command fetch' -a '(__fish_git_remotes)' -d 'Remote'
|
||||
complete -f -c git -n '__fish_git_using_command fetch' -s q -l quiet -d 'Be quiet'
|
||||
complete -f -c git -n '__fish_git_using_command fetch' -s v -l verbose -d 'Be verbose'
|
||||
complete -f -c git -n '__fish_git_using_command fetch' -s a -l append -d 'Append ref names and object names'
|
||||
# TODO --upload-pack
|
||||
complete -f -c git -n '__fish_git_using_command fetch' -s f -l force -d 'Force update of local branches'
|
||||
# TODO other options
|
||||
|
||||
### remote
|
||||
complete -f -c git -n '__fish_git_needs_command' -a remote -d 'Manage set of tracked repositories'
|
||||
complete -f -c git -n '__fish_git_using_command remote' -a '(__fish_git_remotes)'
|
||||
complete -f -c git -n '__fish_git_using_command remote' -s v -l verbose -d 'Be verbose'
|
||||
complete -f -c git -n '__fish_git_using_command remote' -a add -d 'Adds a new remote'
|
||||
complete -f -c git -n '__fish_git_using_command remote' -a rm -d 'Removes a remote'
|
||||
complete -f -c git -n '__fish_git_using_command remote' -a show -d 'Shows a remote'
|
||||
complete -f -c git -n '__fish_git_using_command remote' -a prune -d 'Deletes all stale tracking branches'
|
||||
complete -f -c git -n '__fish_git_using_command remote' -a update -d 'Fetches updates'
|
||||
# TODO options
|
||||
|
||||
### show
|
||||
complete -f -c git -n '__fish_git_needs_command' -a show -d 'Shows the last commit of a branch'
|
||||
complete -f -c git -n '__fish_git_using_command show' -a '(__fish_git_branches)' -d 'Branch'
|
||||
# TODO options
|
||||
|
||||
### show-branch
|
||||
complete -f -c git -n '__fish_git_needs_command' -a show-branch -d 'Shows the commits on branches'
|
||||
complete -f -c git -n '__fish_git_using_command show-branch' -a '(__fish_git_heads)' --description 'Branch'
|
||||
# TODO options
|
||||
|
||||
### add
|
||||
complete -c git -n '__fish_git_needs_command' -a add -d 'Add file contents to the index'
|
||||
# TODO options
|
||||
|
||||
### checkout
|
||||
complete -f -c git -n '__fish_git_needs_command' -a checkout -d 'Checkout and switch to a branch'
|
||||
complete -c git -n '__fish_git_using_command checkout' -a '(__fish_git_branches)' --description 'Branch'
|
||||
complete -c git -n '__fish_git_using_command checkout' -a '(__fish_git_tags)' --description 'Tag'
|
||||
complete -c git -n '__fish_git_using_command checkout' -s b -d 'Create a new branch'
|
||||
# TODO options
|
||||
|
||||
### apply
|
||||
complete -f -c git -n '__fish_git_needs_command' -a apply -d 'Apply a patch on a git index file and a working tree'
|
||||
# TODO options
|
||||
|
||||
### archive
|
||||
complete -f -c git -n '__fish_git_needs_command' -a archive -d 'Create an archive of files from a named tree'
|
||||
# TODO options
|
||||
|
||||
### bisect
|
||||
complete -f -c git -n '__fish_git_needs_command' -a bisect -d 'Find the change that introduced a bug by binary search'
|
||||
# TODO options
|
||||
|
||||
### branch
|
||||
complete -f -c git -n '__fish_git_needs_command' -a branch -d 'List, create, or delete branches'
|
||||
complete -f -c git -n '__fish_git_using_command branch' -a '(__fish_git_branches)' -d 'Branch'
|
||||
complete -f -c git -n '__fish_git_using_command branch' -s d -d 'Delete Branch'
|
||||
complete -f -c git -n '__fish_git_using_command branch' -s D -d 'Force deletion of branch'
|
||||
complete -f -c git -n '__fish_git_using_command branch' -s m -d 'Rename branch'
|
||||
complete -f -c git -n '__fish_git_using_command branch' -s M -d 'Force renaming branch'
|
||||
complete -f -c git -n '__fish_git_using_command branch' -s a -d 'Lists both local and remote branches'
|
||||
|
||||
### cherry-pick
|
||||
complete -f -c git -n '__fish_git_needs_command' -a cherry-pick -d 'Apply the change introduced by an existing commit'
|
||||
complete -f -c git -n '__fish_git_using_command cherry-pick' -a '(__fish_git_branches)' -d 'Branch'
|
||||
# TODO options
|
||||
|
||||
### clone
|
||||
complete -f -c git -n '__fish_git_needs_command' -a clone -d 'Clone a repository into a new directory'
|
||||
# TODO options
|
||||
|
||||
### commit
|
||||
complete -c git -n '__fish_git_needs_command' -a commit -d 'Record changes to the repository'
|
||||
complete -c git -n '__fish_git_using_command commit' -l amend -d 'Amend the log message of the last commit'
|
||||
# TODO options
|
||||
|
||||
### diff
|
||||
complete -c git -n '__fish_git_needs_command' -a diff -d 'Show changes between commits, commit and working tree, etc'
|
||||
complete -c git -n '__fish_git_using_command diff' -a '(__fish_git_ranges)' -d 'Branch'
|
||||
complete -c git -n '__fish_git_using_command diff' -l cached -d 'Show diff of changes in the index'
|
||||
# TODO options
|
||||
|
||||
### grep
|
||||
complete -c git -n '__fish_git_needs_command' -a grep -d 'Print lines matching a pattern'
|
||||
# TODO options
|
||||
|
||||
### init
|
||||
complete -f -c git -n '__fish_git_needs_command' -a init -d 'Create an empty git repository or reinitialize an existing one'
|
||||
# TODO options
|
||||
|
||||
### log
|
||||
complete -c git -n '__fish_git_needs_command' -a log -d 'Show commit logs'
|
||||
complete -c git -n '__fish_git_using_command log' -a '(__fish_git_heads) (__fish_git_ranges)' -d 'Branch'
|
||||
complete -f -c git -n '__fish_git_using_command log' -l pretty -a 'oneline short medium full fuller email raw format:'
|
||||
# TODO options
|
||||
|
||||
### merge
|
||||
complete -f -c git -n '__fish_git_needs_command' -a merge -d 'Join two or more development histories together'
|
||||
complete -f -c git -n '__fish_git_using_command merge' -a '(__fish_git_branches)' -d 'Branch'
|
||||
complete -f -c git -n '__fish_git_using_command merge' -l commit -d "Autocommit the merge"
|
||||
complete -f -c git -n '__fish_git_using_command merge' -l no-commit -d "Don't autocommit the merge"
|
||||
complete -f -c git -n '__fish_git_using_command merge' -l stat -d "Show diffstat of the merge"
|
||||
complete -f -c git -n '__fish_git_using_command merge' -s n -l no-stat -d "Don't show diffstat of the merge"
|
||||
complete -f -c git -n '__fish_git_using_command merge' -l squash -d "Squash changes from other branch as a single commit"
|
||||
complete -f -c git -n '__fish_git_using_command merge' -l no-squash -d "Don't squash changes"
|
||||
complete -f -c git -n '__fish_git_using_command merge' -l ff -d "Don't generate a merge commit if merge is fast forward"
|
||||
complete -f -c git -n '__fish_git_using_command merge' -l no-ff -d "Generate a merge commit even if merge is fast forward"
|
||||
|
||||
# TODO options
|
||||
|
||||
### mv
|
||||
complete -c git -n '__fish_git_needs_command' -a mv -d 'Move or rename a file, a directory, or a symlink'
|
||||
# TODO options
|
||||
|
||||
### prune
|
||||
complete -f -c git -n '__fish_git_needs_command' -a prune -d 'Prune all unreachable objects from the object database'
|
||||
# TODO options
|
||||
|
||||
### pull
|
||||
complete -f -c git -n '__fish_git_needs_command' -a pull -d 'Fetch from and merge with another repository or a local branch'
|
||||
# TODO options
|
||||
|
||||
### push
|
||||
complete -f -c git -n '__fish_git_needs_command' -a push -d 'Update remote refs along with associated objects'
|
||||
# TODO options
|
||||
|
||||
### rebase
|
||||
complete -f -c git -n '__fish_git_needs_command' -a rebase -d 'Forward-port local commits to the updated upstream head'
|
||||
complete -f -c git -n '__fish_git_using_command rebase' -a '(__fish_git_branches)' -d 'Branch'
|
||||
# TODO options
|
||||
|
||||
### reset
|
||||
complete -c git -n '__fish_git_needs_command' -a reset -d 'Reset current HEAD to the specified state'
|
||||
complete -f -c git -n '__fish_git_using_command reset' -l hard -d 'Reset files in working directory'
|
||||
complete -c git -n '__fish_git_using_command reset' -a '(__fish_git_branches)'
|
||||
# TODO options
|
||||
|
||||
### revert
|
||||
complete -f -c git -n '__fish_git_needs_command' -a revert -d 'Revert an existing commit'
|
||||
# TODO options
|
||||
|
||||
### rm
|
||||
complete -c git -n '__fish_git_needs_command' -a rm -d 'Remove files from the working tree and from the index'
|
||||
# TODO options
|
||||
|
||||
### status
|
||||
complete -f -c git -n '__fish_git_needs_command' -a status -d 'Show the working tree status'
|
||||
# TODO options
|
||||
|
||||
### tag
|
||||
complete -f -c git -n '__fish_git_needs_command' -a tag -d 'Create, list, delete or verify a tag object signed with GPG'
|
||||
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'
|
||||
complete -f -c git -n '__fish_git_using_command tag' -s d -d 'Remove a tag'
|
||||
complete -f -c git -n '__fish_git_using_command tag' -s v -d 'Verify signature of a tag'
|
||||
complete -f -c git -n '__fish_git_using_command tag' -s f -d 'Force overwriting exising tag'
|
||||
complete -f -c git -n '__fish_git_using_command tag' -s s -d 'Make a GPG-signed tag'
|
||||
complete -f -c git -n '__fish_contains_opt -s d' -a '(__fish_git_tags)' -d 'Tag'
|
||||
complete -f -c git -n '__fish_contains_opt -s v' -a '(__fish_git_tags)' -d 'Tag'
|
||||
# TODO options
|
||||
|
||||
### config
|
||||
complete -f -c git -n '__fish_git_needs_command' -a config -d 'Set and read git configuration variables'
|
||||
# TODO options
|
||||
|
||||
### format-patch
|
||||
complete -f -c git -n '__fish_git_needs_command' -a format-patch -d 'Generate patch series to send upstream'
|
||||
complete -f -c git -n '__fish_git_using_command format-patch' -a '(__fish_git_branches)' -d 'Branch'
|
||||
|
||||
### aliases (custom user-definer commands)
|
||||
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)'
|
|
@ -0,0 +1 @@
|
|||
complete -x -c pg_dump -d postgres -a "(__db_list_pg | uniq)"
|
|
@ -0,0 +1 @@
|
|||
complete -x -c psql -d 'database name' -a "(__db_list_pg | uniq)"
|
|
@ -0,0 +1,13 @@
|
|||
function __cache_or_get_rake_completion -d "Create rake completions"
|
||||
mkdir -p "/tmp/rake_completion_cache_for_$USER"
|
||||
set -l hashed_pwd (md5 -q -s (pwd))
|
||||
set -l rake_cache_file "/tmp/rake_completion_cache_for_$USER/$hashed_pwd"
|
||||
|
||||
if not test -f "$rake_cache_file"
|
||||
rake -T 2>&1 | sed -e "/^(/d" -e "s/^rake \([a-z:_0-9!\-]*\).*/\1/" > "$rake_cache_file"
|
||||
end
|
||||
|
||||
cat "$rake_cache_file"
|
||||
end
|
||||
|
||||
complete -x -c rake -a "(__cache_or_get_rake_completion)" --description 'Rake Task'
|
|
@ -0,0 +1 @@
|
|||
complete -x -c rcd -a '(rdir | sed -e "s/\/.*\///g")' --description 'Rails Project'
|
|
@ -0,0 +1 @@
|
|||
complete -x -c rmate -a '(rdir | sed -e "s/\/.*\///g")' --description 'Rails Project'
|
|
@ -1 +1,22 @@
|
|||
set -x PATH $PATH /usr/local/git/bin /usr/local/mysql/bin
|
||||
mkdir -p ~/.l
|
||||
|
||||
set fish_greeting ''
|
||||
set -x PWD "~" # some reason this is empty in new consoles
|
||||
|
||||
set -x PATH $PATH /usr/local/git/bin /usr/local/mysql/bin /usr/local/jruby/bin
|
||||
set -x CDPATH . ~ ~/Sites ~/Code /Volumes ~/.l
|
||||
|
||||
set -x EDITOR "mate -w"
|
||||
set -x VISUAL $EDITOR
|
||||
set -x GITEDITOR $EDITOR
|
||||
|
||||
set -x CLICOLOR 1
|
||||
set -x JAVA_HOME "/usr/"
|
||||
set -U BROWSER "open -a Safari"
|
||||
|
||||
|
||||
bind \cr "rake"
|
||||
|
||||
set fish_color_git_branch green
|
||||
set fish_color_cwd blue
|
||||
set fish_color_uneditable_cwd red
|
|
@ -0,0 +1,4 @@
|
|||
function __completion_cache_path
|
||||
echo "$HOME/.config/completion_caches/$argv[1]"
|
||||
|
||||
end
|
|
@ -0,0 +1,8 @@
|
|||
function __db_list
|
||||
switch $argv[1]
|
||||
case "pg"
|
||||
__db_list_pg | uniq
|
||||
case "mysql"
|
||||
end
|
||||
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
function __db_list_pg
|
||||
psql -c '\l' -t -A -F, | cut -d, -f1 | grep -E -v '^(postgres|template)'
|
||||
__db_list_web | grep -E '^postgres' | cut -f2
|
||||
|
||||
end
|
|
@ -0,0 +1,8 @@
|
|||
function __db_list_web
|
||||
switch (__detect_webapp)
|
||||
case rails merb merb_bundle
|
||||
parse_database_yml.rb config/database.yml
|
||||
case '*'
|
||||
end
|
||||
|
||||
end
|
|
@ -0,0 +1,24 @@
|
|||
function __detect_webapp
|
||||
if __sinatra_app > /dev/null
|
||||
echo sinatra
|
||||
return
|
||||
end
|
||||
|
||||
if test -d 'script'
|
||||
echo rails
|
||||
return
|
||||
end
|
||||
|
||||
if test -d 'config'
|
||||
if test -d 'bin'
|
||||
echo merb_bundle
|
||||
else
|
||||
echo merb
|
||||
end
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
echo "unknown"
|
||||
|
||||
end
|
|
@ -0,0 +1,4 @@
|
|||
function __sinatra_app
|
||||
egrep -l "^require.+sinatra.\$" *.rb
|
||||
|
||||
end
|
|
@ -0,0 +1,16 @@
|
|||
function c
|
||||
switch (__detect_webapp)
|
||||
case rails
|
||||
./script/console $argv
|
||||
case sinatra
|
||||
irb -r (__sinatra_app)
|
||||
case merb_bundle
|
||||
./bin/merb -i $argv
|
||||
case merb
|
||||
merb -i $argv
|
||||
case '*'
|
||||
echo "doesn't look like you're in a web app... using plain ol' irb"
|
||||
irb
|
||||
end
|
||||
|
||||
end
|
|
@ -0,0 +1,4 @@
|
|||
function cdgem --description 'cd to a gems directory'
|
||||
cd (dirname (gem which $argv)[2])
|
||||
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
function clean_rake_cache -d "Clean the rake autocomplete cache"
|
||||
for a in /tmp/rake_completion_cache_for_$USER/*
|
||||
rm "$a"
|
||||
end
|
||||
end
|
|
@ -1,10 +1,29 @@
|
|||
# function fish_prompt --description 'Write out the prompt'
|
||||
# set pr_timestamp (date '+%a %H:%M:%S')
|
||||
# set pr_user (whoami)
|
||||
# set pr_host (hostname | cut -d . -f 1)
|
||||
# set pr_cwd (prompt_pwd)
|
||||
# set pr_git_info (git_cwd_info)
|
||||
# printf "\033[90m$pr_timestamp\033[0m $pr_user\033[90m@\033[0m$pr_host \033[90m$pr_cwd\033[0m \033[32m>\033[0m "
|
||||
# end
|
||||
|
||||
function fish_prompt --description 'Write out the prompt'
|
||||
set pr_timestamp (date '+%a %H:%M:%S')
|
||||
set pr_user (whoami)
|
||||
set pr_host (hostname | cut -d . -f 1)
|
||||
set pr_cwd (prompt_pwd)
|
||||
set pr_git_info (git_cwd_info)
|
||||
echo -e "\033[90m$pr_timestamp\033[0m $pr_user\033[90m@\033[0m$pr_host \033[90m$pr_cwd$pr_git_info\033[0m \033[32m>\033[0m "
|
||||
|
||||
|
||||
end
|
||||
printf '%s%s@%s%s ' (set_color green) (whoami) (hostname|cut -d . -f 1) (set_color normal)
|
||||
|
||||
# Write the process working directory
|
||||
if test -w "."
|
||||
printf '%s%s ' (set_color -o $fish_color_cwd) (prompt_pwd)
|
||||
else
|
||||
printf '%s%s ' (set_color -o $fish_color_uneditable_cwd) (prompt_pwd)
|
||||
end
|
||||
|
||||
printf '%s%s ' (set_color $fish_color_git_branch) (git_parse_branch)
|
||||
|
||||
if git_dirty
|
||||
printf '%s☠ ' (set_color red)
|
||||
end
|
||||
|
||||
printf '%s$%s ' (set_color -o $fish_color_cwd) (set_color normal)
|
||||
|
||||
printf '%s> ' (set_color normal)
|
||||
end
|
|
@ -0,0 +1,3 @@
|
|||
function fish_title
|
||||
echo -n $PWD
|
||||
end
|
|
@ -7,7 +7,4 @@ function git_cwd_info
|
|||
printf "%s" (git_dirty_files_count)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
function git_dirty
|
||||
not git diff HEAD --quiet ^/dev/null
|
||||
|
||||
end
|
|
@ -1,5 +1,3 @@
|
|||
function git_parse_branch
|
||||
sh -c 'git branch --no-color 2> /dev/null' | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'
|
||||
|
||||
|
||||
end
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
function mysqlbackup -d "Dump MySQL database"
|
||||
mysqldump --add-drop-table --single-transaction --allow-keywords --hex-blob --quick -u $MYSQL_USER -p --set-variable=max_allowed_packet=1000000000 $argv
|
||||
end
|
|
@ -0,0 +1,4 @@
|
|||
function netpid --description 'list process <-> socket handles'
|
||||
sudo lsof -i -P
|
||||
|
||||
end
|
|
@ -1,4 +0,0 @@
|
|||
function parse_git_branch
|
||||
sh -c 'git branch --no-color 2> /dev/null' | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'
|
||||
|
||||
end
|
|
@ -0,0 +1,12 @@
|
|||
function rcd -d "Search for rails project and change dir"
|
||||
if test $argv
|
||||
set dir (rdir $argv)
|
||||
if test $dir
|
||||
cd $dir
|
||||
else
|
||||
echo "Cannot find any project named '$argv'"
|
||||
end
|
||||
else
|
||||
echo "Usage: rcd <project>"
|
||||
end
|
||||
end
|
|
@ -0,0 +1,24 @@
|
|||
function rdir -d "Find dir for rails project"
|
||||
if test "$argv" = "clean"
|
||||
for a in /tmp/rdir_cache/*
|
||||
rm "$a"
|
||||
end
|
||||
echo "Cache cleaned"
|
||||
else
|
||||
if test "$argv"
|
||||
set -l hashed_project (md5 -q -s "$argv")
|
||||
set -l rdir_cache_file "/tmp/rdir_cache/$hashed_project"
|
||||
if not test -f "$rdir_cache_file"
|
||||
find ~/**/$argv/config/environment.rb | head -n 1 | sed -e 's/\/config\/environment.rb$//g' > "$rdir_cache_file"
|
||||
end
|
||||
cat "$rdir_cache_file"
|
||||
else
|
||||
set -l rdir_cache_file "/tmp/rdir_cache/all_projects"
|
||||
if not test -f "$rdir_cache_file"
|
||||
mkdir -p "/tmp/rdir_cache"
|
||||
find ~/**/config/environment.rb | sed -e 's/\/config\/environment.rb$//g' > "$rdir_cache_file"
|
||||
end
|
||||
cat "$rdir_cache_file"
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,12 @@
|
|||
function rmate -d "Search for rails project and open in Textmate"
|
||||
if test $argv
|
||||
set dir (rdir $argv)
|
||||
if test $dir
|
||||
mate $dir
|
||||
else
|
||||
echo "Cannot find any project named '$argv'"
|
||||
end
|
||||
else
|
||||
echo "Usage: rmate <project>"
|
||||
end
|
||||
end
|
|
@ -0,0 +1,16 @@
|
|||
function s
|
||||
switch (__detect_webapp)
|
||||
case rails
|
||||
./script/server $argv
|
||||
case sinatra
|
||||
ruby (__sinatra_app)
|
||||
case merb_bundle
|
||||
./bin/merb $argv
|
||||
case merb
|
||||
merb $argv
|
||||
case '*'
|
||||
echo "doesn't look like you're in a web app!"
|
||||
end
|
||||
|
||||
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
function save --description 'Save current directory with name for quick access'
|
||||
echo "ln -s \"$PWD\" \"~/.l/$argv\" ./"
|
||||
ln -s "$PWD" "~/.l/$argv"
|
||||
|
||||
end
|
|
@ -0,0 +1,4 @@
|
|||
function sc --description 'Run the Rails console'
|
||||
script/console
|
||||
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
function ss --description 'Run the script/server'
|
||||
script/server
|
||||
|
||||
|
||||
end
|
|
@ -0,0 +1,4 @@
|
|||
function sshkey --description 'copy ssh keys to clipboard'
|
||||
cat ~/.ssh/*.pub | pbcopy
|
||||
|
||||
end
|
Loading…
Reference in New Issue