Posts tagged with terminal

Lesser known git commands

Tim Pettersen shares some of his git aliases.

Git has a strong commitment to backwards compatibility: many powerful features are hidden behind options rather than exposed as default behaviour. Fortunately Git also supports aliases, so you can create your own commands that do all manner of Git magic. Here’s a selection of the more useful (or at least entertaining) aliases defined in my .gitconfig

https://hackernoon.com/lesser-known-git-commands-151a1918a60

Read more

Advancing in the Bash Shell

If you want to learn some neat bash tricks, read this excellent read by Sam Rowe.

If you’ve ever used GNU/Linux, chances are good that you’ve used bash. Some people hold the belief that using a GUI is faster than using a CLI. These people have obviously never seen someone who uses a shell proficiently. In this tutorial, I hope to show you just a few of the amazing features bash provides that will increase your productivity in the shell.

http://samrowe.com/wordpress/advancing-in-the-bash-shell/

Read more

Join thousands of developers

Every two weeks, I share practical tips, tutorials, and behind-the-scenes insights from maintaining 300+ open source packages.

No spam. Unsubscribe anytime. You can also follow me on X.

Vim for beginners

Last year I made myself a bit acquainted with Vim. I'm by no means an expert and am not (yet :-)) advocating to replace your favourite IDE with Vim. I use it for small things:

  • it's much easier/faster to to edit files on a server using Vim as opposed to opening and editing the files in a tool like Transmit. There's a big chance that vim is already installed on your server.
  • editing your hostfile is breeze with vim.
  • if you need a small change, like deleting a line, in a file and you're IDE isn't open, Vim can help you.
  • there's a big change that you already use Vim when Git promts you to specify a commit message
Unlike most pieces of software, Vim has absolutely no respect for the beginner. Even quitting it proves quite difficult. There's really nobody that can use Vim without some training. But with same quick pointers everybody can do the tasks mentioned above.

Watch this video clearly explains the basic commands.

https://www.youtube.com/watch?v=Nim4_f5QUxA

Read more

The Art of Command Line

Fluency on the command line is a skill often neglected or considered arcane, but it improves your flexibility and productivity as an engineer in both obvious and subtle ways. This is a selection of notes and tips on using the command-line that we've found useful when working on Linux. Some tips are elementary, and some are fairly specific, sophisticated, or obscure. This page is not long, but if you can use and recall all the items here, you know a lot.
https://github.com/jlevy/the-art-of-command-line/blob/master/README.md

Read more

Do not trust cat at the command line

In this excellent post Matthias explains why you can't put all your trust in cat when inspecting a file:

https://ma.ttias.be/terminal-escape-sequences-the-new-xss-for-linux-sysadmins/

Let's all agree to never trust anything that has been posted on the internet without very thorough inspection. And let's especially agree to never run an arbitrary command or script found on the internet, without really close inspection.

Read more

Easy deployments for php projects

Let's talk a bit about deployments.

All the new projects I work on are hosted on servers that are provisioned by Forge. Forge has a quick deploy feature that allows you to pull the lastest master-commit onto the server, install composer dependencies, run migrations and so on.

It has two main drawbacks:

  • you can't see any output of the deployment script in your terminal
  • you can't do some stuff locally on your computer
To solve these points I'm switching from Forge's quick deploy feature to Deployer.
Deployer is a deployment tool written in PHP, it's simple and functional. Deploy your code to all servers you want, it supports deploy via copy, or via VCS (like git), or via rsync. Run your tasks on all your servers, or use our recipes of common tasks for Symfony, Laravel, Zend Framework and Yii.
You can install Deployer via composer. To use Deployer a deploy.php file must be added to your project. This file describes your deployment process. No worries, you can write it in php using a very clean and readable syntax. The documention on how to write the deploy.php-file is a bit vague at this point, but you'll get a good idea of how things work by taking a look at my deploy.php-file.

To run deployer you'll use this command:

[code lang="bash"] dep



I've made a bash alias that uses the name of the git branch you're currently on:

[code lang="bash"]
alias deploy='dep deploy $(git symbolic-ref --short HEAD)'

Now deploying a branch is as easy as just typing "deploy" when standing on a git repo in your terminal. This is a much nicer way to handle deployments. What I really like is that, now a deploy.php stored in the git repo, the deployment process is also versioned.

If you find Deployer doesn't meet your needs, Rocketeer, Phing and Capistrano are some more advanced alternatives. Envoy is nice too, but I haven't found a way to run stuff locally.

Read more