Skip to content

Commit e4fb1c5

Browse files
initial setup.
0 parents  commit e4fb1c5

File tree

8 files changed

+370
-0
lines changed

8 files changed

+370
-0
lines changed

README.org

Whitespace-only changes.

gitconfig

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
[include]
2+
path = ~/.gitconfig.user
3+
[push]
4+
default = current
5+
[color]
6+
ui = auto
7+
[core]
8+
excludesfile = ~/.gitignore
9+
autocrlf = input
10+
[merge]
11+
ff = only
12+
[fetch]
13+
prune = true
14+
[rebase]
15+
autosquash = true
16+
[diff]
17+
colorMoved = zebra
18+
[alias]
19+
aa = add --all
20+
branches = for-each-ref --sort=-committerdate --format=\"%(color:blue)%(authordate:relative)\t%(color:red)%(authorname)\t%(color:white)%(color:bold)%(refname:short)\" refs/remotes
21+
c = commit -v
22+
ca = commit --amend
23+
co = checkout
24+
d = diff
25+
dc = diff --cached
26+
ds = diff --staged
27+
fup = !git fetch origin && git rebase origin/develop
28+
lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%Creset' --abbrev-commit --date=relative
29+
pf = push --force-with-lease
30+
pullr = "!f() { git fetch ${2:-origin} refs/pull/$1/head:pr/pull_$1; } ; f"
31+
st = status
32+
who = shortlog -n -s --no-merges

gitmessage

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
3+
# 50-character subject line
4+
#
5+
# 72-character wrapped longer description. This should answer:
6+
#
7+
# * Why was this change necessary?
8+
# * How does it address the problem?
9+
# * Are there any side effects?
10+
#
11+
# Include a link to the ticket, if any.
12+
#
13+
# Add co-authors if you worked on this code with others:
14+
#
15+
# Co-authored-by: Full Name <[email protected]>
16+
# Co-authored-by: Full Name <[email protected]>

os/darwin

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#!/bin/bash
2+
HOMEBREW_PREFIX="/usr/local"
3+
4+
install_homebrew() {
5+
if [ -d "$HOMEBREW_PREFIX" ]; then
6+
if ! [ -r "$HOMEBREW_PREFIX" ]; then
7+
sudo chown -R "$LOGNAME:admin" /usr/local
8+
fi
9+
else
10+
sudo mkdir "$HOMEBREW_PREFIX"
11+
sudo chflags norestricted "$HOMEBREW_PREFIX"
12+
sudo chown -R "$LOGNAME:admin" "$HOMEBREW_PREFIX"
13+
fi
14+
15+
if ! command -v brew >/dev/null; then
16+
fancy_echo "Installing Homebrew ..."
17+
curl -fsS \
18+
'https://raw.githubusercontent.com/Homebrew/install/master/install' | ruby
19+
20+
append_to_zshrc '# recommended by brew doctor'
21+
22+
# shellcheck disable=SC2016
23+
append_to_zshrc 'export PATH="/usr/local/bin:$PATH"' 1
24+
25+
export PATH="/usr/local/bin:$PATH"
26+
fi
27+
}
28+
29+
install_homebrew
30+
31+
if brew list | grep -Fq brew-cask; then
32+
fancy_echo "Uninstalling old Homebrew-Cask ..."
33+
brew uninstall --force brew-cask
34+
fi
35+
36+
fancy_echo "Updating Homebrew formulae ..."
37+
brew update --force # https://github.com/Homebrew/brew/issues/1151
38+
brew bundle --file=- <<EOF
39+
tap "thoughtbot/formulae"
40+
tap "homebrew/services"
41+
42+
# Unix
43+
brew "git"
44+
brew "openssl"
45+
brew "the_silver_searcher"
46+
brew "tmux"
47+
brew "vim"
48+
brew "watchman"
49+
brew "zsh"
50+
51+
# GitHub
52+
brew "hub"
53+
54+
# Image manipulation
55+
brew "imagemagick"
56+
57+
# Programming language prerequisites and package managers
58+
brew "libyaml" # should come after openssl
59+
brew "coreutils"
60+
brew "yarn"
61+
cask "gpg-suite"
62+
63+
# Databases
64+
brew "postgres", restart_service: :changed
65+
brew "redis", restart_service: :changed
66+
EOF

os/linux-gnu

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#!/bin/bash
2+
3+
OS=
4+
RELEASE=$(cat /etc/*release | grep ^NAME)
5+
6+
if grep -q Fedora <<< $RELEASE; then
7+
OS=Fedora
8+
elif grep -q Ubuntu <<< $RELEASE; then
9+
OS=Debian
10+
elif grep -q Debian <<< $RELEASE; then
11+
OS=Debian
12+
fi
13+
14+
SHARED_PACKAGES=$(cat <<EOF
15+
git zsh vim tmux httpie vim hub
16+
EOF
17+
)
18+
19+
DEBIAN_PACKAGES=$(cat <<EOF
20+
$SHARED_PACKAGES
21+
build-essential
22+
23+
imagemagick shellcheck
24+
silversearcher-ag shellcheck
25+
EOF
26+
)
27+
28+
FEDORA_PACKAGES=$(cat <<EOF
29+
$SHARED_PACKAGES
30+
31+
git-lfs the_silver_searcher
32+
ShellCheck ImageMagick
33+
postgresql-server postgresql-contrib libpq-devel redis
34+
35+
openssl-devel
36+
EOF
37+
)
38+
39+
systemd_enable_databases_on_restart() {
40+
fancy_echo "Ensuring Postgresql Redis run on startup."
41+
if sudo bash -c '[ ! -d "/var/lib/pgsql/data" ]'; then
42+
sudo /usr/bin/postgresql-setup --initdb
43+
fi
44+
sudo systemctl start postgresql
45+
sudo systemctl start redis
46+
sudo systemctl enable postgresql
47+
sudo systemctl enable redis
48+
}
49+
50+
case $OS in
51+
Fedora)
52+
fancy_echo "Installing packages using dnf"
53+
sudo dnf groupinstall -y "C Development Tools and Libraries"
54+
sudo dnf -y install $FEDORA_PACKAGES
55+
systemd_enable_databases_on_restart
56+
;;
57+
Debian)
58+
fancy_echo "Installing packages using apt"
59+
sudo apt install -y $DEBIAN_PACKAGES
60+
systemd_enable_databases_on_restart
61+
;;
62+
*)
63+
fancy_echo "You're OS is not detected, cannot install packages."
64+
;;
65+
esac

psqlrc

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
-- Official docs: http://www.postgresql.org/docs/9.3/static/app-psql.html
2+
3+
-- Don't display the "helpful" message on startup.
4+
\set QUIET 1
5+
\pset null '[NULL]'
6+
7+
-- http://www.postgresql.org/docs/9.3/static/app-psql.html#APP-PSQL-PROMPTING
8+
\set PROMPT1 '%[%033[1m%]%M %n@%/%R%[%033[0m%]%# '
9+
-- PROMPT2 is printed when the prompt expects more input, like when you type
10+
-- SELECT * FROM<enter>. %R shows what type of input it expects.
11+
\set PROMPT2 '[more] %R > '
12+
13+
-- Show how long each query takes to execute
14+
\timing
15+
16+
-- Use best available output format
17+
\x auto
18+
\set VERBOSITY verbose
19+
\set HISTFILE ~/.psql_history- :DBNAME
20+
\set HISTCONTROL ignoredups
21+
\set COMP_KEYWORD_CASE upper
22+
\unset QUIET

setup

+100
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
#!/bin/sh
2+
3+
set -e
4+
5+
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
6+
7+
append_to_zshrc() {
8+
local text="$1" zshrc
9+
local skip_new_line="${2:-0}"
10+
11+
if [ -w "$HOME/.zshrc.local" ]; then
12+
zshrc="$HOME/.zshrc.local"
13+
else
14+
zshrc="$HOME/.zshrc"
15+
fi
16+
17+
if ! grep -Fqs "$text" "$zshrc"; then
18+
if [ "$skip_new_line" -eq 1 ]; then
19+
printf "%s\\n" "$text" >> "$zshrc"
20+
else
21+
printf "\\n%s\\n" "$text" >> "$zshrc"
22+
fi
23+
fi
24+
}
25+
26+
link_dotfile() {
27+
if [ -L "$HOME/.$1" ] && [ ! -a "HOME/.$1" ]; then
28+
rm "$HOME/.$1"
29+
fi
30+
31+
if [ -e "$HOME/.$1" ] && [ ! -L "$HOME/.$1" ]; then
32+
echo "File already exists at $HOME/.$1 I will back it up for you..."
33+
mv "$HOME/.$1"{,.link.backup}
34+
echo "$HOME/.$1.link.backup created"
35+
fi
36+
37+
echo "Linking $1"
38+
ln -sf "$DIR/$1" "$HOME/.$1"
39+
}
40+
41+
fancy_echo() {
42+
local fmt="$1"; shift
43+
printf "\\n$fmt\\n" "$@"
44+
}
45+
46+
install_nvm() {
47+
mkdir "$HOME/.nvm"
48+
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.1/install.sh | bash
49+
nvm --install lts stable
50+
nvm alias default stable
51+
}
52+
53+
install_os_specific_packages() {
54+
if [ -f "os/$OSTYPE" ]; then
55+
source "os/$OSTYPE"
56+
fi
57+
}
58+
59+
install_vim_plug() {
60+
if [ ! -d "$HOME/.nvm" ]; then
61+
fancy_echo "Installing Node ..."
62+
install_nvm
63+
fi
64+
}
65+
66+
update_shell() {
67+
local shell_path;
68+
shell_path="$(command -v zsh)"
69+
70+
fancy_echo "Changing your shell to zsh ..."
71+
if ! grep "$shell_path" /etc/shells > /dev/null 2>&1 ; then
72+
fancy_echo "Adding '$shell_path' to /etc/shells"
73+
sudo sh -c "echo $shell_path >> /etc/shells"
74+
fi
75+
sudo chsh -s "$shell_path" "$USER"
76+
}
77+
78+
fancy_echo "Installing OS Specific Packages ..."
79+
install_os_specific_packages
80+
81+
case "$SHELL" in
82+
*/zsh)
83+
if [ "$(command -v zsh)" != '/usr/local/bin/zsh' ] ; then
84+
update_shell
85+
fi
86+
;;
87+
*)
88+
update_shell
89+
;;
90+
esac
91+
92+
link_dotfile gitconfig
93+
link_dotfile zshrc
94+
link_dotfile psqlrc
95+
link_dotfile gitmessage
96+
97+
if [ ! -d "$HOME/.nvm" ]; then
98+
fancy_echo "Installing Node ..."
99+
install_nvm
100+
fi

zshrc

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# If not running interactively, don't do anything
2+
[[ $- != *i* ]] && return
3+
4+
setopt hist_ignore_all_dups inc_append_history
5+
HISTFILE=~/.zhistory
6+
HISTSIZE=4096
7+
SAVEHIST=4096
8+
export ERL_AFLAGS="-kernel shell_history enabled"
9+
10+
# nice completion
11+
autoload -Uz compinit
12+
compinit
13+
14+
# makes color constants available
15+
autoload -U colors
16+
colors
17+
export CLICOLOR=1
18+
19+
# Prompt Code
20+
# modify the prompt to contain git branch name if applicable
21+
git_prompt_info() {
22+
current_branch=$(git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/')
23+
if [[ -n $current_branch ]]; then
24+
echo "%{$fg_bold[yellow]%}$current_branch%{$reset_color%}"
25+
fi
26+
}
27+
28+
setopt promptsubst
29+
30+
# Allow exported PS1 variable to override default prompt.
31+
if ! env | grep -q '^PS1='; then
32+
PS1='${SSH_CONNECTION+"%{$fg_bold[green]%}%n@%m:"}%{$fg_bold[red]%}%c%{$reset_color%}$(git_prompt_info) # '
33+
fi
34+
35+
# awesome cd movements from zshkit
36+
setopt autocd autopushd pushdminus pushdsilent pushdtohome cdablevars
37+
DIRSTACKSIZE=5
38+
39+
# Enable extended globbing
40+
setopt extendedglob
41+
42+
# Allow [ or ] whereever you want
43+
unsetopt nomatch
44+
45+
# global envs
46+
export VISUAL=vim
47+
export EDITOR=$VISUAL
48+
49+
g() {
50+
if [[ $# -gt 0 ]]; then
51+
git "$@"
52+
else
53+
git status
54+
fi
55+
}
56+
compdef g=git
57+
58+
bindkey "^[[1;5C" forward-word
59+
bindkey "^[[1;5D" backward-word
60+
61+
export PATH="$HOME/bin:$PATH"
62+
63+
# nvm
64+
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
65+
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
66+
67+
# yarn
68+
export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH"
69+

0 commit comments

Comments
 (0)