Showing posts with label linux. Show all posts
Showing posts with label linux. Show all posts

Sunday, September 9, 2012

Handling archives in linux (ranger file manager)

Today I was looking for a some plugin for unpacking files in Ranger file manager. I found great tool ( atool :) ). It is nice and simple command for packing and unpacking many types of archives.

First install atool, in ubuntu you do it with apt-get:
sudo apt-get install atool


Now update your rc.conf in ranger (after default instalation you need to copy-config from default skeleton. ranger --copy-config all). Now edit your bindings in ~/.config/ranger/rc.conf

map Pu shell atool -x %s
map Pa shell atool -a %s

Now after pressing Pu/Pa archive is unpacked or directory/file is packed.

Thursday, June 21, 2012

Merge many PDF files into one in linux shell

Do you want to merge many PDF files into one? There you are:

Shell code:
$ gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=out.pdf in1.pdf in2.pdf

- out.pdf - destination file name
- in1.pdf, in2.pdf - source file names

(gs - Ghost Script - on Ubuntu 12.04 and OpenSuse 11.3 is installed by default)

Linux Shell Tips - rm exclude emulation

If you want to remove all files and sub-directories from directory exept some files you can use  rm and find combination as described below: :

rm -rf $(find . ! -wholename './web/index.php' ! -wholename './web/.htaccess' ! -name '.' ! -name 'web')

You can see more find power examples on  http://www.infoanda.com/resources/find.htm

Linux Shell Tips - watch

If you want to monitor some command execution in time like "tail -f" for files, probably your linux box have nice solution for you:

watch -n 1 'ls -l'

Where:
'-n 1' - time (in seconds) to refresh command output
'ls -l' - command to execute in interval above

When we add '-d' option (help: highlight changes between updates), watch inform Us what was changed between command executions.

Example for 'ls' command below:


watch --color -n 10 -d 'ls -la'

Output:



After change in directory structure watch informs us about changes:

Friday, June 15, 2012

VIM + gpicker = SublimeText 2 like files fuzzy searching

Authors of SublimeText2 make great job with Fuzzy searching. In the past I've used Command-T and CtrlP plugins but both of them doesn't works well for me. Then i found Gpicker project it is written in C so its very fast and can be used in two most powerful editors: VIM (gpicker.vim) or Emacs (gpicker.el). I'm using now gpicker for both of them. It's not so powerful like SublimeText but it get the job done very well.

You can install gpicker in ubuntu

$ sudo apt-get install gpicker

Next step is to configure your favourite editor. In VIM you must put gpicker.vim to ~/.vim/plugins directory (or use any other technique pathogen, vundle or whatever). In emacs you must load gpicker.el in your init.el file (I'm using prelude for that ~/.emacs.d/vendor/). It is working out of the box for me (Ubuntu 12.04, Vim 7.3.429, Emacs-snapshot - 24.1.50.1).

My key bindings in VIM:

map <Leader>p :GPickFile<CR>
noremap <C-p> :GPickFile<CR>
map <Leader>. :GPickBuffer<CR>


Final result:

Gpicker in VIM


Gpicker in Emacs



You can use it in shell too: 


You can look in my vim dotfiles for more information. If you want try my VIM configs you can run command below in your shell

$ curl -L https://raw.github.com/exu/vim-dotfiles/master/gitinstall|bash

WARNING this command will kill your .vimrc file and .vim/ directory so BACKUP your old configs! look at https://raw.github.com/exu/vim-dotfiles/master/gitinstall for more details

Thursday, September 8, 2011

PHP Ubuntu simple server monitoring script

Simple PHP monitoring script.

Change hosts variable (array) and path to icon file (-i /usr/share/icons/Faenza/status/scalable/error.svg).

You can use it in your crontab: Edit your cron settings:
 
crontab -e

and insert:
 
* * * * * php /home/exu/scripts/monitoring

(change /home/exu/scripts/monitoring to path to your file) Enjoy!


Thursday, July 7, 2011

rsync with --itemize-changes flag

My yesterday rsync battle notes:
rsync --checksum --verbose  --recursive --delete --itemize-changes --times SOURCE_HOST DESTINATION_HOST 

+- incoming / outgoing / change 
|
|+- type : f for a file, a d for a
||         directory, an L for a symlink, 
||         a D for a device, and a S  for  a
||         special file (e.g. named sockets and fifos
||
<f.st......
  |||||||||
  ||||||||+- x - extended attributes
  |||||||+- a - ACL info changed
  ||||||+- u - reserved for future
  |||||+- g - group
  ||||+- o - owner
  |||+- p - permissions
  ||+- t - modification time 
  |+- s - size
  +- c - checksum


Additional information:
. - no change
* - e.g. *deleting
c - local change/creation e.g. creating dir symlink
< - file transfer to remote
> - file transfer to local host (received)

Friday, May 6, 2011

Ubuntu 11.04 po instalacji na VirtualBox

Oto moje Ubuntu 11.04 po wstępnej instalacji i konfiguracji. 

  • na Virtualbox'ie  czasami się zacina przestał się zacinać po pierwszej aktualizacji.
  • Jak dla mnie unity wprowadziło delikatny powiew nowości (lubię nowe rzeczy).
  • Co mnie najbardziej zdziwiło to na moim starym desktopie z Pentium 4 2.8 i 2GB działa płynnie a co najważniejsze działa po aktualizacji z wersji 10.10.

Monday, April 11, 2011

Ubuntu 11.04 już jest

The next version of Ubuntu is coming soon

Postawione na VirtualBox , w wolnej chwili postaram się opisać wrażenia. Wrażenia po godzinie używania - spodziewałem się że będzie gorzej ;)

Thursday, March 17, 2011

Métamorphose - masowe zmienianie plików w ubuntu

Całkiem niezłe, przynajmniej dla Mnie najlepsze GUI do masowej zmiany plików jakie znalazłem,
http://file-folder-ren.sourceforge.net/

Przejdź do strony lub jeżeli korzystasz z ubuntu:
sudo apt-add-repository ppa:ianare/ppa && sudo apt-get update && sudo apt-get install metamorphose2

Screen:

Wednesday, March 2, 2011

Uruchomienie wielu zakładek w terminalu GNOME z konsoli

Przykładowy skrypt:
#!/bin/sh
gnome-terminal --maximize \
     --tab -t LOCAL \
     --tab -e "sudo su" -t ROOT \
     --tab -e "ssh jacek.wysocki@10.0.0.222" -t CDT \
     --tab -e "ssh jacek.wysocki@10.0.0.221" -t WRK \
     --tab -e "ssh jacek.wysocki@10.0.0.217" -t PRD \
     --tab -e "ssh dplyr@10.0.0.219" -t DEPLOY \
     --tab -e "ssh jacek.wysocki@10.0.0.218" -t NGINX

Rezultat:




Opcja --maximize maksymalizuje okno i nie jest konieczna
Opcja -e POLECENIE wykonuje POLECENIE po uruchomieniu zakładki
Opcja -t TYTUŁ ustawia tytuł okna na TYTUŁ

SVN dodanie istniejących plików do listy ignorowanych przy wykonaniu commit

Podpiąłem sobie pod F11 w VIMie commit wykonanie commita na aktualnym katalogu. Niestety chciałem pominąć określone pliki których z określonych powodów nie chciałem zmieniać w repozytorium.

Można to osiągnąć wykorzystując tzw.: changelist
$ svn changelist ignore-on-commit example-file-to-ignore.txt