Last active
April 16, 2019 08:29
-
-
Save ebal5/8a287126f732506fc9c30590412167a1 to your computer and use it in GitHub Desktop.
Shell settings
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[user] | |
name = Shuichi Tani | |
email = [email protected] | |
[alias] | |
s = status | |
ss = status -s | |
l = log | |
c = commit | |
ca = commit --amend | |
pu = push | |
pl = pull | |
co = checkout | |
graph = log --graph --date=short --decorate=short --pretty=format:'%Cgreen%h %Creset%cd %Cblue%cn %Cred%d %Creset%s' | |
gr = log --graph --date=short --decorate=short --pretty=format:'%Cgreen%h %Creset%cd %Cblue%cn %Cred%d %Creset%s' | |
unstage = reset HEAD | |
cp = cherry-pick | |
ss = stash save | |
sp = stash pop | |
cof = !"git branch | fzf | xargs git checkout" | |
cor = !"git branch | sed -e 's|origin/||' | xargs git checkout" | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$latex = 'xelatex -synctex=1 -halt-on-error'; | |
$latex_silent = 'xelatex -synctex=1 -halt-on-error -interaction=batchmode'; | |
$pdflatex = 'xelatex -synctex=1 -halt-on-error'; | |
$bibtex = 'bibtex'; | |
$biber = 'biber --bblencoding=utf8 -u -U --output_safechars'; | |
$dvipdf = 'dvipdfmx %O -o %D %S'; | |
$makeindex = 'mendex %O -o %D %S'; | |
$max_repeat = 5; | |
$pdf_mode = 1; | |
$pvc_view_file_via_temporary = 0; | |
$pdf_previewer = "evince" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# set prefix to C-z | |
set -g prefix C-z | |
unbind C-b | |
bind C-z send-prefix | |
# 0 is too far from ` ;) | |
set -g base-index 1 | |
# Automatically set window title | |
set-window-option -g automatic-rename on | |
set-option -g set-titles on | |
#set -g default-terminal screen-256color | |
set -g status-keys vi | |
set -g history-limit 10000 | |
setw -g mode-keys vi | |
setw -g monitor-activity on | |
bind-key v split-window -h | |
bind-key s split-window -v | |
bind-key J resize-pane -D 5 | |
bind-key K resize-pane -U 5 | |
bind-key H resize-pane -L 5 | |
bind-key L resize-pane -R 5 | |
bind-key M-j resize-pane -D | |
bind-key M-k resize-pane -U | |
bind-key M-h resize-pane -L | |
bind-key M-l resize-pane -R | |
# Vim style pane selection | |
bind h select-pane -L | |
bind j select-pane -D | |
bind k select-pane -U | |
bind l select-pane -R | |
# Use Alt-vim keys without prefix key to switch panes | |
bind -n M-h select-pane -L | |
bind -n M-j select-pane -D | |
bind -n M-k select-pane -U | |
bind -n M-l select-pane -R | |
# Use Alt-arrow keys without prefix key to switch panes | |
bind -n M-Left select-pane -L | |
bind -n M-Right select-pane -R | |
bind -n M-Up select-pane -U | |
bind -n M-Down select-pane -D | |
# Shift arrow to switch windows | |
bind -n S-Left previous-window | |
bind -n S-Right next-window | |
# No delay for escape key press | |
set -sg escape-time 0 | |
# Reload tmux config | |
bind r source-file ~/.tmux.conf \; display "Reloaded!" | |
# THEME | |
set -g status-bg black | |
set -g status-fg white | |
set -g window-status-current-bg white | |
set -g window-status-current-fg black | |
set -g window-status-current-attr bold | |
set -g status-interval 60 | |
set -g status-left-length 30 | |
set -g status-left '#[fg=green](#S) #(whoami)' | |
set -g status-right '#[fg=yellow]#(cut -d " " -f 1-3 /proc/loadavg)#[default] #[fg=white]%H:%M#[default]'# List of plugins | |
set -g @plugin 'tmux-plugins/tpm' | |
set -g @plugin 'tmux-plugins/tmux-sensible' | |
set -g @plugin 'tmux-plugins/tmux-copycat' | |
set -g @plugin 'nhdaly/tmux-better-mouse-mode' | |
set-option -g mouse on | |
set -g @plugin 'tmux-plugins/tmux-yank' | |
# run-shell "powerline-daemon -q" | |
# source "/usr/lib/python3.6/site-packages/powerline/bindings/tmux/powerline.conf" | |
# set -g @plugin 'jimeh/tmux-themepack' | |
# set -g @themepack 'powerline/block/blue' | |
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf) | |
run '~/.tmux/plugins/tpm/tpm' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dirfile=$(mktemp -p /tmp tmuxdir.XXXXX) | |
fzf -h 2> /dev/null | |
if [ $? -eq 0 ]; then | |
if [[ ! -n $TMUX ]] ; then | |
choices="New session with name\nNew session\nPlain" | |
sessions=$(tmux ls -F "#{session_name}" 2> /dev/null | sort -r) | |
if [ ! -z $sessions ]; then | |
choices="$choices\n$sessions" | |
fi | |
choise=$(echo $choices | fzf) | |
case $choise in | |
"Plain") | |
;; | |
"New session") | |
tmux new | |
;; | |
"New session with name") | |
printf "Name: " | |
read name | |
tmux new -t $name | |
;; | |
?*) | |
tmux a -t $choise | |
;; | |
*) | |
;; | |
esac | |
fi | |
function __chpwd_savepath() { | |
$(pwd > $dirfile) | |
} | |
function __exit_rmpath() { | |
rm $dirfile | |
} | |
preexec() { | |
local line=${1%%$'\n'} | |
local cmd=${line%% *} | |
if [ ${line} = 'exec ${SHELL}' -o $line = 'exec $SHELL' ] ; then | |
if [ -f $dirfile ]; then | |
rm $dirfile | |
fi | |
fi | |
} | |
autoload -Uz add-zsh-hook | |
add-zsh-hook chpwd __chpwd_savepath | |
function cdt() { | |
if [ $# -eq 1 ] ; then | |
cd $1 | |
return | |
elif [ ! $# -eq 0 ] ; then | |
>&2 echo "too many arguments" | |
return 1 | |
fi | |
dlist=$(cat /tmp/tmuxdir* | sort | uniq | grep -vEw "^$(pwd)$") | |
d=$(echo $dlist | fzf) | |
cd $d | |
} | |
function cdf() { | |
choise=$(cdr -l | sed -e "s/^..* *//" | sort | uniq | fzf) | |
hs=$(echo $choise | grep -oE "~[a-zA-Z]+" | tr -d "~") | |
for h in ${hs}; do | |
rep=$(hash -d | grep -E "^${h}=" | cut -d "=" -f 2) | |
choise=${choise/"~${h}"/${rep}} | |
done | |
choise=$(echo $choise | sed -e "s!^~/!${HOME}/!") | |
cd $choise | |
} | |
fi | |
bindkey -e # Use emacs-like key bind | |
# zplug settings | |
if [ -f ~/.zplug/init.zsh ]; then | |
source ~/.zplug/init.zsh | |
zplug "zsh-users/zsh-autosuggestions" | |
zplug 'zsh-users/zaw' | |
zplug 'zsh-users/zsh-syntax-highlighting', defer:2 | |
zplug "zsh-users/zsh-completions" | |
fi | |
if ! zplug check --verbose; then | |
printf 'Install? [y/N]: ' | |
if read -q; then | |
echo; zplug install | |
fi | |
fi | |
autoload -Uz chpwd_recent_dirs cdr add-zsh-hook is-at-least | |
if is-at-least 4.3.10; then | |
add-zsh-hook chpwd chpwd_recent_dirs | |
zstyle ':chpwd:*' recent-dirs-max 5000 | |
zstyle ':chpwd:*' recent-dirs-default yes | |
fi | |
zplug load | |
# global aliases | |
setopt extended_glob | |
typeset -A abbreviations | |
abbreviations=( | |
"@g" '| grep' | |
"@gc" '| grep --color=always' | |
"@l" '| less' | |
"@x" '| xargs' | |
"@s" '| sed -e' | |
"@u" '| sort | uniq' | |
"@t" '| tail' | |
"@h" '| head' | |
"@w" '| wc' | |
"@wl" '| wc -l' | |
"@a" '| awk' | |
"@j" '| jq' | |
"@jc" '| jq -C' | |
"@r" '| rg' | |
"@rc" '| rg --color=always' | |
"@cp" '| xsel -b' | |
"@c" '| cut' | |
) | |
magic-abbrev-expand() { | |
local MATCH | |
LBUFFER=${LBUFFER%%(#m)[-.@_a-zA-Z0-9]#} | |
LBUFFER+=${abbreviations[$MATCH]:-$MATCH} | |
echo $LBUFFER >> /tmp/shell | |
zle self-insert | |
} | |
no-magic-abbrev-expand() { | |
LBUFFER+=' ' | |
} | |
zle -N magic-abbrev-expand | |
zle -N no-magic-abbrev-expand | |
bindkey " " magic-abbrev-expand | |
bindkey "^x " no-magic-abbrev-expand | |
alias -g ...="../.." | |
alias -g ....="../../.." | |
# suffix aliases | |
alias -s txt="cat" | |
alias -s rb="ruby" | |
alias -s py="python" | |
function runcpp() { | |
clang -O2 $1 | |
shift | |
./a.out $@ | |
} | |
alias -s {c,cpp}="runcpp" | |
function runjava() { | |
ccl=$1 | |
ccln=${ccl%.java} | |
javac $ccl | |
shift | |
java $ccln $@ | |
} | |
alias -s java="runjava" | |
# Hisotry settings | |
autoload history-search-end | |
bindkey "^N" history-beginning-search-forward-end | |
bindkey "^P" history-beginning-search-backward-end | |
export HISTFILE="${HOME}/.zsh_history" | |
export HISTSIZE=10000 | |
export SAVEHIST=100000 | |
setopt EXTENDED_HISTORY | |
setopt appendhistory | |
setopt hist_ignore_all_dups | |
setopt hist_ignore_space | |
setopt hist_reduce_blanks | |
setopt incappendhistory | |
setopt sharehistory | |
zle -N history-beginning-search-backward-end history-search-end | |
zle -N history-beginning-search-forward-end history-search-end | |
zshaddhistory () { | |
local line=${1%%$'\n'} | |
local cmd=${line%% *} | |
[[ ${#line} -ge 5 \ | |
&& ${cmd} != (c|cd) \ | |
&& ${cmd} != (m|man) \ | |
&& ${cmd} != (l|l[lsah]) | |
]] | |
} | |
setopt inc_append_history | |
# completion | |
autoload -U compinit; compinit | |
setopt correct | |
setopt auto_cd | |
setopt auto_pushd | |
setopt pushd_ignore_dups # ignore if dups | |
setopt auto_list | |
zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS} | |
zstyle ':completion:*:default' menu select=1 | |
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}' | |
zstyle ':completion:*' keep-prefix | |
zstyle ':completion:*' recent-dirs-insert both | |
## 補完候補をキャッシュする。 | |
zstyle ':completion:*' use-cache yes | |
zstyle ':completion:*' cache-path ~/.zsh/cache | |
## 詳細な情報を使わない | |
zstyle ':completion:*' verbose no | |
WORDCHARS='*?_-.[]~=&;!#$%^(){}<>' | |
zstyle ':completion:*:sudo:*' command-path /usr/local/sbin /usr/local/bin \ | |
/usr/sbin /usr/bin /sbin /bin /usr/X11R6/bin | |
zstyle ':completion:*:processes' command 'ps x -o pid,s,args' | |
[[ -f /usr/share/fzf/key-bindings.zsh ]] && source /usr/share/fzf/key-bindings.zsh | |
[[ -f /usr/share/fzf/completion.zsh ]] && source /usr/share/fzf/completion.zsh | |
# Prompt settings | |
autoload -Uz colors; colors | |
autoload -Uz vcs_info | |
zstyle ':vcs_info:*' enable git svn hg | |
setopt prompt_subst | |
zstyle ':vcs_info:*' check-for-changes true | |
zstyle ':vcs_info:git:*' stagedstr "%F{yellow}!" | |
zstyle ':vcs_info:git:*' unstagedstr "%F{red}+" | |
zstyle ':vcs_info:*' formats "%F{green}%c%u[%b]%f" | |
zstyle ':vcs_info:*' actionformats '[%b|%a]' | |
setopt PROMPT_SUBST # allow funky stuff in prompt | |
color="080" | |
hcolor="033" | |
if [ ! -z $SSH_CLIENT -o ! -z $SSH_CONNECTION ]; then | |
color="220" | |
hcolor="222" | |
fi | |
if [ "$USER" = "root" ]; then | |
color="124" # root is red, user is blue | |
fi | |
PROMPT="%F{$color}%n%f@%F{$hcolor}%m%f: %F{014}$pd%f | |
%F{040}>%f " | |
echo -ne "\033]0;${USER}@${HOST} (*'v'*)\007" | |
precmd() { | |
vcs_info | |
local pd | |
pd=$(pwd | sed -e "s|${HOME}|~|" -e "s|\([^~/]\)[^/]*/|\1/|g") | |
PROMPT="%F{014}%n%f@%F{$hcolor}%m%f: %F{014}$pd%f | |
%{%(?.%F{040}.%F{124})%}%(?.(*'v'*%) >.(-_-##%) >)%f " | |
RPROMPT="${vcs_info_msg_0_}" | |
} | |
# zmv | |
autoload -Uz zmv | |
alias zmv='noglob zmv -w' | |
# zed | |
autoload -Uz zed | |
export SDKMAN_DIR="$HOME/.sdkman" | |
[[ -s "${HOME}/.sdkman/bin/sdkman-init.sh" ]] && source "${HOME}/.sdkman/bin/sdkman-init.sh" | |
# load user settings | |
[[ -f ~/.config/shellrc ]] && . ~/.config/shellrc | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
zrcpos="$HOME/.zshrc" | |
trcpos="$HOME/.tmux.conf" | |
srcpos="$HOME/.config/shellrc" | |
pystpos="$HOME/.config/pythonstartup.py" | |
gitpos="$HOME/.gitconfig" | |
[[ -f $zrcpos ]] && mv $zrcpos ${zrcpos}.orig | |
[[ -f $trcpos ]] && mv $trcpos ${trcpos}.orig | |
[[ -f $srcpos ]] && mv $srcpos ${srcpos}.orig | |
[[ -f $pystpos ]] && mv $pystpos ${pystpos}.orig | |
[[ -f $gitpos ]] && mv $gitpos ${gitpos}.orig | |
dir=$(cd $(dirname $0); pwd) | |
ln -s $dir/.zshrc $zrcpos | |
ln -s $dir/.tmux.conf $trcpos | |
ln -s $dir/shellrc $srcpos | |
ln -s $dir/.latexmkrc $HOME/ | |
ln -s $dir/pythonstartup.py $pystpos | |
ln -s $dir/.gitconfig $gitpos |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Python startup file | |
import readline | |
import rlcompleter | |
import atexit | |
import os | |
# tab complete | |
readline.parse_and_bind('tab: complete') | |
# history file | |
histfile = os.path.join(os.environ['HOME'], '.python_history') | |
try: | |
readline.read_history_file(histfile) | |
except IOError: | |
pass | |
atexit.register(readline.write_history_file, histfile) | |
del os, histfile, readline, rlcompleter, atexit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding:utf-8 -*- | |
#+STARTUP: shell-script-mode | |
DIRNAME="$HOME/bin" | |
[[ -d $DIRNAME ]] && export PATH="${DIRNAME}:${PATH}" | |
alias ls="ls --color=auto" | |
alias grep="grep --color=auto" | |
alias ll="ls -l" | |
alias la="ls -la" | |
alias lh="ls -lh" | |
alias l="ls" | |
alias lc="ls --color=always" | |
alias c="cd" | |
alias m="man" | |
alias g="git" | |
alias e="echo" | |
alias md="mkdir" | |
alias less="less -F" | |
alias len="wc -l" | |
function speedmeter { | |
cat - |sed -e "s/^.*時間: \(.*:..\).*$/\1 /" -e "s/^.[^0-9]*\([0-9]*[km]bps\).$/\1 /" -e "s/^-*//" -e "/^$/d" | perl -pe "s/\n/ /" |perl -pe "s/$/\n/" | sed -e "s/ \+/ /g" | |
} | |
[[ -d "$HOME/.texmf" ]] && export TEXMFHOME="$HOME/.texmf" | |
[[ -d "$HOME/.rbenv/bin" ]] && export PATH="$HOME/.rbenv/bin:$PATH"; eval "$(rbenv init -)" | |
export LESS=-R | |
export LESS_TERMCAP_mb=$'\E[1;31m' # begin bold | |
export LESS_TERMCAP_md=$'\E[1;36m' # begin blink | |
export LESS_TERMCAP_me=$'\E[0m' # reset bold/blink | |
export LESS_TERMCAP_so=$'\E[01;44;33m' # begin reverse video | |
export LESS_TERMCAP_se=$'\E[0m' # reset reverse video | |
export LESS_TERMCAP_us=$'\E[1;32m' # begin underline | |
export LESS_TERMCAP_ue=$'\E[0m' # reset underline | |
# User functions... | |
if git --help > /dev/null; then | |
function ghome(){ | |
git rev-parse --show-toplevel | |
} | |
fi | |
function gdrive_dl(){ | |
# $1: url that want to download (only google drive) | |
# $2: file name that you want to save to | |
if [[ ! $@ -eq 2 ]]; then | |
echo "Usage: gdrive_dl drive_url save_file_name" | |
exit 1 | |
fi | |
if [[ ! $1 -regex-match ^https://drive.google.com/.+ ]]; then | |
echo "first arugment must be google drive's url" | |
exit 1 | |
fi | |
FID=$(echo $1 | sed -E 's/.*id=(.+)[&|$].*/\1/') | |
FN=$2 | |
cookie=$(mktemp /tmp/cookie.XXXXXX) | |
curl -sc $cookie "https://drive.google.com/uc?export=download&id=$FID" > /dev/null | |
CODE="$(awk '/_warning_/ {print $NF}' ${cookie})" | |
curl -Lb $cookie "https://drive.google.com/uc?export=download&confirm=${CODE}&id=$FID" -o $FN | |
} | |
function mcd(){ | |
mkdir $1 && cd $1 | |
} | |
# load local settings. | |
[[ -f "$HOME/.config/shellrc.local" ]] && source "$HOME/.config/shellrc.local" | |
virtualenvfile=/usr/local/bin/virtualenvwrapper.sh | |
[[ -f $virtuenvfile ]] && \ | |
source $virtualenvfile && \ | |
export WORKON_HOME=~/.virtualenvs | |
PYENV_ROOT=$HOME/.pyenv | |
[[ -d $PYENV_ROOT ]] && \ | |
PATH="$PYENV_ROOT/shims:$PATH"; \ | |
PATH="$PYENV_ROOT/bin:$PATH"; \ | |
eval "$(pyenv init -)" | |
alias pipmd="env PIPENV_VENV_IN_PROJECT=true pipenv install -d" | |
[[ -f "$HOME/.config/pythonstartup.py" ]] && export PYTHONSTARTUP="$HOME/.config/pythonstartup.py" | |
if pipenv --help > /dev/null; then | |
eval "$(pipenv --completion)" | |
fi | |
export XAPIAN_CJK_NGRAM=1 | |
if which xsv > /dev/null; then | |
function csvcp() { | |
cat $1 | xsv fmt -t "\t" | xsel -b | |
} | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment