Shower Presentation Engine

Yours Truly, Famous Inc.

Console Into Mass__

Vitalii Rybka

Favourite browser

Favourite browser

Console for user

Console for user

devtools terminal

devtools terminal

The escape plan

  1. Console manager
  2. Bash-scripting
  3. Routine tasks automation

Repository

Slides

Compatible OS

Console managers

  1. screen
  2. tmux
  3. screen vs tmux

Console managers. Screen

Installation:
			sudo apt-get install screen
			screen
		

Console managers. Screen

Basic key combinations:

Console managers. Screen

An example of configuration (.screenrc):
			# Default is ‘on’, as you probably noticed.
			startup_message off
			# Window list at the bottom.
			hardstatus alwayslastline
			hardstatus string "%-w%{= BW}%50>%n %t%{-}%+w%<"
		
What are the strange characters in this line hardstatus string "%-w%{= BW}%50>%n %t%{-}%+w%<" can be read here.

Console managers. Screen

screen example

Console managers. Tmux

Installation:
			sudo apt-get install tmux
			tmux
		

Console managers. Tmux.

Basic key combinations:

Console managers. Tmux

tmux example

Console managers. screen vs tmux

screen
- Cannot create independent layouts for each tab
- Cannot save layouts in case of a connection’s drop
- Before 4.1 version couldn’t support vertical separation
- Whenever you create a new region, you also need to create a new window (Ctrl+a, c), then shift to the needed directory, etc
- To delete a region, you’d need to press one more key combination Ctrl+a, :remove

Console managers. screen vs tmux

tmux
+ Boasts quality default settings out-of-the-box
+ No need to customize the arrangement and backlight of the control pane
+ Supports both vertical and horizontal splits
+ In order to close the pane, you only need to enter exit
+ Can hold a remote connection by SSH*
* requires some additional magic
keep calm and bin bash

bash

  1. Basics
  2. Conditions
  3. Loops

bash. Basics

  1. Variables
  2. Passing arguments to the script
  3. Processing arguments within the script

bash. Basics. "Hello, world!"

			#!/bin/bash
			echo "Hello, world!"
		
./hw.sh # how it calls

bash. Basics. Variables

Variables: Create (rewrite) variable:
path="~/Docs"
Read variable:
$path

bash. Basics. Arguments

Passing arguments to the script:
./script.sh arg1 arg2 arg3 … argN
Processing arguments within the script:
$1 - first argument
$2 - second argument
$0 - name of script
$# - count of arguments

bash. Basics. Examples

Another one example of working with variables
			#!/bin/bash
			var1=$1
			var2=$2
			echo "Arguments are \$1=$var1 \$2=$var2"
		
./variables.sh var1 var2 # how it calls

bash. Basics. Conditions

  1. if
  2. if/else
  3. if/elif/else
  4. case/in/esac

bash. Basics. Conditions

if
			git diff origin/master origin/%branch% > %path%
		
fast_diff.sh

bash. Basics. Conditions

Conditions (strings):
-z <string> # string is empty
-n <string> # string is not empty
<str1> == <str2> # strings are equal
<str1> != <str2> # strings are not equal

bash. Basics. Conditions

Conditions (numbers/strings):
-eq, (==) # equal
-ne, (!=) # not equal
-lt, (<) # less than
-le # less than or equal
-gt, (>) # more than
-ge # more than or equal

bash. Basics. Conditions

Conditions (files):
-e <path> # path is exist
-f <path> # is file
-d <path> # is directory
-s <path> # file size more than 0
-x <path> # file is executable

bash. Basics. Conditions

Conditions (boolean):
! # denial of boolean expression
&& # boolean "and"
|| # boolean "or"

bash. Basics. Loops

  1. for/in
  2. while

bash. Basics. Loops

for/in:
			for i in array
			do
			  # an action, i on every iteration is getting
			  # the next value from array
			done
		

Helpful links

Routine tasks automation

Up a large number of repositories

Up a large number of repositories

Solution: Automation

Up a large number of repositories. After

Helpful aliases

Helpful aliases

Helpful aliases

.bashrc, .gitconfig
			alias gst='git status'
			alias gf='git fetch'
			alias ghide='git stash'
			alias gshow='git stash pop'
			alias gmom='git merge origin/master' # !!!
			alias gad='git add'
			alias grm='git rm'
			alias showaliases='cat $HOME/.bashrc | grep alias'
		

Helpful links

About me

This is the last slide

Go ahead...

Fork me on GitHub