bf4 / bf4.github.com

jekyll blog on github pages
http://benjaminfleischer.com
MIT License
2 stars 0 forks source link

prompt stuff #10

Open bf4 opened 8 years ago

bf4 commented 8 years ago

Prompt (style and completion)

Style

# .profile

# use mac's git prompt if git isn't brewed
if [ ! -f "$(brew --prefix)/etc/bash_completion.d/git-prompt.sh" ]; then  
  source /Applications/Xcode.app/Contents/Developer/usr/share/git-core/git-prompt.bash
else
  source "$(brew --prefix)/etc/bash_completion.d/git-prompt.sh"
fi

__my_lang_prompt() {
  [ -f ~/.rvm/bin/rvm-prompt ] && eval ~/.rvm/bin/rvm-prompt
}
build_git_prompt() {
  git_prompt=$(__git_ps1 "(%s)")
}

if ! $(echo $PROMPT_COMMAND | grep -q build_git_prompt); then
  PROMPT_COMMAND="build_git_prompt; $PROMPT_COMMAND"
fi
# .bash_profile

# Default Git enabled prompt with dirty state
export PS1="\$(__my_lang_prompt)\$git_prompt \w\nšŸ“ $ "

# Default Git enabled root prompt (for use with "sudo -s")
# doesn't require txtuid
txtuid="$([ $UID -eq "0" ] && echo $txtred || echo $txtwht)" # user/sudo color
bakred="$(tput setab 1 2>/dev/null || echo '\e[41m')"  # Red
txtrst="$(tput sgr 0 2>/dev/null || echo '\e[0m')"  # Text Reset
export SUDO_PS1="\[$bakred\]\u@\h\[$txtrst\] \w\$ "

Completion

# .bash_profile

_source_if_exists() {
  [ -f "$1" ] && source "$1"
}
# brew install bash_completion
# Homebrew's own bash completion script has been installed to
#   /usr/local/etc/bash_completion.d
#
#   Bash completion has been installed to:
#     /usr/local/etc/bash_completion.d
_source_if_exists "$(brew --prefix)/etc/bash_completion"

# shell_name=$(echo $0 | cut -d- -f2)
# shell_completions_file="$(brew --repository)/Library/Contributions/brew_$(echo $0 | cut -d- -f2)_completion.sh"
# [ -s $shell_completions_file ] && source $shell_completions_file

# If Commandline tools are installed without Xcode.app,
# we'll fall back to local git completion
# handle various places git completion may be
# if not using homebrew git completion
if [ ! -f "$(brew --prefix)/etc/bash_completion.d/git-completion.bash" ]; then
  if [ -s /Applications/Xcode.app/Contents/Developer/usr/share/git-core/git-completion.bash ]; then
    # echo "using apple git completion for /usr/bin/git"
    source /Applications/Xcode.app/Contents/Developer/usr/share/git-core/git-completion.bash
  else
    # fall back to local (linked) copy
    # echo "using local git completion"
    source $HOME/.git-completion.sh
    # maybe see brew install bash-completion
    # source $(brew --prefix)/etc/bash_completion.d/git-prompt.sh
  fi
fi
# brew install grc
_source_if_exists "$(brew --prefix grc)/etc/grc.bashrc"

_source_if_exists "$(brew --prefix)/etc/bash_completion.d/go"

Git niceties

# https://git-scm.com/docs/git-config
# http://mislav.uniqpath.com/2010/07/git-tips/
# http://stackoverflow.com/a/1371215
[core]
    editor = vim
    excludesfile = ~/.gitignore_global
    whitespace = trailing-space,space-before-tab
[branch]
    autoSetupRebase = always
[fetch]
    prune = true
[push]
    default = current
[pull]
    # see https://github.com/thoughtbot/dotfiles/pull/377
    # autosquash = true
    rebase = true
[merge]
    ff = only
[rerere]
    enabled = 1
    autoupdate = 1
[include]
    path = ~/.gitconfig.local
[credential]
    helper = osxkeychain
[alias]
    extend = commit --amend -C HEAD
    rbc = rebase --continue
    prune-merged-local = "!git branch --merged | while read branch ; do git branch -D $branch 2>/dev/null ; done"
    plog = log --pretty=format:'%C(red)%h%C(reset) | %C(green)%ad%Creset | %C(yellow)%d%C(reset) %s %C(bold blue)[%an]%Creset | (%cr)'  --date=short
[color]
    diff = auto
    status = auto
    branch = auto
[color "branch"]
    current = yellow reverse
    local = yellow
    remote = green
[color "diff"]
    meta = yellow bold
    frag = magenta bold
    old = red bold
    new = cyan bold
[color "status"]
    added = yellow
    changed = green
    untracked = cyan

Verbose setup

  1. Go to the apple developer site and download and install the "command line tools" package. This will provide a C compiler and other build tools.

    sudo xcodebuild -license # offers option to install only Command line tools
    `open /Applications/Xcode.app`
    xcode-select --install

    If you want the full XCode, install from app store https://developer.apple.com/xcode/downloads/ https://itunes.apple.com/us/app/xcode/id497799835?ls=1&mt=12

  2. Install the homebrew package manager:

    ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
  3. Install git:

    brew install git
    # Identify yourself in commits (if you haven't set $GIT_COMMITTER_NAME nor $EMAIL)
    git config --global user.name "First Last"
    git config --global user.email "first.last@example.com"
  4. Setup GitHub

    1. If you don't have a GitHub user account, create one.
    2. Then, follow the ssh key instructions here -> https://help.github.com/articles/generating-ssh-keys to add your ssh key to GitHub so that you can do the next step.

      # if you don't have a ~/.ssh/id_rsa.pub
      
      email="first.last@example.com"
      ssh-keygen -t rsa -b 4096 -C "$email"
      # Creates a new ssh key, using the provided email as a label
      # Generating public/private rsa key pair.
      
      # Enter file in which to save the key (/Users/you/.ssh/id_rsa): [Press enter]
      
      # Enter passphrase (empty for no passphrase): [Press enter]
      # Enter same passphrase again: [Press enter]
      
      # Your identification has been saved in /Users/you/.ssh/id_rsa.
      # Your public key has been saved in /Users/you/.ssh/id_rsa.pub.
      # The key fingerprint is:
      #01:0f:f4:3b:ca:85:d6:17:a1:7d:f0:68:9d:f0:a2:db your_email@example.com
      
      # Ensure your ssh agent is configured
      
      # start the ssh-agent in the background
      eval "$(ssh-agent -s)"
      # Agent pid 59566
      
      ssh-add ~/.ssh/id_rsa
      
      # Add your public ssh key to GitHub
      
      pbcopy < ~/.ssh/id_rsa.pub
      
      # Add SSH key
      https://github.com/settings/ssh
      # Give it a nice name like 'omg my mac'
      
      # While here, optionally set up notifications to go to your desired email
      https://github.com/settings/emails
      
      ssh -T git@github.com
      
      # The authenticity of host 'github.com (207.97.227.239)' can't be established.
      # RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
      # Are you sure you want to continue connecting (yes/no)? [ yes ]
      
      # Hi username! You've successfully authenticated, but GitHub does not
      # provide shell access.
  5. Install Ruby (rvm instructions follow):

    curl -L https://get.rvm.io | bash --auto-dotfiles

    Brews (packages and programs)

===Installed brews===

aws-elasticbeanstalk
awscli
bash-completion
chruby
cowsay
ctags
fortune
gdbm
gnupg
grc
homebrew/dupes/rsync
homebrew/versions/mysql55
hub
imagemagick
jq
libyaml
llvm
macvim
nginx
nvm
pyenv
qt
rabbitmq
readline
reattach-to-user-namespace
redis
ruby-install
shellcheck
sysdig
terminal-notifier
the_silver_searcher
tmux
trash
tree
watchman
youtube-dl
shopify/shopify/toxiproxy

===Installed casks===

appcleaner
caffeine
cyberduck
firefox
github
gitx
google-chrome
google-drive
iterm2
java
keka
libreoffice
lunchy
mediainfo
netnewswire
nvalt
pgadmin3
postgres
sequel-pro
sqlitebrowser
vagrant
virtualbox
vlc
bf4 commented 6 years ago

colors

ANSI https://github.com/sickill/rainbow