Archive for Terminal

How to set VIM as SVN editor

export SVN_EDITOR=vim

vim can be replaced with nano for instance, but not with mate, because its a graphical editor.

How long your mac is turned on

Just type this command:

uptime

Checking IP address

Please execute following command:

ifconfig | grep netmask

Converting line endings

Install the small nice applications called “Flip” with:

brew install flip

and then execute following command:

flip -u filename

Options:
-u = convert file(s) to Unix newline format (newline)
-d = convert file(s) to MS-DOS/Windows newline format (linefeed + newline)
-m = convert file(s) to Macintosh newline format (linefeed)
-t = display current file type, no file modifications

Total Terminal – Quake like console

Install and enjoy:
http://totalterminal.binaryage.com/

Uploading files with scp command

Just execute following command in your terminal (~ is the home directory):

scp filename.txt username@hostname.org:~

Uploading directory with all files inside it:

scp -r dirname username@hostname.org:~

Chmod

Legend:
u – users
g – groups
o – others
a – all

To add a write permissions for the user (+ because we want to add them):

chmod u+w file

To remove a read/write permissions for the group (- because we want to remove them):

chmod g-rw file

Specifying multiple permissions per once:

chmod u=rwx, go=r file

Specifying permissions for all groups:

chmod a+r file

Setting permissions recursively:

chmod -R o-rwx some/directory

Useful commands

Counting the number of words in file:

cat file.txt | wc -w

Searching the output for “uzza” word:

cat big-file.txt | grep uzza

Gzipping files:

gzip some_file.txt

Decompressing Gzipped files:

gzip -d some_file.txt.gz

Creating archive of directory:

tar -cvf archive-name.tar some-dir

c – creating new archive
v – verbose
f – we want to specify the name of the output file

Creating compressed archive of directory:

tar -czvf archive-name.tgz some-dir

z – compress with gzip

Expending the archive:

tar -xzvf archive-name.tgz

x – tells to expend rather than compress

Creating entire directory structure:

mkdir -p dir1/dir2/dir3

Tree – Listing all files from selected directory

Installing:

brew install tree

Using:

tree /some/dir

Saving output of the tree command:

tree > some_file.txt

Appending content to existing file:

tree >> data.txt

Enabling bash terminal highlightning

Open

~/.profile

Add following lines:

export CLICOLOR=1
export LSCOLORS=CxFxCxDxbxegedabagacad

Colors:

a  black
b  red
c  green
d  brown
e  blue
f  magenta
c  cyan
h  light grey
A  block black, usually shows up as dark grey
B  bold red
C  bold green
D  bold brown, usually shows up as yellow
E  bold blue
F  bold magenta
G  bold cyan
H  bold light grey; looks like bright white
x  default foreground or background