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


  1. Produc'vity The key to succeed as a So/ware Engineer @henocdz

  2. Work more (me or Work faster @henocdz

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

    them. — Alan Kay ). Henoc Díaz. @henocdz
  4. Tips. @henocdz

  5. 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
  6. 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
  7. 3. Always use SSH auth for remote repositories. Just do

    it. It's faster. @henocdz
  8. 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
  9. 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
  10. 5. Boost your Code Editor. Shortcuts are the key to

    improve produc3vity. @henocdz
  11. 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
  12. 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
  13. 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
  14. 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
  15. 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
  16. write your own produc.vity-tools with bash @henocdz

  17. 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
  18. Bash 1. 1989 2. Unix Shell and Command Line Language

    3. Default shell for Unix systems (a.k.a Linux + macOS) @henocdz
  19. 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
  20. 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
  21. The shi' built-in Access parameters $0 # command name $N

    # param number $# # number of params available $* # all params excluding $0 $@ # all params @henocdz
  22. execute in another shell and wait for response (spawning) output=$(command

    something...) @henocdz
  23. last result $? # execution of last command was successful?

    result 0 to 255 @henocdz
  24. 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
  25. !✨ @henocdz