Skip to content

Commit

Permalink
add initial configs
Browse files Browse the repository at this point in the history
  • Loading branch information
CatalinManolescu committed Feb 28, 2019
1 parent df783f0 commit 249e901
Show file tree
Hide file tree
Showing 25 changed files with 1,145 additions and 0 deletions.
30 changes: 30 additions & 0 deletions .install.conf.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
- defaults:
link:
create: true
relink: true

- clean: ['~']

- link:
~/.bash:
~/.bash_profile:
~/.bashrc:
~/.dotfiles: ''
~/.gitconfig:
~/.gnupg/gpg.conf:
~/.shell:
~/.tmux.conf:
~/.vim:
~/.vimrc:
~/.zsh:
~/.zshrc:

- shell:
- git submodule sync --recursive
# the following have to run after linking ~/.gitconfig
- git update-submodules
- >
git cleanall -f
shell/plugins/
vim/bundle/
zsh/plugins/
4 changes: 4 additions & 0 deletions bash/plugins.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# dircolors
if [[ "$(tput colors)" == "256" ]]; then
eval "$(dircolors ~/.shell/plugins/dircolors-solarized/dircolors.256dark)"
fi
21 changes: 21 additions & 0 deletions bash/prompt.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
ATTRIBUTE_BOLD='\[\e[1m\]'
ATTRIBUTE_RESET='\[\e[0m\]'
COLOR_DEFAULT='\[\e[39m\]'
COLOR_RED='\[\e[31m\]'
COLOR_GREEN='\[\e[32m\]'
COLOR_YELLOW='\[\e[33m\]'
COLOR_BLUE='\[\e[34m\]'
COLOR_MAGENTA='\[\e[35m\]'
COLOR_CYAN='\[\e[36m\]'

machine_name() {
if [[ -f $HOME/.name ]]; then
cat $HOME/.name
else
hostname
fi
}

PROMPT_DIRTRIM=3
PS1="\n${COLOR_BLUE}#${COLOR_DEFAULT} ${COLOR_CYAN}\\u${COLOR_DEFAULT} ${COLOR_GREEN}at${COLOR_DEFAULT} ${COLOR_MAGENTA}\$(machine_name)${COLOR_DEFAULT} ${COLOR_GREEN}in${COLOR_DEFAULT} ${COLOR_YELLOW}\w${COLOR_DEFAULT}\n\$(if [ \$? -ne 0 ]; then echo \"${COLOR_RED}!${COLOR_DEFAULT} \"; fi)${COLOR_BLUE}>${COLOR_DEFAULT} "
PS2="${COLOR_BLUE}>${COLOR_DEFAULT} "
6 changes: 6 additions & 0 deletions bash/settings.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
HISTSIZE=1048576
HISTFILE="$HOME/.bash_history"
SAVEHIST=$HISTSIZE
shopt -s histappend # append to history file

export EDITOR=vim
1 change: 1 addition & 0 deletions bash_profile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
source ~/.bashrc
40 changes: 40 additions & 0 deletions bashrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Functions
source ~/.shell/functions.sh

# Allow local customizations in the ~/.shell_local_before file
if [ -f ~/.shell_local_before ]; then
source ~/.shell_local_before
fi

# Allow local customizations in the ~/.bashrc_local_before file
if [ -f ~/.bashrc_local_before ]; then
source ~/.bashrc_local_before
fi

# Settings
source ~/.bash/settings.bash

# Bootstrap
source ~/.shell/bootstrap.sh

# External settings
source ~/.shell/external.sh

# Aliases
source ~/.shell/aliases.sh

# Custom prompt
source ~/.bash/prompt.bash

# Plugins
source ~/.bash/plugins.bash

# Allow local customizations in the ~/.shell_local_after file
if [ -f ~/.shell_local_after ]; then
source ~/.shell_local_after
fi

# Allow local customizations in the ~/.bashrc_local_after file
if [ -f ~/.bashrc_local_after ]; then
source ~/.bashrc_local_after
fi
41 changes: 41 additions & 0 deletions bin/tmx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env bash

# tmux launcher

DEFAULT_SESSION_NAME="0"

# Works because bash automatically trims by assigning to variables and by
# passing arguments
trim() { echo $1; }

if [[ -z "$1" ]]; then
# use default session name
base_session="$DEFAULT_SESSION_NAME"
else
base_session="$1"
fi

# This actually works without the trim() on all systems except OSX
tmux_nb=$(trim `tmux ls 2>/dev/null | grep "^$base_session" | wc -l`)
if [[ "$tmux_nb" == "0" ]]; then
tmux new-session -s $base_session
else
# Make sure we are not already in a tmux session
if [[ -z "$TMUX" ]]; then
# Kill defunct sessions first
old_sessions=$(tmux ls 2>/dev/null | egrep "^[0-9]{14}.*[0-9]+\)$" | cut -f 1 -d:)
for old_session_id in $old_sessions; do
tmux kill-session -t $old_session_id
done

# Session is is date and time to prevent conflict
session_id=`date +%Y%m%d%H%M%S`
# Create a new session (without attaching it) and link to base session
# to share windows
tmux new-session -d -t $base_session -s $session_id
# Attach to the new session
tmux attach-session -t $session_id
# When we detach from it, kill the session
tmux kill-session -t $session_id
fi
fi
68 changes: 68 additions & 0 deletions gitconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
[alias]
st = status -sb
versions = tag -l --sort=version:refname
update-submodules = submodule update --init --recursive
upgrade-submodules = submodule update --init --remote
tar = ! "tar() { git archive --format tar --prefix=\"${PWD##*/}/\" HEAD -o ${1}; }; tar"
targz = ! "targz() { git archive --format tar.gz --prefix=\"${PWD##*/}/\" HEAD -o ${1}; }; targz"
zip = ! "zip() { git archive --format zip --prefix=\"${PWD##*/}/\" HEAD -o ${1}; }; zip"

[diff]
mnemonicPrefix = true
wordRegex = "[^[:space:]]|([[:alnum:]]|UTF_8_GUARD)+"
compactionHeuristic = true

[color]
ui = auto

[color "grep"]
match = cyan bold
selected = blue
context = normal
filename = magenta
linenumber = green
separator = yellow
function = blue

[pretty]
line = "%C(auto)%h%d %s %C(yellow)by %C(blue)%an %C(green)%ar"
compact = "%C(auto)%h %s %C(green)%ar%n %C(auto)%d%n"
detail = "%C(auto)%h %s%n %C(yellow)by %C(blue)%an %C(magenta)<%ae> [%G?] %C(green)%ar%n %C(auto)%d%n"

[merge]
defaultToUpstream = true
tool = vimdiff

[pull]
#ff = only

[mergetool]
keepBackup = false

[push]
default = upstream

[credential]
helper = cache --timeout=3600

[grep]
lineNumber = true

[advice]
detachedHead = false
waitingForEditor = false

[user]
useConfigOnly = true
name = Catalin Manolescu
email = [email protected]

[http]
cookieFile = ~/.gitcookies

[core]
excludesfile = ~/.gitignore_global

# Allow local customizations in the .gitconfig_local file
[include]
path = ~/.gitconfig_local
65 changes: 65 additions & 0 deletions gpg.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
##########
# BEHAVIOR
##########

# Disable inclusion of the version string in ASCII armored output.
no-emit-version

# Disable comment string in clear text signatures and ASCII armored messages.
no-comments

# Display long key IDs.
keyid-format 0xlong

# List all keys (or the specified ones) along with their fingerprints.
with-fingerprint

# Display the calculated validity of user IDs during key listings.
list-options show-uid-validity
verify-options show-uid-validity

# Try to use the GnuPG-Agent. With this option, GnuPG first tries to connect to
# the agent before it asks for a passphrase.
use-agent

###########
# KEYSERVER
###########

# This is the server that --recv-keys, --send-keys, and --search-keys will
# communicate with to receive keys from, send keys to, and search for keys on.
# The certificate from https://sks-keyservers.net/sks-keyservers.netCA.pem will
# need to be trusted by the system for this to work.
keyserver hkps://hkps.pool.sks-keyservers.net:443

# When using --refresh-keys, if the key in question has a preferred keyserver
# URL, then disable use of that preferred keyserver to refresh the key from.
keyserver-options no-honor-keyserver-url

# When searching for a key with --search-keys, include keys that are marked on
# the keyserver as revoked.
keyserver-options include-revoked

#######################
# ALGORITHM AND CIPHERS
#######################

# When verifying a signature made from a subkey, ensure that the cross
# certification "back signature" on the subkey is present and valid. This
# protects against a subtle attack against subkeys that can sign.
require-cross-certification

# List of personal digest preferences. When multiple digests are supported by
# all recipients, choose the strongest one.
personal-cipher-preferences AES256 AES192 AES CAST5

# List of personal digest preferences. When multiple ciphers are supported by
# all recipients, choose the strongest one.
personal-digest-preferences SHA512 SHA384 SHA256 SHA224

# Message digest algorithm used when signing a key.
cert-digest-algo SHA512

# This preference list is used for new keys and becomes the default for
# "setpref" in the edit menu.
default-preference-list SHA512 SHA384 SHA256 SHA224 AES256 AES192 AES CAST5 ZLIB BZIP2 ZIP Uncompressed
15 changes: 15 additions & 0 deletions install
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash

set -e

CONFIG=".install.conf.yaml"
DOTBOT_DIR=".dotbot"

DOTBOT_BIN="bin/dotbot"
BASEDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

cd "${BASEDIR}"
git -C "${DOTBOT_DIR}" submodule sync --quiet --recursive
git submodule update --init --recursive "${DOTBOT_DIR}"

"${BASEDIR}/${DOTBOT_DIR}/${DOTBOT_BIN}" -d "${BASEDIR}" -c "${CONFIG}" "${@}"
21 changes: 21 additions & 0 deletions license
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2019 Catalin Manolescu

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
4 changes: 4 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Dotfiles

Based on [https://github.com/anishathalye/dotfiles](https://github.com/anishathalye/dotfiles) and powered by [https://git.io/dotbot](https://git.io/dotbot) .

13 changes: 13 additions & 0 deletions shell/aliases.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Use colors in coreutils utilities output
alias ls='ls --color=auto'
alias grep='grep --color'

# ls aliases
alias ll='ls -lah'

# Aliases to protect against overwriting
alias cp='cp -i'
alias mv='mv -i'

# Mirror a website
alias mirrorsite='wget -m -k -K -E -e robots=off'
12 changes: 12 additions & 0 deletions shell/bootstrap.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
path_prepend "$HOME/.dotfiles/bin"
path_append "$HOME/bin"

if ! shopt -oq posix; then
if [ -f /usr/share/bash-completion/bash_completion ]; then
. /usr/share/bash-completion/bash_completion
elif [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
fi

bind 'set bell-style none'
4 changes: 4 additions & 0 deletions shell/dircolors.extra
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# unimportant files
.vo 00;38;5;240
.v.d 00;38;5;240
.glob 00;38;5;240
8 changes: 8 additions & 0 deletions shell/external.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# pip should only run if there is a virtualenv currently activated
export PIP_REQUIRE_VIRTUALENV=true

# Cache pip-installed packages to avoid re-downloading
export PIP_DOWNLOAD_CACHE=$HOME/.pip/cache

# Python startup file
export PYTHONSTARTUP=$HOME/.pythonrc
13 changes: 13 additions & 0 deletions shell/functions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
path_remove() {
PATH=$(echo -n $PATH | awk -v RS=: -v ORS=: '$0 != "'$1'"' |sed 's/:$//')
}

path_append() {
path_remove "$1"
PATH="${PATH:+"$PATH:"}$1"
}

path_prepend() {
path_remove "$1"
PATH="$1${PATH:+":$PATH"}"
}
Loading

0 comments on commit 249e901

Please sign in to comment.