PREFIX ? - list keys
PREFIX d - leave
# Come Back
$ tmux a
PREFIX c - create window
PREFIX , - rename window
PREFIX n - next window
PREFIX p - previous window
PREFIX {num} - go to {num} window
PREFIX & - exit window
PREFIX % - split pane in vertically
PREFIX “ - split pane in horizontally
PREFIX o - switch between panes
PREFIX {arrow} - move around the panes
PREFIX q - show pane number and its size
PREFIX x - kill pane
PREFIX z - toggle pane to be fullscreen
PREFIX {, } - swap panes
PREFIX ! - turn pane to window
Copying between tmux buffers and the system clipboard
Share buffer with system clipboard
tmux Copy & Paste on OS X: A Better Future
Copy Mode - Linux TMUX Video Tutorial
# .tmux.conf
setw -g mode-keys vi
bind-key -t vi-copy 'v' begin-selection
bind-key -t vi-copy 'y' copy-selection
bind -t vi-copy y copy-pipe 'xclip -in -selection clipboard'
Copy to Buffer
PREFIX [
- scroll buffer use arrow key to move around and enter to quitPaste from buffer PREFIX ]
#Window: python dev (Prefix - Meta(Alt) + d)
# -v = split horizontal
bind-key M-d split-window -v -p 30 -t 0 \; \
send-keys './watchdog_python.py' 'Enter' \; \
select-pane -t 0
$ gem install tmuxinator
export EDITOR=vim
# OSX via Homebrew
$ brew install wemux
brew update
brew install reattach-to-user-namespace
echo "set -g default-command \"reattach-to-user-namespace -l ${SHELL}\"" >> ~/.tmux.conf
Prefix + space
Flattened list of list
>>> l = [[1,5,6], [4,5,9,7] ,[] ,[] ,[9]]
[[1, 5, 6], [4, 5, 9, 7], [], [], [9]]
>>> sum(l, [])
[1, 5, 6, 4, 5, 9, 7, 9]
>>> [i for x in l for i in x if type(x) is list]
[1, 5, 6, 4, 5, 9, 7, 9]
Else with for loop
>> for i, v in enumerate(range(10)):
>> print i,
>> else:
>> print 10
1 2 3 4 5 6 7 8 9 10
Zen of Python :: run this command in python console
import this
Virtualenv with system package
virtualenv --system-site-packages <env_name>
Virtualenv with python3
virtualenv --python=$(which python3) <env_name>
Virtualenv can’t move. You must edit environment path in
<your_env>/bin/activate
<your_env>/bin/activate.csh
<your_env>/bin/activate.finsh
Install py package into python2
pip install <package>
Install py package into python3
pip3 install <package>
Pip upgrade
pip install <package> --upgrade
or you can use pip-tool to review all pip-package to upgrade
pip install pip-tools
pip-review
pip-dump
Install Project as develop via pip
# same as 'python setup.py develope'
pip install --use-mirrors --editable .
Print without newline or spaces
import sys
for i in xrange(0,10):
sys.stdout.write(".")
sys.stdout.flush()
>>> execfile('filename.py')
import X
reload( X )
$ pip install --download-cache="/pth/to/downloaded/files" package
function line {
PYTHON_ARG="$1" python - <<END
import os
line_len = int(os.environ['PYTHON_ARG'])
print '-' * line_len
END
}
Calling a python function from bash script
python -c'import themodule; themodule.thefunction("boo!")'
How to print to stderr in Python?
print >> sys.stderr, 'word'
Virtualenv Python Power Tools: virtualenv
pip install virtualenv
Or
brew install pyenv-virtualenv
VirtualenvWrapper - Python Power Tools: virtualenvwrapper
pip install virtualenvwrapper
add this into your .bashrc/.zshrc
export WORKON_HOME=<env_path>
source /usr/local/bin/virtualenvwrapper.sh
brew install autoenv
echo 'source /usr/local/opt/autoenv/activate.sh' >> ~/.zshrc
# install
$ pip install --upgrade autopep8
# usage
$ autopep8 --in-place --aggressive --aggressive <filename>
# install
$ pip install pylint
$ apt-get install graphviz
# usage
pyreverse -o png <code>