Compare commits
6 Commits
305b8679c8
...
c9e8e938b6
Author | SHA1 | Date | |
---|---|---|---|
|
c9e8e938b6 | ||
|
33880507d3 | ||
|
2fb19b837d | ||
|
ca13db3e0e | ||
|
d7a97dd085 | ||
|
2f77657c7b |
69
dotlinker
69
dotlinker
@ -1,12 +1,6 @@
|
|||||||
#!/usr/bin/env ruby
|
#!/usr/bin/env ruby
|
||||||
|
|
||||||
#/ Usage: dotlinker <command>
|
require 'optparse'
|
||||||
#/
|
|
||||||
#/ list List files to link
|
|
||||||
#/ update Update dotfiles repo
|
|
||||||
#/ symlink Symlink all files
|
|
||||||
#/ unsymlink Unsymlink all files
|
|
||||||
|
|
||||||
require 'pathname'
|
require 'pathname'
|
||||||
require 'fileutils'
|
require 'fileutils'
|
||||||
|
|
||||||
@ -29,10 +23,6 @@ module ShellHelpers
|
|||||||
"\033[0;#{COLOR_CODES[color] + 30}m#{str}\033[0m"
|
"\033[0;#{COLOR_CODES[color] + 30}m#{str}\033[0m"
|
||||||
end
|
end
|
||||||
|
|
||||||
def say_help
|
|
||||||
exec "grep ^#/<'#{__FILE__}'|cut -c4-"
|
|
||||||
end
|
|
||||||
|
|
||||||
def say(message, color = :default)
|
def say(message, color = :default)
|
||||||
$stdout.print(colorify_string(message, color))
|
$stdout.print(colorify_string(message, color))
|
||||||
$stdout.flush
|
$stdout.flush
|
||||||
@ -135,7 +125,7 @@ module FileHelpers
|
|||||||
elsif destination.exist?
|
elsif destination.exist?
|
||||||
say_status(:conflict, "#{destination} exists", :red)
|
say_status(:conflict, "#{destination} exists", :red)
|
||||||
|
|
||||||
if collision_accepted?(destination)
|
if options[:force] || collision_accepted?(destination)
|
||||||
FileUtils.rm_r(destination, force: true)
|
FileUtils.rm_r(destination, force: true)
|
||||||
FileUtils.ln_s(source, destination, force: true)
|
FileUtils.ln_s(source, destination, force: true)
|
||||||
end
|
end
|
||||||
@ -147,25 +137,17 @@ module FileHelpers
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
module GitHelpers
|
|
||||||
extend self
|
|
||||||
|
|
||||||
def git_pull
|
|
||||||
say_status(:git, "Pulling #{`git config --get remote.origin.url`}", :green)
|
|
||||||
system 'git pull'
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
class Linker
|
class Linker
|
||||||
include GitHelpers
|
|
||||||
include FileHelpers
|
include FileHelpers
|
||||||
include ShellHelpers
|
include ShellHelpers
|
||||||
|
|
||||||
VERSION = '0.1.0'.freeze
|
VERSION = '0.2.1'.freeze
|
||||||
LINKDIR_FILENAME = '.linkdir'.freeze
|
LINKDIR_FILENAME = '.linkdir'.freeze
|
||||||
|
|
||||||
def git_dir
|
attr_reader :options
|
||||||
@git_dir ||= Pathname.new(File.dirname(__FILE__)).realpath
|
|
||||||
|
def initialize(options = {})
|
||||||
|
@options = options
|
||||||
end
|
end
|
||||||
|
|
||||||
def home_dir
|
def home_dir
|
||||||
@ -176,10 +158,6 @@ class Linker
|
|||||||
@repo_dir ||= Pathname.new(File.dirname(__FILE__)).join('home').realpath
|
@repo_dir ||= Pathname.new(File.dirname(__FILE__)).join('home').realpath
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
|
||||||
inside(git_dir) { git_pull }
|
|
||||||
end
|
|
||||||
|
|
||||||
def each_file
|
def each_file
|
||||||
skip_dirs = []
|
skip_dirs = []
|
||||||
|
|
||||||
@ -206,7 +184,7 @@ class Linker
|
|||||||
|
|
||||||
def symlink_all
|
def symlink_all
|
||||||
each_file do |absolute_path, home_path|
|
each_file do |absolute_path, home_path|
|
||||||
ln_s(absolute_path, home_path)
|
ln_s(absolute_path, home_path, options)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -217,24 +195,37 @@ class Linker
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
COMMANDS = ['list', 'update', 'symlink', 'unsymlink'].freeze
|
COMMANDS = ['list', 'update', 'link', 'unlink'].freeze
|
||||||
|
|
||||||
|
options = {}
|
||||||
|
opt_parser = OptionParser.new do |opts|
|
||||||
|
opts.banner = "Usage: #{__FILE__} <command> [options]"
|
||||||
|
|
||||||
|
opts.separator ''
|
||||||
|
opts.separator 'Commands:'
|
||||||
|
opts.separator 'list List files to link'
|
||||||
|
opts.separator 'link Symlink all files'
|
||||||
|
opts.separator 'unlink Unsymlink all files'
|
||||||
|
|
||||||
|
opts.separator ''
|
||||||
|
opts.separator 'Options:'
|
||||||
|
opts.on('-f', '--force', 'Force overwrite all files') { |force| options[:force] = force }
|
||||||
|
opts.on('-v', '--version', 'Show version information') { |_| ShellHelpers.say(Linker::VERSION); exit(0) }
|
||||||
|
end
|
||||||
|
|
||||||
|
opt_parser.parse!
|
||||||
command = ARGV.pop
|
command = ARGV.pop
|
||||||
if command.nil? || !COMMANDS.include?(command)
|
if command.nil? || !COMMANDS.include?(command)
|
||||||
ShellHelpers.say_help
|
ShellHelpers.say(opt_parser.help)
|
||||||
else
|
else
|
||||||
linker = Linker.new
|
linker = Linker.new(options)
|
||||||
|
|
||||||
case command
|
case command
|
||||||
when 'list'
|
when 'list'
|
||||||
linker.list_all
|
linker.list_all
|
||||||
when 'update'
|
when 'link'
|
||||||
linker.update
|
|
||||||
when 'symlink'
|
|
||||||
linker.symlink_all
|
linker.symlink_all
|
||||||
when 'unsymlink'
|
when 'unlink'
|
||||||
linker.unsymlink_all
|
linker.unsymlink_all
|
||||||
else
|
|
||||||
ShellHelpers.say_help
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -22,3 +22,8 @@
|
|||||||
prompt = false
|
prompt = false
|
||||||
[help]
|
[help]
|
||||||
autocorrect = 1
|
autocorrect = 1
|
||||||
|
[filter "lfs"]
|
||||||
|
process = git-lfs filter-process
|
||||||
|
required = true
|
||||||
|
clean = git-lfs clean -- %f
|
||||||
|
smudge = git-lfs smudge -- %f
|
||||||
|
265
home/.tmux.conf
265
home/.tmux.conf
@ -1,78 +1,223 @@
|
|||||||
# status bar
|
################################################################################
|
||||||
set -g status-right-length 20
|
#### Unbreak things
|
||||||
set -g status-right '#[fg=red]#H#[fg=green]:#[fg=white]#S #[fg=green]][#[default]'
|
|
||||||
set -g status-left ''
|
|
||||||
|
|
||||||
# default statusbar colors
|
# Prevent tmux from messing up keybindings and colors.
|
||||||
set -g status-fg white
|
# This is witchcraft, I have no explanation for the following commands.
|
||||||
set -g status-bg default
|
set-option -g xterm-keys on
|
||||||
set -g status-attr bright
|
set-window-option -g xterm-keys on
|
||||||
|
set-option -g default-terminal "xterm-256color"
|
||||||
|
|
||||||
# default window title colors
|
# Prevent tmux from waiting half a second before processing the ESC key, see:
|
||||||
set-window-option -g window-status-fg white
|
# http://unix.stackexchange.com/a/25638/176805
|
||||||
set-window-option -g window-status-bg default
|
set-option -s escape-time 0
|
||||||
set-window-option -g window-status-attr dim
|
|
||||||
|
|
||||||
# active window title colors
|
# Enable proper mouse support:
|
||||||
set-window-option -g window-status-current-fg white
|
# http://www.hamvocke.com/blog/a-guide-to-customizing-your-tmux-conf/
|
||||||
set-window-option -g window-status-current-bg default
|
set-option -g mouse on
|
||||||
set-window-option -g window-status-current-attr bright
|
bind-key m set-option -g mouse on
|
||||||
|
bind-key M set-option -g mouse off
|
||||||
|
|
||||||
# C-b is not acceptable -- Vim uses it
|
# The following line prevents a weird OS X problem that otherwise
|
||||||
# set-option -g prefix C-a
|
# keeps the "open" command from working (and has several other
|
||||||
# bind-key C-a last-window
|
# undesirable properties; see issue #120). For more details on the
|
||||||
|
# issue, see [1]-[5].
|
||||||
|
#
|
||||||
|
# The exact version of the solution below is the only way I have found
|
||||||
|
# to satisfy all of the following properties:
|
||||||
|
#
|
||||||
|
# * It fixes the problem, i.e. "open" works correctly.
|
||||||
|
#
|
||||||
|
# * When opening a new window in tmux, the window name is correctly
|
||||||
|
# set to zsh initially. It does not briefly flash
|
||||||
|
# "reattach-to-user-namespace", and it does not display
|
||||||
|
# "/usr/local/bin/zsh" either.
|
||||||
|
#
|
||||||
|
# * The "automatic-rename" property is still set to "on" in new tmux
|
||||||
|
# windows, meaning that if you run another program, the window name
|
||||||
|
# will change to reflect that (unless you manually rename the
|
||||||
|
# window).
|
||||||
|
#
|
||||||
|
# * Exiting the shell (e.g. with Control+D) will immediately kill the
|
||||||
|
# tmux window instead of dropping you into another shell.
|
||||||
|
#
|
||||||
|
# * It works for all shells, and doesn't hardcode any particular one.
|
||||||
|
#
|
||||||
|
# * It still works when reattach-to-user-namespace is unavailable.
|
||||||
|
#
|
||||||
|
# Yes, it's horrible. I think we can all agree on that, no need to
|
||||||
|
# point it out.
|
||||||
|
#
|
||||||
|
# Unfortunately, tmux appears to be remarkably unintelligent when it
|
||||||
|
# comes to determining the string to show as the window title.
|
||||||
|
# Basically, about as unintelligent as shebang parsing, and anyone
|
||||||
|
# involved in the virtualenv-can't-handle-spaces fiasco will know
|
||||||
|
# that's pretty darn unintelligent. In particular, it grabs characters
|
||||||
|
# literally from the beginning of the command string until it hits a
|
||||||
|
# space, then discards until the first slash, if there is one. This
|
||||||
|
# means it's impossible to quote the executable name, so if your shell
|
||||||
|
# has spaces in its name, you're screwed. Making this whole fiasco
|
||||||
|
# work for paths with double quotes in it is an exercise in futility,
|
||||||
|
# I think.
|
||||||
|
#
|
||||||
|
# [1]: http://superuser.com/q/834525/326239
|
||||||
|
# [2]: http://www.economyofeffort.com/2013/07/29/reattach-to-user-namespace-the-fix-for-your-tmux-in-os-x-woes/
|
||||||
|
# [3]: https://www.elmund.io/osx/2015/07/10/open-command-in-osx-tmux/
|
||||||
|
# [4]: https://github.com/ChrisJohnsen/tmux-MacOSX-pasteboard
|
||||||
|
# [5]: https://github.com/ChrisJohnsen/tmux-MacOSX-pasteboard/issues/10
|
||||||
|
|
||||||
# Start numbering at 1
|
run-shell 'command -v reattach-to-user-namespace > /dev/null && tmux set-option -g default-command "$SHELL -c \"reattach-to-user-namespace -l \\\"$(basename "$SHELL")\\\"\"" || true'
|
||||||
set -g base-index 1
|
|
||||||
|
|
||||||
# Allows for faster key repetition
|
################################################################################
|
||||||
set -s escape-time 0
|
#### Keybindings
|
||||||
|
|
||||||
# Rather than constraining window size to the maximum size of any client
|
# Use ` instead of C-b as prefix key, see:
|
||||||
# connected to the *session*, constrain window size to the maximum size of any
|
# http://www.hamvocke.com/blog/a-guide-to-customizing-your-tmux-conf/
|
||||||
# client connected to *that window*. Much more reasonable.
|
unbind-key C-b
|
||||||
setw -g aggressive-resize on
|
set-option -g prefix `
|
||||||
|
bind-key ` send-prefix
|
||||||
|
|
||||||
# Allows us to use C-a a <command> to send commands to a TMUX session inside
|
# Force tmux to use Emacs keybindings, see:
|
||||||
# another TMUX session
|
# http://stackoverflow.com/q/18240683/3538165
|
||||||
bind-key a send-prefix
|
# http://stackoverflow.com/a/18247437/3538165
|
||||||
|
set-option -g status-keys emacs
|
||||||
|
set-window-option -g mode-keys emacs
|
||||||
|
|
||||||
# Activity monitoring
|
# Turn off repeatability for moving between panes. Otherwise, if you split
|
||||||
setw -g monitor-activity on
|
# horizontally and switch panes, you will have to wait for the 'repeat period'
|
||||||
set -g visual-activity on
|
# to expire before you can use <Up> and <Down> to page through shell history.
|
||||||
|
#
|
||||||
|
# Doing it this way instead of using 'set-option -g repeat-time 0' makes it
|
||||||
|
# so that Control+Arrows and Meta+Arrows (for resizing panes) are still
|
||||||
|
# repeatable.
|
||||||
|
#
|
||||||
|
# See: http://superuser.com/a/325579/326239
|
||||||
|
bind-key Up select-pane -U
|
||||||
|
bind-key Down select-pane -D
|
||||||
|
bind-key Left select-pane -L
|
||||||
|
bind-key Right select-pane -R
|
||||||
|
|
||||||
# Highlight active window
|
# Keybinding for reloading .tmux.conf.
|
||||||
set-window-option -g window-status-current-bg red
|
bind-key R source-file ~/.tmux.conf
|
||||||
|
|
||||||
# VI keybindings please
|
# Keybinding for swapping the current and marked windows.
|
||||||
setw -g mode-keys vi
|
bind-key \ swap-window
|
||||||
|
|
||||||
# VI for splitting
|
# Keybindings for swapping adjacent windows.
|
||||||
bind s split-window -v
|
bind-key < swap-window -t -1
|
||||||
bind v split-window -h
|
bind-key > swap-window -t +1
|
||||||
|
|
||||||
# Vi copypaste mode
|
# Keybinding for inserting a window.
|
||||||
set-window-option -g mode-keys vi
|
# Adapted from http://superuser.com/a/704551/326239
|
||||||
bind-key -T copy-mode-vi 'v' begin-selection
|
bind-key I command-prompt -p 'Insert window at:' ' \
|
||||||
bind-key -T copy-mode-vi 'y' copy-selection
|
run-shell " \
|
||||||
|
if tmux select-window -t %1; then \
|
||||||
|
tmux new-window -a; \
|
||||||
|
tmux swap-window -s %1 -t \$((%1+1)); \
|
||||||
|
else \
|
||||||
|
tmux new-window; \
|
||||||
|
tmux move-window -t %1; \
|
||||||
|
fi; \
|
||||||
|
tmux select-window -t #{window_id}; \
|
||||||
|
tmux select-window -t %1; \
|
||||||
|
"'
|
||||||
|
|
||||||
# hjkl pane traversal
|
################################################################################
|
||||||
bind h select-pane -L
|
#### Status bar
|
||||||
bind j select-pane -D
|
|
||||||
bind k select-pane -U
|
|
||||||
bind l select-pane -R
|
|
||||||
|
|
||||||
# reload config
|
# The following code is adapted from:
|
||||||
bind r source-file ~/.tmux.conf \; display-message "Config reloaded..."
|
# https://coderwall.com/p/trgyrq/make-your-tmux-status-bar-responsive
|
||||||
|
# It provides the same appearance as https://github.com/powerline/powerline,
|
||||||
|
# but sidesteps the environment/configuration hell which that project
|
||||||
|
# introduces.
|
||||||
|
|
||||||
# auto window rename
|
# Format to display on the left-hand side of the status bar.
|
||||||
set-window-option -g automatic-rename
|
# Note that the conditional #{?cond,true,false} operator does not do any
|
||||||
|
# fancy parsing, so you can't have literal commas in the conditions --
|
||||||
|
# this will cause the conditions to be split up. So we have to use multiple
|
||||||
|
# style #[attr=value] directives.
|
||||||
|
set-option -g status-left '#{?client_prefix,#[fg=colour254]#[bg=colour31],#[fg=colour16]#[bg=colour254]#[bold]} #{=80:session_name} #{?client_prefix,#[fg=colour31],#[fg=colour254]}#[bg=colour234,nobold] '
|
||||||
|
|
||||||
# color
|
# Maximum length of the format displayed on the left-hand side.
|
||||||
set -g default-terminal "screen-256color"
|
# Since the maximum length of the session name is limited in the above
|
||||||
|
# format string, this number is unimportant -- it just needs to be a
|
||||||
|
# bit larger than what is allocated for the session name, to allow for
|
||||||
|
# the surrounding characters.
|
||||||
|
set-option -g status-left-length 90
|
||||||
|
|
||||||
# Pane resizing
|
# Format to display on the right-hand side of the status bar.
|
||||||
bind-key J resize-pane -D 10
|
set-option -g status-right '#{?mouse,#[fg=colour254]#[bg=colour31],#[fg=colour244,bg=colour234]} Mouse #[fg=colour254,bg=colour234] #H'
|
||||||
bind-key K resize-pane -U 10
|
|
||||||
bind-key H resize-pane -L 10
|
# Format to display for the current window.
|
||||||
bind-key L resize-pane -R 10
|
set-option -g window-status-current-format '#[fg=colour117,bg=colour31] #{window_index}#{window_flags} #[fg=colour231,bold]#(tmux display-message -p "#{pane_current_path}" | sed "s#$HOME#~#g") #{?#{m:*#{b:SHELL}*, #{pane_current_command}},| #{pane_current_command} }#[fg=colour31,bg=colour234,nobold]'
|
||||||
|
|
||||||
|
# Format to display for other windows.
|
||||||
|
set-option -g window-status-format '#[fg=colour244,bg=colour234]#{window_index}#{window_flags} #[fg=colour249]#(tmux display-message -p "#{pane_current_path}" | sed "s#$HOME#~#g") #{?#{m:*#{b:SHELL}*, #{pane_current_command}},| #{pane_current_command} }'
|
||||||
|
|
||||||
|
# Background color for parts of the status bar not specified by the above
|
||||||
|
# formats. For instance, the empty space to the right, and the single
|
||||||
|
# spaces between instances of window-status-format.
|
||||||
|
set-option -g status-bg colour234
|
||||||
|
|
||||||
|
# Inhibit the default styling for windows with unseen activity, which
|
||||||
|
# looks blatantly incorrect with the "powerline" theme we are trying to
|
||||||
|
# emulate.
|
||||||
|
set-window-option -g window-status-activity-attr none
|
||||||
|
|
||||||
|
# Update the status bar every second, instead of the default 15(!)
|
||||||
|
# seconds. It doesn't look like it's possible to update more than
|
||||||
|
# once per second, unfortunately.
|
||||||
|
set-option -g status-interval 1
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
#### Appearance
|
||||||
|
|
||||||
|
# Attempt to set the title of the terminal emulator.
|
||||||
|
set-option -g set-titles on
|
||||||
|
set-option -g set-titles-string '#{session_name} - #{window_name}'
|
||||||
|
|
||||||
|
# Show an indicator in the status bar on windows with unseen activity.
|
||||||
|
set-option -g monitor-activity on
|
||||||
|
|
||||||
|
# Make the borders of the current pane the same color as the borders
|
||||||
|
# of other panes. This is because the borders of the marked pane are
|
||||||
|
# *inverted*, and while different foreground colors in different parts
|
||||||
|
# of the frame are not too objectionable, different background colors
|
||||||
|
# look very bad.
|
||||||
|
set-option -g pane-active-border-style none
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
#### Miscellaneous
|
||||||
|
|
||||||
|
# When the current session is killed, switch to another session instead of
|
||||||
|
# detaching.
|
||||||
|
set-option -g detach-on-destroy off
|
||||||
|
|
||||||
|
# Show messages until they are dismissed, instead of for 750 milliseconds(!).
|
||||||
|
# Actually it is only for an hour, because it doesn't seem like you can turn
|
||||||
|
# off the time limit.
|
||||||
|
set-option -g display-time 36000000
|
||||||
|
|
||||||
|
# Open new windows in the same directory as the current pane.
|
||||||
|
bind-key c new-window -c "#{pane_current_path}"
|
||||||
|
|
||||||
|
# Automatically renumber windows when one is deleted, see:
|
||||||
|
# http://unix.stackexchange.com/a/51879/176805
|
||||||
|
set-option -g renumber-windows on
|
||||||
|
|
||||||
|
# Number windows and panes from 1, instead of 0; see:
|
||||||
|
# http://unix.stackexchange.com/a/35932/176805
|
||||||
|
set-option -g base-index 1
|
||||||
|
set-window-option -g pane-base-index 1
|
||||||
|
|
||||||
|
# Open new panes in the same directory as the current pane.
|
||||||
|
bind-key % split-window -h -c "#{pane_current_path}"
|
||||||
|
bind-key '"' split-window -v -c "#{pane_current_path}"
|
||||||
|
|
||||||
|
# Increase the scrollback buffer size from 2000 to a larger size, but
|
||||||
|
# not one so large that tmux begins to lag.
|
||||||
|
set-option -g history-limit 10000
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
#### Local overrides
|
||||||
|
|
||||||
|
if-shell "[[ -f ~/.tmux.local.conf ]]" "source ~/.tmux.local.conf"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
ZSH=$HOME/.oh-my-zsh
|
ZSH=$HOME/.oh-my-zsh
|
||||||
ZSH_THEME="cheetah"
|
ZSH_THEME="cheetah"
|
||||||
|
|
||||||
plugins=(osx brew git github redis-cli ruby rbenv gem bundler sublime pass zsh-syntax-highlighting)
|
plugins=(osx brew git github redis-cli ruby rbenv gem bundler sublime pass docker zsh-syntax-highlighting)
|
||||||
|
|
||||||
source $ZSH/oh-my-zsh.sh
|
source $ZSH/oh-my-zsh.sh
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user