Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Productivity and Bash

Productivity and Bash

Recently I wrote a small tool for switching between projects called workon, was a sideproject but I decided to share it with my fellow coworkers under the context of productivity. So I added some tips on productivity as a software engineer and something on bash language which I needed for my workon project.

Henoc Díaz

March 10, 2017
Tweet

More Decks by Henoc Díaz

Other Decks in Programming

Transcript

  1. The best way to survive to deadlines is to work

    them. — Alan Kay ). Henoc Díaz. @henocdz
  2. 1. Organiza+on. Put all your projects' code in one place

    and organize them by client-name, so you can remember where you put them easily. e.g: ~/Drive/Work/asistia ~/Drive/Work/sable @henocdz
  3. 2. Project notes. 1. Add a global .gitignore 2. Set

    it up: git config --global core.excludesfile ~/.gitignore 3. Create a folder .notes inside each one of your projects. Now you can add temporary notes or code-samples per project without losing them. Just keep in mind that this notes are not in version control, so you might lose them if something happen with you machine1. 1 Solu'on: You can add your workspace folder inside a folder of Google Drive or similar. I'm not a fan of this btw. @henocdz
  4. 4. Use CLI aliases. If you use oh-my-zsh, there are

    a few that come within plugins like gp = git push gcb = git checkout -b If not, then add some aliases in your ~/.bash_profile for example: alias gp="git push" alias djmm="python manage.py makemigrations" alias rnlios="react-native log-ios" type less, think more. @henocdz
  5. 4.1 Configure ssh-keys properly. run this once, then add it

    to ~/.bash_profile ssh-add -K ~/.ssh/id_rsa so you will never need to add your ssk-key password again. btw. put your ~/.ssh/id_rsa file in something like Google Drive, so you don't need to create a new one when the end of your machine arrives ! @henocdz
  6. Sublime Text. • Reveal current file in side bar {

    "keys": ["alt+shift+r"], "command": "reveal_in_side_bar"} • Go to defini+on. { "keys": ["super+e"], "command": "goto_definition" } • Upper and lower case2. { "keys": ["super+k", "super+u"], "command": "upper_case" } { "keys": ["super+k", "super+l"], "command": "lower_case" } 2 Super => Mac or Windows key. @henocdz
  7. use the ones that are already configured: • Paste from

    history { "keys": ["super+option+v"], "command": "paste_from_history" } • Select current word mul/ple /mes.. { "keys": ["super+d"], "command": "find_under_expand" } You can add your own shortcuts just go to: Sublime Text -> Peferences -> Key bindings @henocdz
  8. 5.1 Some useful se-ngs. super + , "remember_open_files": true, "ensure_newline_at_eof_on_save":

    true, "translate_tabs_to_spaces": true, "trim_trailing_white_space_on_save": true @henocdz
  9. Extra 1. Use something like Spectacle 2 (so1ware) to manage

    window sizes with your keyboard. 2. Set up your hot corners 3. Boom 2 (macOS) for a beCer audio output. 4. Use ~/ssh/config to manage remote hosts. 5. Classic one: use pomodoro technique. @henocdz
  10. memorize some useful bash commands to improve produc5vity e.g •

    Search for something you already typed in3. history | grep "what you lookin' for?" and others... 3 or use backward interac1ve search: ctrl + r @henocdz
  11. like work on $ pip install workon Set up: h)ps:/

    /github.com/henocdz/workon/issues/2 Work in mul+ple projects easily. work add project-name work on project-name work list @henocdz
  12. Bash 1. 1989 2. Unix Shell and Command Line Language

    3. Default shell for Unix systems (a.k.a Linux + macOS) @henocdz
  13. Variables VARIABLE="some value" # string VARIABLE2=somevalue # ref to something,

    not defined in this case. typeset -i a_number a_number=1205 echo $VARIABLE echo $a_number Important: no spaces around = sign. @henocdz
  14. Func%ons function work { ... } source your script and

    then you can use func1on name as CLI tool (command)4 source /abspath/script.sh 4 Tip: add it to ~/.bash_profile @henocdz
  15. The shi' built-in Access parameters $0 # command name $N

    # param number $# # number of params available $* # all params excluding $0 $@ # all params @henocdz
  16. Tests a.k.a Condi.onals. [ represents a test case. Available comparison

    operators can be found with: man test if [ $result -eq 0 ]; then if [ -d "$output" ]; then workon_cd $output else echo "$output" fi elif [ $result -eq 1 ]; then echo $output fi @henocdz