Skip to content

Commit

Permalink
Commit bunch of changes
Browse files Browse the repository at this point in the history
- Noticable thing: update iterm/vim/tmux based on dark/light macos ui
mode
  • Loading branch information
A committed Nov 26, 2019
1 parent e0cdd41 commit 7d9e4ed
Show file tree
Hide file tree
Showing 10 changed files with 124 additions and 68 deletions.
2 changes: 1 addition & 1 deletion .exports
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export VISUAL=vi
export EDITOR="$VISUAL"
# export GITHUB_ACCESS_TOKEN=`cat ~/.config/.gh-token`
export GITHUB_ACCESS_TOKEN=`cat ~/.config/.gh-token`

# Setup locales #
# If you'll got locale related error by `perl -e exit`, you should generate
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
._*
.gtd
.gitconfig
.npmrc
.byobu/.ssh-agent
lib
# .tmuxinator/.*.yml
14 changes: 9 additions & 5 deletions .nvimrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,13 @@ exec "so" dotfiles . '/nvim/settings.vim'
exec "so" dotfiles . '/nvim/plugins.vim'
exec "so" dotfiles . '/nvim/utils.vim'

" Update colorscheme based on dark/light interface style
let g:colorschemeDark = 'nord'
let g:colorschemeLight = 'nofrils-light'

call SetBackgroundMode()
call timer_start(3000, "SetBackgroundMode", {"repeat": -1})

colorscheme 1989

let mapleader = " "

Expand All @@ -31,8 +36,10 @@ noremap <leader>ce <Plug>(ale_next_wrap)
" JS/TS:
noremap <leader>jt :TSType<CR>
noremap <leader>jd :TSGetDiagnostics<CR>
noremap <leader>jd :ALEGoToDefinition<CR>
noremap <leader>jr :ALEFindReferences<CR>
noremap <leader>jc :ImportCost<CR>
noremap <leader>jr :ALEFindReferences<CR>
" noremap <leader>jt :TestNearest<CR>
" noremap <leader>jT :TestVisit<CR>

Expand Down Expand Up @@ -71,6 +78,3 @@ noremap <C-k> <C-W>k
noremap <C-h> <C-W>h
noremap <C-l> <C-W>l
" automatically clean trailing whitespaces on save
autocmd bufwritepre *.* :call Striptrailingwhitespaces()

67 changes: 44 additions & 23 deletions .tmux.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@ bind R source-file ~/.tmux.conf
# Ctrl-a as prefix instead of Ctrl-b
set -g prefix C-a
unbind C-b
bind C-a send-prefix

# zsh
# set -g default-command /bin/zsh
# set -g default-shell /bin/zsh

# https://github.com/jimeh/dotfiles/commit/3838db8
# Linux-safe fix for Mac OS pbcopy, pbpaste, and launchctl
set-option -g default-command "safe-reattach-to-user-namespace -l $SHELL"
# set-option -g default-command "safe-reattach-to-user-namespace -l $SHELL"


# set -g default-shell $SHELL
# set -g default-command "reattach-to-user-namespace -l ${SHELL}"

# have `C-a C-a` send C-a keypress to the current window
bind C-a send-prefix

# smart pane switching with awareness of vim splits
bind -n S-Up run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-k) || tmux select-pane -U"
Expand All @@ -43,11 +43,6 @@ bind c new-window -c '#{pane_current_path}'
# enable for iTerm (Terminal.app doesn't have mouse support)
# set -g mouse-resize-pane on
set -g mouse on
set -g history-limit 10000

# Faster escape sequences (default is 500ms).
# This helps when exiting insert mode in Vim: http://superuser.com/a/252717/65504
set -s escape-time 50

# start numbering windows from 1 instead of zero
set -g base-index 1
Expand All @@ -58,39 +53,65 @@ set-window-option -g pane-base-index 1
# switch to a tmuxinator project
bind T command-prompt -p session: "run-shell 'tmuxinator %1'"

# syntax highlighting in Vim
set -g default-terminal "screen-256color"

# disable programs changing window names via terminal escape sequence
set-window-option -g allow-rename off

# Panes
set -g main-pane-height 56

# status bar
# set -g status-utf8 on
set -g status-fg cyan
set -g status-bg white
set -g main-pane-height 60

# current session
set -g status-left ' #S#[fg=black]@#H'
set -g status-fg magenta
set -g status-bg black
set -g status-left ' ﮙ #[fg=magenta]#H'
set -g status-left-length 30
set -g status-right-length 100

# window list
set -g window-status-format " #[fg=black] #I.#W"
set -g window-status-current-format " #[fg=black,bg=cyan] #I.#W "
set -g window-status-current-format " #[fg=black,bg=magenta] #I.#W "
set -g window-status-separator ""

# battery and pomo status <http://git.io/zMf0IA>
set -g status-right ' #(battery) '
set -g status-interval 15
set -g status-right "\
CS:#{continuum_status} |\
#{online_status} |\
 #{cpu_percentage}% |\
 #(top -l1 | awk '/PhysMem/ {print $2}') |\
 #(df / | tail -n1 | awk '{print $5}') |\
#{battery_icon} #{battery_percentage} |\
#(date '+%H:%M') \
"
set -g status-interval 10


# List of plugins
set -g @plugin 'tmux-plugins/tpm'

set -g @plugin 'tmux-plugins/tmux-sensible'

set -g @plugin 'arcticicestudio/nord-tmux'
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @plugin 'tmux-plugins/tmux-continuum'
set -g @continuum-boot 'on'
set -g @continuum-boot-options 'iterm,fullscreen'
set -g @continuum-restore 'on'

set -g @plugin 'tmux-plugins/tmux-battery'
set -g @batt_icon_charge_tier8 ''
set -g @batt_icon_charge_tier7 ''
set -g @batt_icon_charge_tier6 ''
set -g @batt_icon_charge_tier5 ''
set -g @batt_icon_charge_tier4 ''
set -g @batt_icon_charge_tier3 ''
set -g @batt_icon_charge_tier2 ''
set -g @batt_icon_charge_tier1 ''
set -g @batt_icon_status_charged ' '
set -g @batt_icon_status_charging ''
set -g @batt_icon_status_discharging ' '

set -g @plugin 'tmux-plugins/tmux-online-status'
set -g @online_icon ""
set -g @offline_icon ""

set -g @plugin 'tmux-plugins/tmux-cpu'


# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.tmux/plugins/tpm/tpm'
6 changes: 6 additions & 0 deletions .zsh_background_tasks
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

if [[ ! $(pgrep -f $DOTFILES/bin/iterm-theme) ]]; then
nohup $DOTFILES/bin/iterm-theme > /dev/null 2>&1 &
fi


14 changes: 1 addition & 13 deletions .zshrc
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,12 @@ source $DOTFILES/.exports
source $ZSH/oh-my-zsh.sh
source $DOTFILES/.aliases
source $DOTFILES/lib/emo/prompt.zsh


preexec_functions=()
function expand_aliases {
input_command=$1
expanded_command=$2
if [ $input_command != $expanded_command ]; then
print -nP $PROMPT
echo $expanded_command
fi
}
source $DOTFILES/.zsh_background_tasks

if type brew &>/dev/null; then
FPATH=$(brew --prefix)/share/zsh/site-functions:$FPATH
fi

preexec_functions+=expand_aliases


type rbenv > /dev/null && eval "$(rbenv init -)"
type mux > /dev/null && test -z $TMUX && mux dotfiles
Expand Down
27 changes: 16 additions & 11 deletions bin/battery
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,21 @@ else
current_charge=$(echo $battery_info | grep -o '"CurrentCapacity" = [0-9]\+' | awk '{print $3}')
total_charge=$(echo $battery_info | grep -o '"MaxCapacity" = [0-9]\+' | awk '{print $3}')
fi
echo $current_charge
echo $total_charge

charged_slots=$(echo "(($current_charge/$total_charge)*10)+1" | bc -l | cut -d '.' -f 1)
if [[ $charged_slots -gt 10 ]]; then
charged_slots=10
fi

echo -n '#[fg=red]'
for i in `seq 1 $charged_slots`; do echo -n "$HEART"; done
charged_perc=$(echo "(($current_charge/$total_charge)*100)" | bc -l | cut -d '.' -f 1)
echo "$charged_perc%";

if [[ $charged_slots -lt 10 ]]; then
echo -n '#[fg=blue]'
for i in `seq 1 $(echo "10-$charged_slots" | bc)`; do echo -n "$HEART"; done
fi
# charged_slots=$(echo "(($current_charge/$total_charge)*10)+1" | bc -l | cut -d '.' -f 1)
# if [[ $charged_slots -gt 10 ]]; then
# charged_slots=10
# fi
#
# echo -n '#[fg=red]'
# for i in `seq 1 $charged_slots`; do echo -n "$HEART"; done
#
# if [[ $charged_slots -lt 10 ]]; then
# echo -n '#[fg=blue]'
# for i in `seq 1 $(echo "10-$charged_slots" | bc)`; do echo -n "$HEART"; done
# fi
26 changes: 26 additions & 0 deletions bin/iterm-theme
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env python3

import asyncio
import iterm2

async def main(connection):
async with iterm2.VariableMonitor(connection, iterm2.VariableScopes.APP, "effectiveTheme", None) as mon:
while True:
# Block until theme changes
theme = await mon.async_get()

# Themes have space-delimited attributes, one of which will be light or dark.
parts = theme.split(" ")
if "dark" in parts:
preset = await iterm2.ColorPreset.async_get(connection, "Nord (2)")
else:
preset = await iterm2.ColorPreset.async_get(connection, "OneHalfLight")

# Update the list of all profiles and iterate over them.
profiles=await iterm2.PartialProfile.async_query(connection)
for partial in profiles:
# Fetch the full profile and then set the color preset in it.
profile = await partial.async_get_full_profile()
await profile.async_set_color_preset(preset)

iterm2.run_forever(main)
17 changes: 9 additions & 8 deletions nvim/plugins.vim
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,13 @@ Plug 'editorconfig/editorconfig-vim'
" let g:syntastic_auto_loc_list = 1
" let g:syntastic_check_on_open = 1
" let g:syntastic_check_on_wq = 0
Plug 'A/vim-import-cost', { 'do': 'npm install' }
augroup import_cost_auto_run
autocmd!
autocmd InsertLeave *.js,*.jsx,*.ts,*.tsx ImportCost
autocmd BufEnter *.js,*.jsx,*.ts,*.tsx ImportCost
autocmd CursorHold *.js,*.jsx,*.ts,*.tsx ImportCost
augroup END
" Plug 'A/vim-import-cost', { 'do': 'npm install' }
" augroup import_cost_auto_run
" autocmd!
" autocmd InsertLeave *.js,*.jsx,*.ts,*.tsx ImportCost
" autocmd BufEnter *.js,*.jsx,*.ts,*.tsx ImportCost
" autocmd CursorHold *.js,*.jsx,*.ts,*.tsx ImportCost
" augroup END
Plug 'tyru/open-browser.vim'
Plug 'pocari/vim-denite-kind-open-browser'
Plug 'pocari/vim-denite-gists'
Expand All @@ -126,12 +126,13 @@ Plug 'alvan/vim-closetag'
\ }
Plug 'dense-analysis/ale'
let g:airline#extensions#ale#enabled = 1
let g:ale_open_list = 1
let g:ale_open_list = 0
let g:ale_list_window_size = 5
let g:ale_fixers = {
\ '*': ['remove_trailing_lines', 'trim_whitespace'],
\ 'javascript': ['eslint'],
\ 'typescript': ['tslint'],
\}
Plug 'csscomb/vim-csscomb', {'do': 'npm install -g csscomb'}

call plug#end()
18 changes: 11 additions & 7 deletions nvim/utils.vim
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@ autocmd BufReadPost *
\ exe "normal! g`\"" |
\ endif

" Strip whitespaces
fun! Striptrailingwhitespaces()
let l = line(".")
let c = col(".")
%s/\s\+$//e
call cursor(l, c)
endfun

" let g:colorschemeDark = '1989'
" let g:colorschemeLight = 'nofrils-light'
function! SetBackgroundMode(...)
" dark mode enabled?
if system("defaults read -g AppleInterfaceStyle") =~ '^Dark'
execute "colorscheme ". g:colorschemeDark
else
execute "colorscheme ". g:colorschemeLight
endif
endfunction

0 comments on commit 7d9e4ed

Please sign in to comment.