tmux – Notes

May 22, 2016 Leave a comment

I started using tmux. It is genuinely easier to use than screen. I have used screen for a while, but I never bothered to learn more commands. I would not consider myself a screen power user so maybe that is why I prefer using tmux.

Basic commands for tmux

1. Creating named sessions

$ tmux new-session -s <name_of_session>


$ tmux new -s <name_of_session>

2. To view sessions

$ tmux list-sessions


$ tmux ls

3. To attach to a session

$ tmux attach -t <name_of_session>

4. To detach from a session

$ Cntrl-b d

5. To kill/destroy a session

$ tmux kill-session -t <name_of_session>

6. Working with Windows

$ tmux new -s <name_of_session> -n <name_of_window>

$ Cntrl-b c # Create a new window.
$ Cntrl-b , # Rename window. It defaults to whatever is running on the window.
$ Cntrl-b n # Move to the next window.
$ Cntrl-b p # Move to the previous window.
$ Cntrl-b F # Find window if named, else they are numbered.
$ Cntrl-b w # Display visual menu of the windows.
$ Cntrl-b [0-9] # Can move to a particular window by typing the number eg Cntrl-b 1; Cntrl-b 2; etc.
$ Cnrtl-b x # Closes the current pane or window after prompting for confirmation.
$ Cntrl-b <space> # Cycles through the various panes layout.

My current tmux config

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

# UTF is great, let us use that
set -g utf8
set-window-option -g utf8 on

# Tmux should be pretty, we need 256 color for that
set -g default-terminal "screen-256color"

# Tmux uses a 'control key', let's set it to 'Ctrl-a'
# Reason: 'Ctrl-a' is easier to reach than 'Ctrl-b'
set -g prefix C-a
unbind C-b

# command delay? We don't want that, make it short
set -sg escape-time 1

# Set the numbering of windows to go from 1 instead
# of 0 - silly programmers😐
set-option -g base-index 1
setw -g pane-base-index 1

# Allow us to reload our Tmux configuration while
# using Tmux
bind r source-file ~/.tmux.conf \; display "Reloaded!"

# Getting interesting now, we use the vertical and horizontal
# symbols to split the screen
bind | split-window -h
bind - split-window -v

# hjkl pane traversal
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R

tmux: Productive Mouse-Free Development 1st Editionby Brian P. Hogan (Author)

Categories: bash Tags:

Ansible – Interactive scripts

May 20, 2016 Leave a comment

Working with interactive scripts in Ansible 2. I need to change the shell from bash to zsh. Using the command chsh -s /usr/bin/zsh will prompt the user for their password. I am running this command on a vagrant box.

Use expect.

This is what I added to my existing ansible script.

– name: “Install python pip”
become_user: root
apt: name=python-pip state=present

# expect needs pexpect to work.
– pip: name=pexpect version=3.3
become_user: root

– expect:
command: chsh -s /usr/bin/zsh
Password: vagrant


Categories: ansible Tags: ,

cURL to access Https server

May 19, 2016 Leave a comment

You need to access a https server using curl.

Use –cert and –key options in curl. As per the man.

-E, –cert
(SSL) Tells curl to use the specified client certificate file when getting a file
with HTTPS, FTPS or another SSL-based protocol. The certificate must be in
PKCS#12 format if using Secure Transport, or PEM format if using any other
engine. If the optional password isn’t specified, it will be queried for on the
terminal. Note that this option assumes a “certificate” file that is the private
key and the private certificate concatenated! See –cert and –key to specify
them independently.
(SSL/SSH) Private key file name. Allows you to provide your private key in this
separate file.

If this option is used several times, the last one will be used.
-k, –insecure
(SSL) This option explicitly allows curl to perform “insecure” SSL connections
and transfers. All SSL connections are attempted to be made secure by using the
CA certificate bundle installed by default. This makes all connections considered
“insecure” fail unless -k, –insecure is used.

See this online resource for further details:


# This attempt fails.
$ curl
<head><title>400 No required SSL certificate was sent</title></head>
<body bgcolor="white">
<center><h1>400 Bad Request</h1></center>
<center>No required SSL certificate was sent</center>
<hr><center>nginx/1.4.6 (Ubuntu)</center>
# This attempt to bypass fails.
$ curl --insecure
<head><title>400 No required SSL certificate was sent</title></head>
<body bgcolor="white">
<center><h1>400 Bad Request</h1></center>
<center>No required SSL certificate was sent</center>
<hr><center>nginx/1.4.6 (Ubuntu)</center>
# This works.
$ curl --cert /path/to/certifcate/client.crt --key /path/to/key/client.key
    <title>Server Example</title>

<frameset rows="60,*" frameborder="1" border="1">
  <frame src="/browser/header/" name="Header" id='header' scrolling="no" noresize="true" />

    <frame src="/composer/?" name="content" id="composerFrame"/>

Categories: bash Tags: , ,

podcast – Talk Python to me

May 18, 2016 Leave a comment
Categories: Interesting, python Tags:

Impatient R — thoughts…

May 18, 2016 Leave a comment

This is a tutorial (previously known as “Some hints for the R beginner”) for beginning to learn the R programming language. It is a tree of pages — move through the pages in whatever way best suits your style of learning. You are probably impatient to learn R — most people are. That’s fine. But […]

via Impatient R — thoughts…

Categories: Interesting, uncategorized

How to create a self signed ssl certificate for nginx

May 17, 2016 Leave a comment
Categories: Interesting Tags:

67th Aniversary of the Nakba

May 17, 2016 Leave a comment
Categories: Interesting Tags:

Get every new post delivered to your Inbox.

Join 44 other followers