Skip to content

Instantly share code, notes, and snippets.

@ltribolet
Created January 5, 2020 00:11
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 ltribolet/eeb2f651c879ebeab3fe2dde22b94ddc to your computer and use it in GitHub Desktop.
Save ltribolet/eeb2f651c879ebeab3fe2dde22b94ddc to your computer and use it in GitHub Desktop.
Dotfiles
# change the prefix from 'C-b' to 'C-a'
# (remap capslock to CTRL for easy access)
unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefix
bind a last-window
# start with window 1 (instead of 0)
set -g base-index 1
# start with pane 1
set -g pane-base-index 1
# split panes using | and -
bind | split-window -h
bind - split-window -v
unbind '"'
unbind %
# reload config file
bind r source-file ~/.tmux.conf
unbind p
bind p previous-window
# don't rename windows automatically
#set -g renumber-windows on
#set -g automatic-rename off
set-option -g allow-rename off
# mouse control (clickable windows, panes, resizable panes)
set -g mouse on
# Use Alt-arrow keys without prefix key to switch panes
bind -n C-Left select-pane -L
bind -n C-Right select-pane -R
bind -n C-Up select-pane -U
bind -n C-Down select-pane -D
bind-key -n S-Up set-option -g status
bind-key -n S-Down set-option -g status
bind-key -n S-Left previous-window
bind-key -n S-Right next-window
# Override the default command to use `reattach-to-user-namespace` for everything.
set -g default-command "reattach-to-user-namespace -l ${SHELL}"
bind-key -T copy-mode-vi 'y' send-keys -X copy-pipe-and-cancel 'reattach-to-user-namespace pbcopy'
# Size up history size
set -g history-limit 50000
set -g default-terminal "screen-256color"
set-window-option -g xterm-keys on
set -g escape-time 0
# focus events enabled for terminals that support them
set -g focus-events on
# super useful when using "grouped sessions" and multi-monitor setup
setw -g aggressive-resize on
set-option -g status-position bottom
set-option -g status-fg colour2
set-option -g status-bg default
set-option -g status-attr default
set-window-option -g window-status-fg colour8
set-window-option -g window-status-bg default
set-window-option -g window-status-attr default
set-window-option -g window-status-current-fg colour4
set-window-option -g window-status-current-bg default
set-window-option -g window-status-current-attr default
set-option -g message-fg white
set-option -g message-bg black
set-option -g message-attr bright
set -g status-left ""
set -g status-justify left
setw -g window-status-format ' #W '
setw -g window-status-current-format ' #W '
set -g status-right " "
# pane
setw -g pane-border-status off
setw -g pane-border-format ""
setw -g pane-border-bg default
setw -g pane-border-fg colour0
set -g pane-active-border-style fg=colour4,bg=default
#set-option -g status-position bottom
#set-option -g status-fg white
#set-option -g status-bg default
#set-option -g status-attr default
#set-window-option -g window-status-fg "#666666"
#set-window-option -g window-status-bg default
#set-window-option -g window-status-attr default
#set-window-option -g window-status-current-fg red
#set-window-option -g window-status-current-bg default
#set-window-option -g window-status-current-attr default
#set-option -g message-fg white
#set-option -g message-bg black
#set-option -g message-attr bright
#set -g status-left " "
#set -g status-justify left
#setw -g window-status-format ' #W '
#setw -g window-status-current-format ' #W '
#set -g status-right " "
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-resurrect'
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.tmux/plugins/tpm/tpm'
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
# Path to your oh-my-zsh installation.
export ZSH="/home/luc/.oh-my-zsh"
# Set name of the theme to load. Optionally, if you set this to "random"
# it'll load a random theme each time that oh-my-zsh is loaded.
# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes
ZSH_THEME="spaceship"
# Set list of themes to load
# Setting this variable when ZSH_THEME=random
# cause zsh load theme from this variable instead of
# looking in ~/.oh-my-zsh/themes/
# An empty array have no effect
# ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" )
# Uncomment the following line to use case-sensitive completion.
# CASE_SENSITIVE="true"
# Uncomment the following line to use hyphen-insensitive completion. Case
# sensitive completion must be off. _ and - will be interchangeable.
# HYPHEN_INSENSITIVE="true"
# Uncomment the following line to disable bi-weekly auto-update checks.
# DISABLE_AUTO_UPDATE="true"
# Uncomment the following line to change how often to auto-update (in days).
# export UPDATE_ZSH_DAYS=13
# Uncomment the following line to disable colors in ls.
# DISABLE_LS_COLORS="true"
# Uncomment the following line to disable auto-setting terminal title.
# DISABLE_AUTO_TITLE="true"
# Uncomment the following line to enable command auto-correction.
# ENABLE_CORRECTION="true"
# Uncomment the following line to display red dots whilst waiting for completion.
# COMPLETION_WAITING_DOTS="true"
# Uncomment the following line if you want to disable marking untracked files
# under VCS as dirty. This makes repository status check for large repositories
# much, much faster.
# DISABLE_UNTRACKED_FILES_DIRTY="true"
# Uncomment the following line if you want to change the command execution time
# stamp shown in the history command output.
# The optional three formats: "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"
# HIST_STAMPS="mm/dd/yyyy"
# Would you like to use another custom folder than $ZSH/custom?
# ZSH_CUSTOM=/path/to/new-custom-folder
# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*)
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
plugins=(
git
zsh-syntax-highlighting
sudo
urltools
encode64
docker
tmux
colorize
)
source $ZSH/oh-my-zsh.sh
# User configuration
# export MANPATH="/usr/local/man:$MANPATH"
# You may need to manually set your language environment
# export LANG=en_US.UTF-8
# Preferred editor for local and remote sessions
# if [[ -n $SSH_CONNECTION ]]; then
# export EDITOR='vim'
# else
# export EDITOR='mvim'
# fi
# Compilation flags
# export ARCHFLAGS="-arch x86_64"
# ssh
# export SSH_KEY_PATH="~/.ssh/rsa_id"
# Set personal aliases, overriding those provided by oh-my-zsh libs,
# plugins, and themes. Aliases can be placed here, though oh-my-zsh
# users are encouraged to define aliases within the ZSH_CUSTOM folder.
# For a full list of active aliases, run `alias`.
#
# Example aliases
# alias zshconfig="mate ~/.zshrc"
# alias ohmyzsh="mate ~/.oh-my-zsh"
#source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
source ~/.zsh/zsh-autosuggestions/zsh-autosuggestions.zsh
# Set Spaceship ZSH as a prompt
# autoload -U promptinit; promptinit
# prompt spaceship
# ORDER
SPACESHIP_PROMPT_ORDER=(
time
user
host
dir
git
exec_time
line_sep
vi_mode
jobs
exit_code
char
)
SPACESHIP_CHAR_SYMBOL="\uf054 "
SPACESHIP_USER_SHOW="true"
ZSH_TMUX_AUTOSTART=true
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
# fd - cd to selected directory
fd() {
local dir
dir=$(find ${1:-.} -path '*/\.*' -prune \
-o -type d -print 2> /dev/null | fzf +m) &&
cd "$dir"
}
# fh - search in your command history and execute selected command
fh() {
eval $( ([ -n "$ZSH_NAME" ] && fc -l 1 || history) | fzf +s --tac | sed 's/ *[0-9]* *//')
}
# Fuzzy-find and checkout a branch
fco() {
local branches branch
branches=$(git branch) &&
branch=$(echo "$branches" | fzf +m) &&
git checkout $(echo "$branch" | awk '{print $1}' | sed "s/.* //") &&
gl
}
fbr() {
gfa
local branches branch
branches=$(git branch --all | grep -v HEAD) &&
branch=$(echo "$branches" |
fzf-tmux -d $(( 2 + $(wc -l <<< "$branches") )) +m) &&
git checkout $(echo "$branch" | sed "s/.* //" | sed "s#remotes/[^/]*/##")
gl
}
gitstat() {
gfa > /dev/null
local branches branch1 branch2 branchSha1 branchSha2 diffs
branches=$(git branch --all | grep -v HEAD) &&
branch1=$(echo "$branches" |
fzf-tmux -d $(( 2 + $(wc -l <<< "$branches") )) +m) &&
branch2=$(echo "$branches" |
fzf-tmux -d $(( 2 + $(wc -l <<< "$branches") )) +m) &&
cleanBranch1=$(echo "$branch1" | sed "s/.* //") &&
cleanBranch2=$(echo "$branch2" | sed "s/.* //") &&
branchSha1=$(git rev-parse $cleanBranch1) &&
branchSha2=$(git rev-parse $cleanBranch2) &&
diffs=$(git diff --shortstat "$branchSha1"..."$branchSha2") &&
echo "$cleanBranch1 <-> $cleanBranch2" &&
echo "$diffs"
}
tailf-with-colors () {
if [ -z "$1" ] ; then
echo "Please specify a file for monitoring"
return
fi
tail -f $1 | awk '
{matched=0}
/INFO:/ {matched=1; print "\033[0;37m" $0 "\033[0m"} # WHITE
/NOTICE:/ {matched=1; print "\033[0;36m" $0 "\033[0m"} # CYAN
/WARNING:/ {matched=1; print "\033[0;34m" $0 "\033[0m"} # BLUE
/ERROR:/ {matched=1; print "\033[0;31m" $0 "\033[0m"} # RED
/ALERT:/ {matched=1; print "\033[0;35m" $0 "\033[0m"} # PURPLE
matched==0 {print "\033[0;33m" $0 "\033[0m"} # YELLOW
'
}
export DOCKER_HOST=tcp://localhost:2375
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment