Skip to content

Instantly share code, notes, and snippets.

@PierreMage
Last active June 2, 2020 17:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PierreMage/4e59528bc92d84f08555a4ac6644e51a to your computer and use it in GitHub Desktop.
Save PierreMage/4e59528bc92d84f08555a4ac6644e51a to your computer and use it in GitHub Desktop.
bare dotfiles
#!/bin/bash
#https://github.com/mathiasbynens/dotfiles/blob/master/.aliases
alias ..="cd .."
alias ...="cd ../.."
alias ....="cd ../../.."
alias .....="cd ../../../.."
alias ~="cd ~"
alias -- -="cd -"
case "$OSTYPE" in
darwin*)
alias dsstorecleaner="find . -name \"*.DS_Store\" -type f -delete"
# Hide/show all desktop icons (useful when presenting)
alias hidedesktop="defaults write com.apple.finder CreateDesktop -bool false && killall Finder"
alias showdesktop="defaults write com.apple.finder CreateDesktop -bool true && killall Finder"
;;
cygwin*)
alias open="cygstart"
alias pbcopy="cat >/dev/clipboard"
alias pbpaste="cat /dev/clipboard"
;;
linux*) echo "LINUX" ;;
win*) echo "Windows" ;;
bsd*) echo "BSD" ;;
solaris*) echo "SOLARIS" ;;
*) echo "unknown: $OSTYPE" ;;
esac
alias l="ls -F"
alias la="ls -FA"
alias ll="ls -FAl"
alias lsd="ls -l | grep \"^d\""
alias h="history"
alias o="open"
alias oo="open ."
alias vi="vim"
pbsort () {
pbpaste | sort "$@" | pbcopy
}
pbcsv () {
pbpaste | paste -sd ${@:-,} | pbcopy
}
# Git
alias g="git"
__git_complete g __git_main
alias br="git branch"
__git_complete br _git_branch
alias co="git checkout"
__git_complete co _git_checkout
alias st="git status --short --branch"
__git_complete stash _git_stash
alias fetch="git fetch --all"
alias gl="git log --graph --pretty=\"format:%C(yellow)%h%Cgreen%d%Creset %s %C(white) %an, %ar%Creset\""
alias glh="gl -n 10"
alias init="git init && git commit --allow-empty -m \"root\""
alias prune="git remote prune origin; git gc --prune=now"
alias pull="git pull --ff"
alias stash="git stash"
alias pop="git stash pop"
# Kafka
[ -f ~/.kafka_aliases ] && . ~/.kafka_aliases
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
# don't put duplicate lines in the history. See bash(1) for more options
# ... or force ignoredups and ignorespace
HISTCONTROL=ignoredups:ignorespace
# append to the history file, don't overwrite it
shopt -s histappend
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTFILESIZE=400000000
HISTSIZE=10000
# http://mywiki.wooledge.org/BashFAQ/088
# write to history after each command
PROMPT_COMMAND="history -a"
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
# make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
debian_chroot=$(cat /etc/debian_chroot)
fi
# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
screen*|xterm-*color)
color_prompt=yes
;;
esac
#https://github.com/gf3/dotfiles/blob/master/.bash_prompt
if [ "$color_prompt" = yes ]; then
tput sgr0
GOLD=$(tput setaf 3)
WHITE=$(tput setaf 7)
ORANGE=$(tput setaf 172)
GREEN=$(tput setaf 190)
BOLD=$(tput bold)
RESET=$(tput sgr0)
PS1="${debian_chroot:+($debian_chroot)}\[$BOLD$GOLD\]\u \[$WHITE\]at \[$ORANGE\]\h \[$WHITE\]in \[$GREEN\]\w\[$WHITE\]\n\$ \[$RESET\]"
#PS1="${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ "
else
PS1="${debian_chroot:+($debian_chroot)}\u@\h:\w\$ "
fi
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
;;
*)
;;
esac
unset color_prompt debian_chroot
# Path definitions.
[ -f ~/.path ] && . ~/.path
# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.
[ -f ~/.aliases ] &&. ~/.aliases
# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
. /etc/bash_completion
fi
# https://dzone.com/articles/lesser-known-git-commands
[alias]
br = branch
ci = commit
co = checkout
it = !git init && git commit --allow-empty -m "root"
st = status
[merge]
tool = opendiff
ff = false
[core]
autocrlf = input
excludesfile = ~/.gitignore_global
#[url "https://"]
# insteadOf = git://
#[credential]
# helper = osxkeychain
[diff]
compactionHeuristic = true
*~
.DS_Store
.local
# Gradle
.gradle
out
# IntelliJ IDEA
.idea
*.iml
$include /etc/inputrc
# https://github.com/mathiasbynens/dotfiles/blob/master/.inputrc
# Make Tab autocomplete regardless of filename case
set completion-ignore-case on
# List all matches in case multiple possible completions are possible
set show-all-if-ambiguous on
# Immediately add a trailing slash when autocompleting symlinks to directories
set mark-symlinked-directories on
# Use the text that has already been typed as the prefix for searching through
# commands (i.e. more intelligent Up/Down behavior)
"\e[B": history-search-forward
"\e[A": history-search-backward
# Do not autocomplete hidden files unless the pattern explicitly begins with a dot
set match-hidden-files off
# Show all autocomplete results at once
set page-completions off
# If there are more than 200 possible completions for a word, ask to show them all
set completion-query-items 200
# Show extra file information when completing, like `ls -F` does
set visible-stats on
# Be more intelligent when autocompleting by also looking at the text after
# the cursor. For example, when the current line is "cd ~/src/mozil", and
# the cursor is on the "z", pressing Tab will not autocomplete it to "cd
# ~/src/mozillail", but to "cd ~/src/mozilla". (This is supported by the
# Readline used by Bash 4.)
set skip-completed-text on
# Allow UTF-8 input and output, instead of showing stuff like $'\0123\0456'
set input-meta on
set output-meta on
set convert-meta off
# Use Alt/Meta + Delete to delete the preceding word
"\e[3;3~": kill-word
#!/bin/bash
bootstrapservers () {
echo ${KAFKA_BOOTSTRAP_SERVERS:-127.0.0.1:9092}
}
zkpath () {
echo ${ZK_PATH:-127.0.0.1:2181}
}
brokers () {
[[ "$@" == "-h" ]] && echo "Usage: brokers [<id>]" && return
if [ $# -lt 1 ]; then
zkCli ls /brokers/ids
else
id="$1"
zkCli get /brokers/ids/${id}
fi
}
consume () {
if [ $# -lt 1 ] || [[ "$@" == "-h" ]]; then
echo "Usage: consume <topic> [<args>]" && return
fi
topic="$1"
shift
kafka-console-consumer --bootstrap-server $(bootstrapservers) --topic ${topic} "$@"
}
consumergroups () {
[[ "$@" == "-h" ]] && echo "Usage: consumergroups [<group>] [<args>]" && return
if [ $# -lt 1 ]; then
kafka-consumer-groups --bootstrap-server $(bootstrapservers) --list
else
group="$1"
shift
kafka-consumer-groups --bootstrap-server $(bootstrapservers) --group ${group} "$@"
fi
}
offsets () {
if [ $# -lt 1 ] || [[ "$@" == "-h" ]]; then
echo "Usage: offsets <topic> [<args>]" && return
fi
topic="$1"
shift
kafka-run-class kafka.tools.GetOffsetShell --broker-list $(bootstrapservers) --topic ${topic} "$@"
}
produce () {
if [ $# -lt 1 ] || [[ "$@" == "-h" ]]; then
echo "Usage: produce <topic> [<args>]" && return
fi
topic="$1"
shift
kafka-console-producer --broker-list $(bootstrapservers) --topic ${topic} "$@"
}
topics () {
[[ "$@" == "-h" ]] && echo "Usage: topics [<topic>] [<args>]" && return
if [ $# -lt 1 ]; then
kafka-topics --zookeeper $(zkpath) --list
else
topic="$1"
shift
kafka-topics --zookeeper $(zkpath) --topic ${topic} "$@"
fi
}
zk4 () {
if [ $# -lt 1 ] || [[ "$@" == "-h" ]]; then
echo "Usage: zk4 <four-letter-word> [<host>] [<port>]" && return
fi
flw="$1"
host="${2:-127.0.0.1}"
port="${3:-2181}"
exec 7<>/dev/tcp/${host}/${port}
echo ${flw} >&7
cat <&7
exec 7>&-
}
colorscheme desert
" Attempt to determine the type of a file based on its name and possibly its
" contents. Use this to allow intelligent auto-indenting for each filetype,
" and for plugins that are filetype specific.
filetype indent plugin on
" Enable syntax highlighting
syntax on
" One of the most important options to activate. Allows you to switch from an
" unsaved buffer without saving it first. Also allows you to keep an undo
" history for multiple files. Vim will complain if you try to quit without
" saving, and swap files will keep you safe if your computer crashes.
set hidden
" Better command-line completion
set wildmenu
" Show partial commands in the last line of the screen
set showcmd
" Highlight searches (use <C-L> to temporarily turn off highlighting; see the
" mapping of <C-L> below)
set hlsearch
" Use case insensitive search, except when using capital letters
set ignorecase
set smartcase
" Allow backspacing over autoindent, line breaks and start of insert action
set backspace=indent,eol,start
" When opening a new line and no filetype-specific indenting is enabled, keep
" the same indent as the line you're currently on. Useful for READMEs, etc.
set autoindent
" Stop certain movements from always going to the first character of a line.
" While this behaviour deviates from that of Vi, it does what most users
" coming from other editors would expect.
set nostartofline
" Display the cursor position on the last line of the screen or in the status
" line of a window
set ruler
" Always display the status line, even if only one window is displayed
set laststatus=2
" Instead of failing a command because of unsaved changes, instead raise a
" dialogue asking if you wish to save changed files.
set confirm
" Enable use of the mouse for all modes
set mouse=a
" Set the command window height to 2 lines, to avoid many cases of having to
" "press <Enter> to continue"
set cmdheight=2
" Display line numbers on the left
set number
" Use <F11> to toggle between 'paste' and 'nopaste'
set pastetoggle=<F11>
" Indentation settings for using 2 spaces instead of tabs.
" Do not change 'tabstop' from its default value of 8 with this setup.
set shiftwidth=2
set softtabstop=2
set expandtab
" Map Y to act like D and C, i.e. to yank until EOL, rather than act as yy,
" which is the default
map Y y$
" Map <C-L> (redraw screen) to also turn off search highlighting until the
" next search
nnoremap <C-L> :nohl<CR><C-L>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment