console Add color to your bash script Longer scripts with a lot of output get confusing fast. A nice change of pace is working with colors there. For this you can use ANSI escape codes [https://en.wikipedia.org/wiki/ANSI_escape_code#Colors]. In a script this might look like this: RED='\033[0;31m&
symfony Show environment variables in Symfony Environment variables can be defined in multiple files and you might need to check a few to see what is used at the moment. Much easier is running the following command to show all environment variables used in the currently used environment with: php bin/console debug:container --env-vars Or
symfony Get global symfony kernel parameters Recently I needed to inject the current environment into a service, but couldn't remember how the parameter Symfony offers for it was named. Luckily you can output the existing parameters on the console. And it makes it easier if you remember that it was something with "kernel&
console Zip file with password on Mac Recently I wanted to send a zip file with a password for sending confidential data to a colleague. But I didn't want to download a separate app for it. Luckily there is a easy command line tool for it called - I could have guessed - zip with
console Jump to beginning of line in iTerm When working with iTerm or a console in general I hate it that I can't jump words forward or backwards with ALT + Arrow keys. Now I found a way to do this. And it's so simple I just didn't know the term "Natural
git Changing git commit message after push You know the feeling when you just pushed a commit to the remote and realize you've got a typo or some information missing in your commit message? There is a fix for that. Not for the feeling itself, but at least for the message. You can update it
ssh Upload file via ssh connection One common thing you have to do when doing Sysops, is uploading or downloading files. Most times you've got a SFTP connection to do so, but often times that's not possible and you only have a SSH connection available. Every time I have to do this,
console zsh agnoster theme without hostname I really like the agnoster theme [https://github.com/agnoster/agnoster-zsh-theme] for my terminal. But the hostname is just to long and not really useful on your local machine. That's why I searched for a way to remove it. And it's quite easy: Just remove the
console Create folders from text file Did you ever had the case that you wanted to create a lot of folders but didn't want to do this by hand? There is a simple command to create a list of folders from a text file: xargs -tI % mkdir % < folder-list.txt with each folder name
ssh Always login to ssh with the id_rsa ssh key A neat little trick to always login with ssh via a the id_rsa ssh key on mac is to put the following line at the end of your config file: Host * UseKeychain yes This way when you setup any other ssh config before that it will still use whatever
console Track time a command takes on the console I wanted to track the time two php documentation generation tools need for the complete generation. Both generators are triggered on the console, so I searched for a console command. Of course there already is a basic UNIX one. It's called time. This is the basic usage: $ time
console chmod recursive only on files When needing to move a lot of repositories from one VM to another, I used rsync to move all files from one NFS share to another. I didn't use the flag to keep the permissions and they got scrambled. To make them available to my server again I
console Global .gitignore When you're working with git, there are many types of files which you will want to ignore in every single git project. System files like .DS_Store or IDE files/folders like .idea. Those files are more related to your system then your project and should therefore be
console Show lines before and after with grep Little neat parameter for grep to show lines before and after the found line. -A number of lines to show after, -B number of lines to show before and -C numbers of lines to show before and after (with default of 2). $ grep -C 5 "My error message"
console Git autocorrect Did you know that there is an autocorrect feature within git? It automatically correct (and execute) things like git stats to git status. By default this feature is disabled. To enable it enter the following command: $ git config --global help.autocorrect -1 From the documentation: > Automatically correct and execute
mac Export a VMWare Fusion virtual machine Recently I had to reinstall my Mac. One of the things I wanted to save was my virtual machine. Turns out VMWare Fusion doesn't have any kind of export functionality directly within the application. What I found though was a command line tool with which you can export
mac Show log files on console with changes When writing any kind of log files you can of course show them on the console by opening them in any kind of editor be it vim, less or just a simple cat. But you need to run the command every single time you run a process that writes something
mac Manually update oh-my-zsh When you're like me and running oh-my-zsh on mac in your iTerm console you won't get auto updates, because you just don't restart your console very often. There is a way to still get oh-my-zsh updates with running this command: $ upgrade_oh_my_zsh
mac Running multiple instances of apps on mac (like Skype) Do you also have multiple accounts for Skype or any other mac app? For example if you've got a private and a business account. You can't login with two accounts in the same Skype instance. What you can do instead is starting a second instance of
ssh SSH Config Creating a ssh connection via your console can be kind of awkward. $ ssh user@domain.tld Password: ...... Last login: Thu Oct 23 21:06:01 2014 from ip-.... This can be way easier. Just create a ssh key with ssh-keygen grab your public key and transfer it to your server.
console Color scheme for iTerm I'm a iTerm user for a long time now and I always used the default color scheme, because it was just good. There was no reason for me to even think: "Hey couldn't I improve that". Now i stubled over a very nice color
console Show file size on console There are a few easy options to see the size of a file via the console. That's primarely useful if you want to see wether there is a log file that goes bananas. The easiest way is the following: $ ls -l /tmp/query.log which returns something like:
search Search through console history Of course you can use the ▲ (up) and ▼ (down) keys to navigation through the last executed commands, but there are way more comfortable ways to search through your console history. Search through last commands: $ CTRL + r # Reverse search Show all console commands with the search term in it as a
cache Clear composer cache When working with your own repositories or with just updated packages, it can happen, that composer still has something in the cache and just don't want to update. To clear the composer cache just run the following: $ composer clearcache You can also use clear-cache which is an alias
console Show current date and time on linux Sometimes a virtual maschine or your server can run into the wrong date or time. That happens for example if you don't restart a virtual maschine but just pause it. To show the current date and time just enter the following: $ date which output's something like: