Ubuntu

Customize GNU Screen Terminal Title

  • Posted on: 6 April 2014
  • By: Zhijun Chen

GNU Screen is a full-screen window manager that multiplexes a physical terminal between several processes, typically interactive shells.

To install Screen under Ubuntu, open a terminal and type in the following script.

sudo apt-get install screen

After installation, You can customize the terminal titles by creating a .screenrc file under your home directory and put the following code in the file.

termcapinfo xterm 'hs:ts=\E]2;:fs=\007:ds=\E]2;screen\007'
termcapinfo xterm ti@:te@
shelltitle '$ |bash'

termcapinfo rxvt 'hs:ts=\E]2;:fs=\007:ds=\E]2;screen\007'
termcapinfo rxvt ti@:te@

hardstatus on
hardstatus alwayslastline
hardstatus string "%{wk}%H%{Bk}|%{Mk}%?%-Lw%?%{km}[%n*%f %t]%?(%u)%?%{mk}%?%+Lw%? %=%{Bk}"

The effect of the code above will set the screen display as shown in the following picture.

 

Some useful keyboard combinations in Screen:

  • ctrl+a -> caps+a : Name the current terminal
  • ctrl+a -> number of window x : Switch to window x, e.g. ctrl+a 1
  • ctrl+a -> ctrl+a : Go back to the previous screen
  • ctrl+a -> [ : Enter copy mode, then you can scroll up and down in the current window, press q to exit
  • ctrl+a -> caps+s : Split display vertically
  • ctrl+a -> | : Split display horizontally
  • ctrl+a -> tab : Jump to next display region
  • ctrl+a -> caps+x : Remove current region
  • ctrl+a -> caps+q : Remove all regions but the current one

Set up Git and Jenkins under Ubuntu

  • Posted on: 26 January 2013
  • By: Zhijun Chen
* Install Git and set up Git

Git is a distributed version control system and can be installed using the following one command:

sudo apt-get install git

After it finishes downloading, you will have Git installed and ready to use. Use the following commands to config global username and email.

git config --global user.name "username"
git config --global user.email "email"

Use the following command to see all of your settings:

git config --list
* Set up a new Git project

After installing Git, you should be able to create a new Git project.

There are two types of repositories in Git: development repository and bare repository. A development repository is used for normal, daily development, e.g. editing, adding and deleting files. In contrast, a bare repository has no working directory and it serves as an authoritative basis for collaborative development. You can pull/push changes from/to bare repositories.

Use the following commands to set up a remote bare repository

ssh git@example.com  
mkdir my_test_project.git 
cd my_test_project.git 
git init --bare

After setting up bare repository, we need to init a local project and do a initial "push" to the bare repository. So on local machine, do the following:

cd my_test_project
git init
git add * 
git commit -m "Initial commit message" 
# Add remote origin, specify your own project path 
git remote add origin git@example.com:my_test_project.git
git push -u origin master

Others can clone the remote repository using the following command

git clone git@example.com:my_test_project.git
* Install Jenkins

Install Jenkins using the following command:

wget -q -O - http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key | sudo apt-key add -
sudo sh -c 'echo deb http://pkg.jenkins-ci.org/debian binary/ > /etc/apt/sources.list.d/jenkins.list'
sudo apt-get update
sudo apt-get install jenkins

For more configurations, please refer to Installing Jenkins on Ubuntu

* Install Jenkins Git plugin

After installing Jenkins, you should be able to access Jenkins root page at http://your_jenkins_host:8080/

Next we should install Jenkins Git plugin to allow Jenkins to talk to Git repository. If your Jenkins instance has security enabled, login as a user who has the Overall/Administer permission.

Select Manage Jenkins link on the left-hand side of the screen. Click on Manage Plugins link.

Under Available tab search for "git" then you should be able to select the Git plugin.

Click the Download now and Install after restart button at the bottom.

* Configure job in Jenkins

Navigate to Jenkins instance job or create one if none exists.

Select Configure link on the left hand side of the screen In the Source Code Management select Git option and enter the previous git address which looks like ssh://git@example.com/my_test_project.git. Note: Make sure that the bare git repository is visible to Jenkins otherwise errors would be thrown.

For more information please refer to Jenkins Git Plugin Click Save button at the bottom.

* Configure Jenkins to build automatically after Git push

You may want to trigger Jenkins job to build automatically after each Git push. You can achieve this simply by using Git post-receive hook.

To do this, navigate to job configuration page by clicking on Configure link on the left hand side. Check Poll SCM option under Builder Triggers.

In the machine which holds Git bare repository, inside my_test_project.git folder, go into hooks folder and create a file called post-receive, and type in the following command:

curl http://your_jenkins_host:8080/git/notifyCommit?url=path_to_bare_repository

for instance, curl http://localhost:8080/git/notifyCommit?url=/Projects/myproject.git

Go to your Git development repository and do a Git push, you should see the following message.

"remote: Scheduled polling of my test project"