HakoDocs

HakoDocs

Posts (Latest 10 updated) :
Read all
Table of Contents:
  1. Linux: CLI Tips
  2. Useful and unorganized bash functions
    1. Add git branch to PS1 prompt
  3. Images
    1. Merge images to PDF
    2. Merge images to video
  4. Video
    1. Convert format

Linux: CLI Tips

This is a collection of quick commands you can use to accomplish very specific tasks using the command line. This is a continuously growing collection, and contributions are accepted.

See the Table of Contents for a full guide.

Useful and unorganized bash functions

Add git branch to PS1 prompt

The following bash function writes adds (branch) at the end of your default prompt.

git_branch() {
  git branch 2>/dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}

Images

Merge images to PDF

Depends on ‘imagemagick’.

convert $(ls -v *.jpg) out.pdf

Merge images to video

Combine images (frames) into a single video. Depends on ‘ffmpeg’

ffmpeg -framerate 30 -i %d.png -c:v libx264 -pix_fmt yuv420p output.mp4

in case it fails, you can try instead

ffmpeg -framerate 15 -i %d.png -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" -c:v libx264 -pix_fmt yuv420p output.mp4

Video

Convert format

Depends on ‘ffmpeg’.

ffmpeg -i video.mkv -codec copy video_out.mp4