From b0234e7d762042551abaaf12dbaa0d917b1103af Mon Sep 17 00:00:00 2001 From: ViViDboarder Date: Wed, 3 Jun 2015 13:53:20 -0700 Subject: [PATCH] Add fish recipe --- assets/default/fish/custom/_omf-plugins.load | 12 ++ assets/default/fish/custom/alias.load | 68 ++++++ .../plugins/force/completions/force.fish | 23 ++ .../custom/plugins/port/completions/port.fish | 202 ++++++++++++++++++ .../custom/themes/thefij/fish_prompt.fish | 55 +++++ .../themes/thefij/fish_right_prompt.fish | 34 +++ my-cookbook | 12 ++ recipes/default/fish | 18 ++ 8 files changed, 424 insertions(+) create mode 100644 assets/default/fish/custom/_omf-plugins.load create mode 100644 assets/default/fish/custom/alias.load create mode 100644 assets/default/fish/custom/plugins/force/completions/force.fish create mode 100644 assets/default/fish/custom/plugins/port/completions/port.fish create mode 100644 assets/default/fish/custom/themes/thefij/fish_prompt.fish create mode 100644 assets/default/fish/custom/themes/thefij/fish_right_prompt.fish create mode 100644 recipes/default/fish diff --git a/assets/default/fish/custom/_omf-plugins.load b/assets/default/fish/custom/_omf-plugins.load new file mode 100644 index 0000000..9d3101f --- /dev/null +++ b/assets/default/fish/custom/_omf-plugins.load @@ -0,0 +1,12 @@ +Theme "thefij" + +Plugin "theme" +Plugin "bak" +Plugin "balias" +Plugin "export" +Plugin "extract" +Plugin "jump" +Plugin "osx" +Plugin "pbcopy" +Plugin "port" +Plugin "force" diff --git a/assets/default/fish/custom/alias.load b/assets/default/fish/custom/alias.load new file mode 100644 index 0000000..e489639 --- /dev/null +++ b/assets/default/fish/custom/alias.load @@ -0,0 +1,68 @@ +# vim +balias nv='nvim' +balias tv='tmux-vim' +balias :q='exit' + +# git +balias ga='git add' +balias gc='git commit' +balias gco='git checkout' +balias gd='git diff' +balias gl='git log' +balias gr='git rebase' +balias gs='git status' +balias tiga='tig --all' + +# cd +balias cd..='cd ..' + +# vim +balias mviml='env VIM_COLOR=github mvim' +balias gvim='mvim' + +# yelp +balias moshdev='mosh dev7-devc' +balias sshadev='ssh -A dev7-devc' +# Copy remote tmux clipboard +balias rpbcopy='ssh dev7-devc "TMPDIR=/nail/tmp tmux show-buffer" | pbcopy' + +balias force-login-dev='force login ;and rsync -av /Users/ifij/.force/accounts/ dev7-devc:~/.force/accounts' + +# projects +balias cd-sf='cd ~/workspace/salesforce-apex' + +# git +balias mybranches='git branch --list ifij/*' +balias mb='git branch --list ifij/*' + +# vagrant +balias vssh='vagrant ssh' +balias vmosh='mosh vagrant@localhost -p 2222' +balias vrl='vagrant reload' +balias vbm='mosh -p 3122 --ssh="ssh -p 3022" ifij@localhost' + +# terminal-notifier +balias notify-done='terminal-notifier -message "Done"' +balias notify-success='terminal-notifier -message "Success"' +balias notify-fail='terminal-notifier -message "Failure"' + +# function sh-notify +# ($argv) ;and notify-success ;or notify-fail +# end + +# gl-notifire +balias gl-notify-done='gl-notifier "Done"' +balias gl-notify-success='gl-notifier "Success"' +balias gl-notify-fail='gl-notifier "Failure"' + +# function gl-notify +# ($argv) ;and gl-notify-success ;or gl-notify-fail +# end + +# gopush +balias pb-done='pb "Done"' +balias pb-success='pb "Success"' +balias pb-failure='pb "Failure"' +# function pb-notify +# ($argv) ;and pb-success ;or pb-failure +# end diff --git a/assets/default/fish/custom/plugins/force/completions/force.fish b/assets/default/fish/custom/plugins/force/completions/force.fish new file mode 100644 index 0000000..ccab2a3 --- /dev/null +++ b/assets/default/fish/custom/plugins/force/completions/force.fish @@ -0,0 +1,23 @@ +function __fish_force_needs_command + set cmd (commandline -opc) + if [ (count $cmd) -eq 1 -a $cmd[1] = 'force' ] + return 0 + end + return 1 +end + +function __fish_force_using_command + set cmd (commandline -opc) + if [ (count $cmd) -gt 1 ] + if [ $argv[1] = $cmd[2] ] + return 0 + end + end + return 1 +end + +complete -f -c force -n '__fish_force_needs_command' -a login -d 'Log into an environment' +complete -f -c force -n '__fish_force_using_command login' -a '-i' -d 'Specify environment' + +complete -f -c force -n '__fish_force_needs_command' -a push -d 'Push a change to Salesforce' +complete -f -c force -n '__fish_force_needs_command' -a test -d 'Run specified test name' diff --git a/assets/default/fish/custom/plugins/port/completions/port.fish b/assets/default/fish/custom/plugins/port/completions/port.fish new file mode 100644 index 0000000..ed5a58e --- /dev/null +++ b/assets/default/fish/custom/plugins/port/completions/port.fish @@ -0,0 +1,202 @@ +function __fish_port_needs_command + set cmd (commandline -opc) + if [ (count $cmd) -eq 1 -a $cmd[1] = 'port' ] + return 0 + end + return 1 +end + +function __fish_port_using_command + set cmd (commandline -opc) + if [ (count $cmd) -gt 1 ] + if [ $argv[1] = $cmd[2] ] + return 0 + end + end + return 1 +end + +function __fish_port_list + port list | cut -d' ' -f1 +end + +function __fish_port_installed + port installed | cut -d' ' -f1 +end + +function __fish_port_outdated_formulas + port outdated | cut -d' ' -f1 +end + +set -l pseudo_portnames = 'all current active inactive actintact installed uninstalled outdated obsolete requested unrequested leaves' + +############ +# commands # +############ + +# activate +complete -f -c port -n '__fish_port_needs_command' -a activate -d 'Activates installed portname' +complete -f -c port -n '__fish_port_using_command activate' -a '(__fish_port_installed)' + +# # cat +# complete -f -c port -n '__fish_port_needs_command' -a cat -d 'Display formula' +# complete -f -c port -n '__fish_port_using_command cat' -a '(__fish_port_list)' +# +# # cleanup +# complete -f -c port -n '__fish_port_needs_command' -a cleanup -d 'Remove old installed versions' +# complete -f -c port -n '__fish_port_using_command cleanup' -l force -d 'Remove out-of-date keg-only ports as well' +# complete -f -c port -n '__fish_port_using_command cleanup' -s n -d 'Dry run' +# complete -f -c port -n '__fish_port_using_command cleanup' -s s -d 'Scrubs the cache' +# complete -f -c port -n '__fish_port_using_command cleanup' -a '(__fish_port_installed)' +# +# # create +# complete -f -c port -n '__fish_port_needs_command' -a create -d 'Create new formula from URL' +# complete -f -c port -n '__fish_port_using_command create' -l cmake -d 'Use template for CMake-style build' +# complete -f -c port -n '__fish_port_using_command create' -l autotools -d 'Use template for Autotools-style build' +# complete -f -c port -n '__fish_port_using_command create' -l no-fetch -d 'Don\'t download URL' +# +# # deps +# complete -f -c port -n '__fish_port_needs_command' -a deps -d 'Show a formula\'s dependencies' +# complete -f -c port -n '__fish_port_using_command deps' -l 1 -d 'Show only 1 level down' +# complete -f -c port -n '__fish_port_using_command deps' -s n -d 'Show in topological order' +# complete -f -c port -n '__fish_port_using_command deps' -l tree -d 'Show dependencies as tree' +# complete -f -c port -n '__fish_port_using_command deps' -l all -d 'Show dependencies for all formulae' +# complete -f -c port -n '__fish_port_using_command deps' -a '(__fish_port_list)' +# +# # diy +# complete -f -c port -n '__fish_port_needs_command' -a 'diy configure' -d 'Determine installation prefix for non-port software' +# complete -f -c port -n '__fish_port_using_command diy' -l set-name -d 'Set name of package' +# complete -f -c port -n '__fish_port_using_command diy' -l set-version -d 'Set version of package' +# +# complete -f -c port -n '__fish_port_needs_command' -a 'doctor' -d 'Check your system for problems' +# complete -f -c port -n '__fish_port_needs_command' -a 'edit' -d 'Open port/formula for editing' +# +# # fetch +# complete -f -c port -n '__fish_port_needs_command' -a fetch -d 'Download source for formula' +# complete -f -c port -n '__fish_port_using_command fetch' -l force -d 'Remove a previously cached version and re-fetch' +# complete -f -c port -n '__fish_port_using_command fetch' -l HEAD -d 'Download the HEAD version from a VCS' +# complete -f -c port -n '__fish_port_using_command fetch' -l deps -d 'Also download dependencies' +# complete -f -c port -n '__fish_port_using_command fetch' -s v -d 'Make HEAD checkout verbose' +# complete -f -c port -n '__fish_port_using_command fetch' -a '(__fish_port_list)' +# +# complete -f -c port -n '__fish_port_needs_command' -a 'help' -d 'Display help' +# +# # home +# complete -f -c port -n '__fish_port_needs_command' -a home -d 'Open port/formula\'s homepage' +# complete -c port -n '__fish_port_using_command home' -a '(__fish_port_list)' +# +# # info +# complete -f -c port -n '__fish_port_needs_command' -a 'info abv' -d 'Display information about formula' +# complete -f -c port -n '__fish_port_using_command info' -l all -d 'Display info for all formulae' +# complete -f -c port -n '__fish_port_using_command info' -l github -d 'Open the GitHub History page for formula' +# complete -c port -n '__fish_port_using_command info' -a '(__fish_port_list)' + +# install +complete -f -c port -n '__fish_port_needs_command' -a 'install' -d 'Install and activate portname' +# complete -f -c port -n '__fish_port_using_command install' -l interactive -d 'Download and patch formula, then open a shell' +complete -c port -n '__fish_port_using_command install' -a '(__fish_port_list)' -d 'portname' + +# # link +# complete -f -c port -n '__fish_port_needs_command' -a 'link ln' -d 'Symlink installed formula' +# complete -f -c port -n '__fish_port_using_command link' -a '(__fish_port_installed)' +# complete -f -c port -n '__fish_port_using_command ln' -a '(__fish_port_installed)' + +# list +complete -f -c port -n '__fish_port_needs_command' -a 'list ls' -d 'List all installed formula' +complete -f -c port -n '__fish_port_using_command list' -l unported -d 'List all files in the Homeport prefix not installed by port' +complete -f -c port -n '__fish_port_using_command list' -l versions -d 'Show the version number' +complete -c port -n '__fish_port_using_command list' -a '(__fish_port_list)' + +# #ls +# complete -f -c port -n '__fish_port_using_command ls' -l unported -d 'List all files in the Homeport prefix not installed by port' +# complete -f -c port -n '__fish_port_using_command ls' -l versions -d 'Show the version number' +# complete -c port -n '__fish_port_using_command ls' -a '(__fish_port_list)' +# +# # log +# complete -f -c port -n '__fish_port_needs_command' -a log -d 'Show log for formula' +# complete -c port -n '__fish_port_using_command log' -a '(__fish_port_list)' -d 'formula' +# +# # missing +# complete -f -c port -n '__fish_port_needs_command' -a missing -d 'Check formula for missing dependencies' +# complete -c port -n '__fish_port_using_command missing' -a '(__fish_port_list)' -d 'formula' +# +# # options +# complete -f -c port -n '__fish_port_needs_command' -a options -d 'Display install options for formula' +# complete -c port -n '__fish_port_using_command options' -a '(__fish_port_list)' -d 'formula' +# +# # outdated +# complete -f -c port -n '__fish_port_needs_command' -a outdated -d 'Show formula that have updated versions' +# complete -f -c port -n '__fish_port_using_command outdated' -l quiet -d 'Display only names' +# +# # prune +# complete -f -c port -n '__fish_port_needs_command' -a prune -d 'Remove dead symlinks' +# +# # search +# complete -f -c port -n '__fish_port_needs_command' -a 'search -S' -d 'Search for formula by name' +# complete -f -c port -n '__fish_port_using_command search' -l macports -d 'Search on MacPorts' +# complete -f -c port -n '__fish_port_using_command search' -l fink -d 'Search on Fink' +# complete -f -c port -n '__fish_port_using_command -S' -l macports -d 'Search on MacPorts' +# complete -f -c port -n '__fish_port_using_command -S' -l fink -d 'Search on Fink' +# +# # tap +# complete -f -c port -n '__fish_port_needs_command' -a tap -d 'Tap a new formula repository on GitHub' +# +# # test +# complete -f -c port -n '__fish_port_needs_command' -a test -d 'Run tests for formula' +# complete -c port -n '__fish_port_using_command test' -a '(__fish_port_list)' -d 'formula' +# +# # uninstall +# complete -f -c port -n '__fish_port_needs_command' -a 'uninstall remove rm' -d 'Uninstall formula' +# complete -f -c port -n '__fish_port_using_command uninstall' -a '(__fish_port_installed)' +# complete -f -c port -n '__fish_port_using_command remove' -a '(__fish_port_installed)' +# complete -f -c port -n '__fish_port_using_command rm' -a '(__fish_port_installed)' +# complete -f -c port -n '__fish_port_using_command uninstall' -l force -d 'Delete all installed versions' +# complete -f -c port -n '__fish_port_using_command remove' -l force -d 'Delete all installed versions' +# complete -f -c port -n '__fish_port_using_command rm' -l force -d 'Delete all installed versions' +# +# # unlink +# complete -f -c port -n '__fish_port_needs_command' -a unlink -d 'Unlink formula' +# complete -c port -n '__fish_port_using_command unlink' -a '(__fish_port_installed)' +# +# # untap +# complete -f -c port -n '__fish_port_needs_command' -a untap -d 'Remove a tapped repository' +# +# # update +# complete -f -c port -n '__fish_port_needs_command' -a update -d 'Fetch newest version of Homeport and formulas' +# complete -f -c port -n '__fish_port_using_command update' -l rebase -d 'Use git pull --rebase' +# +# # upgrade +complete -f -c port -n '__fish_port_needs_command' -a upgrade -d 'Upgrade outdated ports' +complete -f -c port -n '__fish_port_using_command upgrade' -a "$pseudo_portnames" -d 'pseudo portname' +complete -f -c port -n '__fish_port_using_command upgrade' -a "(__fish_port_outdated_formulas)" -d 'outdated portname' +# +# # uses +# complete -f -c port -n '__fish_port_needs_command' -a uses -d 'Show formulas that depend on specified formula' +# complete -f -c port -n '__fish_port_using_command uses' -l installed -d 'List only installed formulae' +# complete -c port -n '__fish_port_using_command uses' -a '(__fish_port_list)' +# +# # versions +# complete -f -c port -n '__fish_port_needs_command' -a versions -d 'List previous versions of formula' +# complete -f -c port -n '__fish_port_using_command versions' -l compact -d 'Show all options on a single line' +# complete -c port -n '__fish_port_using_command versions' -a '(__fish_port_list)' +# +# +# ############ +# # switches # +# ############ +# complete -f -c port -n '__fish_port_needs_command' -a '-v --version' -d 'Print version number of port' +# complete -f -c port -n '__fish_port_needs_command' -l repository -x -d 'Display where Homeport\'s .git directory is located' +# complete -f -c port -n '__fish_port_needs_command' -l config -x -d 'Show Homeport and system configuration' +# +# # --prefix +# complete -f -c port -n '__fish_port_needs_command' -l prefix -d 'Display Homeport\'s install path' +# complete -f -c port -n '__fish_port_using_command --prefix' -a '(__fish_port_list)' -d 'Display formula\'s install path' +# +# # --cache +# complete -f -c port -n '__fish_port_needs_command' -l cache -d 'Display Homeport\'s download cache' +# complete -f -c port -n '__fish_port_needs_command' -n '__fish_port_using_command --cache' -a '(__fish_port_list)' -d 'Display the file or directory used to cache formula' +# +# # --cellar +# complete -f -c port -n '__fish_port_needs_command' -l cellar -d 'Display Homeport\'s Cellar path' +# complete -f -c port -n '__fish_port_using_command --cellar' -a '(__fish_port_list)' -d 'Display formula\'s install path in Cellar' +# diff --git a/assets/default/fish/custom/themes/thefij/fish_prompt.fish b/assets/default/fish/custom/themes/thefij/fish_prompt.fish new file mode 100644 index 0000000..472c4bc --- /dev/null +++ b/assets/default/fish/custom/themes/thefij/fish_prompt.fish @@ -0,0 +1,55 @@ +# name: RobbyRussel +# +# You can override some default options in your config.fish: +# set -g theme_display_git_untracked no + +function _git_branch_name + echo (command git symbolic-ref HEAD ^/dev/null | sed -e 's|^refs/heads/||') +end + +function _is_git_dirty + set -l show_untracked (git config --bool bash.showUntrackedFiles) + set untracked '' + if [ "$theme_display_git_untracked" = 'no' -o "$show_untracked" = 'false' ] + set untracked '--untracked-files=no' + end + echo (command git status -s --ignore-submodules=dirty $untracked ^/dev/null) +end + +function _prompt_char + if [ (whoami) = 'root' ] + echo '#' + else + echo '$' + end +end + +function fish_prompt + set -l last_status $status + set -l cyan (set_color -o cyan) + set -l yellow (set_color -o yellow) + set -l red (set_color -o red) + set -l blue (set_color -o blue) + set -l green (set_color -o green) + set -l normal (set_color normal) + + if test $last_status = 0 + set arrow "$green➜ " + else + set arrow "$red➜ " + end + set -l cwd $normal(basename (prompt_pwd)) + + if [ (_git_branch_name) ] + if [ (_is_git_dirty) ] + set branch_color "$red" + else + set branch_color "$yellow" + end + set -l git_branch (_git_branch_name) + set git_info " $branch_color($git_branch)" + end + + echo -n -s $arrow $cwd $git_info $normal (_prompt_char) ' ' +end + diff --git a/assets/default/fish/custom/themes/thefij/fish_right_prompt.fish b/assets/default/fish/custom/themes/thefij/fish_right_prompt.fish new file mode 100644 index 0000000..76b22cd --- /dev/null +++ b/assets/default/fish/custom/themes/thefij/fish_right_prompt.fish @@ -0,0 +1,34 @@ +# TODO: [force_target] [virtualenv] +# TODO: Eventually... make pluggable so plugins can add to prompt + +# function _atf_target +# set -l org (atf-target 2> /dev/null) || return +# echo " [$org]" +# end +# + +function _force_target + if [ (git config force.use) ] + set -l org (force-target) + echo " [$org]" + end +end + +function _virtual_env + if [ $VIRTUAL_ENV ] + set -l venv (basename "$VIRTUAL_ENV") + echo " [$venv]" + end +end + +function fish_right_prompt -d 'Write out the right prompt of thefij theme' + set -l cyan (set_color -o cyan) + set -l yellow (set_color -o yellow) + set -l red (set_color -o red) + set -l blue (set_color -o blue) + set -l green (set_color -o green) + set -l normal (set_color normal) + + echo -n $green (_force_target) (_virtual_env) + set_color normal +end diff --git a/my-cookbook b/my-cookbook index 74a6ec6..4171fa5 100755 --- a/my-cookbook +++ b/my-cookbook @@ -49,6 +49,13 @@ if prompt_yn "Install Go?" ; then install_golang=true fi +# Optional +install_fish=false +is_installed "fish" +if prompt_yn "Install fish?" ; then + install_fish=true +fi + ### Run recipes recipe 'dotfiles' recipe 'bin' @@ -82,6 +89,11 @@ if $install_golang ; then set_installed 'golang' fi +if $install_fish ; then + recipe 'fish' + set_installed 'fish' +fi + ### Show the Finished banner finished diff --git a/recipes/default/fish b/recipes/default/fish new file mode 100644 index 0000000..be8af8f --- /dev/null +++ b/recipes/default/fish @@ -0,0 +1,18 @@ +#! /bin/bash + +sudo_package 'fish' + +if [ ! -d $HOME/.oh-my-fish ]; then + curl -L https://github.com/bpinto/oh-my-fish/raw/master/tools/install.fish | fish +fi + +OMF_CUSTOM=$DEFAULT_ASSETS_PATH/custom +FISH_CONFIG=$HOME/.config/fish/config.fish + +if [ ! -f $FISH_CONFIG ]; then + touch $FISH_CONFIG +fi + +add_line 'set fish_path $HOME/.oh-my-fish' $FISH_CONFIG +add_line "set fish_custom $OMF_CUSTOM" $FISH_CONFIG +add_line '. $fish_path/oh-my-fish.fish' $FISH_CONFIG