Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

A Timesaver’s Guide to the Command Line

253 views

Published on

In this talk, I will be looking at various ways to shortcut your workflow. Saving time typing with handy shortcuts for the command line, such as scripts and aliases, emails, and every day tasks. Leaving more time for problem solving and coffee drinking.

This talk will cover workflow and shortcuts on my Mac, introducing terminal, Alfred, Brew, ZSH/Oh My ZSH and shell scripting. While it focuses on Mac, most of the talk is applicable for anyone using or connecting to a Unix/Linux system as well.

By the end of this talk, you will be rushing to shortcut your life.

Published in: Internet
  • Be the first to comment

A Timesaver’s Guide to the Command Line

  1. 1. KEITH HYDE @keithage A Timesavers Guide to the Command Line “I can’t wait to shortcut your world”
  2. 2. WordPress Specialist at 34SP.com Linux System Administrator Licensed Radio Amateur Occasional Videographer Lover of Coffee
  3. 3. What is the Terminal?
  4. 4. VT510 Terminal
  5. 5. Terminal Emulator
  6. 6. Where is the Terminal?
  7. 7. Finding the terminal on a MAC
  8. 8. Enter your web hosting login information
  9. 9. First we need Brew
  10. 10. How to install brew How to install brew /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/ Homebrew/install/master/install)"
  11. 11. How to install a formula Install tree using brew brew install tree
  12. 12. How to install a formula
  13. 13. Running the installed command ╰!$ tree plugins/akismet/ plugins/akismet/ "!! LICENSE.txt "!! _inc #   "!! akismet.css #   "!! akismet.js #   "!! form.js #   %!! img #   %!! logo-full-2x.png "!! akismet.php "!! class.akismet-admin.php "!! class.akismet-cli.php "!! class.akismet-rest-api.php "!! class.akismet-widget.php "!! class.akismet.php "!! index.php "!! readme.txt "!! views #   "!! config.php #   "!! get.php #   "!! notice.php #   "!! start.php #   %!! stats.php %!! wrapper.php
  14. 14. Updating formulas installed with Brew Upgrade outdated, unpinned brews (with existing and any appended install options). brew upgrade Pin the specified formula, preventing them from being upgraded brew pin app-name
  15. 15. Updating formulas installed with Brew
  16. 16. What is a cask?
  17. 17. Cask Project “To install, drag this icon… no more!”
  18. 18. Brew Casks How to find a cask or a formula brew search chrome How to install a cask brew cask install google-chrome How to uninstall a cask brew cask uninstall google-chrome How to update casks brew cask upgrade
  19. 19. Search for chrome
  20. 20. Install google-chrome
  21. 21. Install iterm2 Install iterm2 brew cask install iterm2
  22. 22. Install iterm2
  23. 23. Some iterm2 features
  24. 24. How to install ZSH
  25. 25. Installing ZSH Install zsh using brew brew install zsh
  26. 26. Installing ZSH
  27. 27. Installing oh-my-zsh Install oh-my-zsh sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/ oh-my-zsh/master/tools/install.sh)” Update oh-my-zsh manually with upgrade_oh_my_zsh
  28. 28. Installing oh-my-zsh
  29. 29. Configuring oh-my-zsh with .zshrc # If you come from bash you might have to change your $PATH. export PATH=$HOME/bin:/usr/local/bin:$PATH # Path to your oh-my-zsh installation. export ZSH="/Users/badger/.oh-my-zsh" # Set name of the theme to load --- if set to "random", it will # load a random theme each time oh-my-zsh is loaded, in which case, # to know which specific one was loaded, run: echo $RANDOM_THEME # See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes ZSH_THEME="robbyrussell"
  30. 30. Configuring a theme in .zshrc # If you come from bash you might have to change your $PATH. export PATH=$HOME/bin:/usr/local/bin:$PATH # Path to your oh-my-zsh installation. export ZSH="/Users/badger/.oh-my-zsh" # Set name of the theme to load --- if set to "random", it will # load a random theme each time oh-my-zsh is loaded, in which case, # to know which specific one was loaded, run: echo $RANDOM_THEME # See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes ZSH_THEME="bira"
  31. 31. Bira theme
  32. 32. Customising oh-my-zsh File structure .oh-my-zsh/custom "!! example.zsh "!! plugins #   %!! example #   %!! example.plugin.zsh %!! themes "!! bira-updated.zsh-theme %!! example.zsh-theme
  33. 33. Customising a theme local current_dir='%{$terminfo[bold]$fg[blue]%}%~ %{$reset_color%}'
  34. 34. Customising a theme local current_dir='%{$terminfo[bold]$fg[white]%}%~ %{$reset_color%}'
  35. 35. Setting a custom theme in .zshrc # If you come from bash you might have to change your $PATH. export PATH=$HOME/bin:/usr/local/bin:$PATH # Path to your oh-my-zsh installation. export ZSH="/Users/badger/.oh-my-zsh" # Set name of the theme to load --- if set to "random", it will # load a random theme each time oh-my-zsh is loaded, in which case, # to know which specific one was loaded, run: echo $RANDOM_THEME # See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes ZSH_THEME=“bira-updated”
  36. 36. My custom Bira theme
  37. 37. oh-my-zsh plugins
  38. 38. https://github.com/robbyrussell/oh-my-zsh/wiki/Cheatsheet
  39. 39. Change Directory
  40. 40. Take Directory
  41. 41. Listing help options
  42. 42. Some oh-my-zsh aliases l='ls -lah' la='ls -lAh' ll='ls -lh' ls='ls -G' lsa='ls -lah' md='mkdir -p' rd=rmdir run-help=man -='cd -' ...=../.. ....=../../.. .....=../../../.. ……=../../../../.. _=sudo
  43. 43. List Aliases
  44. 44. How to create shell aliases
  45. 45. ZSH [Keith@34SP:~]$ nano .zshrc # User specific aliases and functions alias rm=‘rm -i’ alias cp=‘cp -i’ alias mv=‘mv -i’ alias dbe=‘wp db export’ alias edit=‘vi’
  46. 46. Bash Shell [Keith@34SP:~]$ nano .bashrc # .bashrc # User specific aliases and functions alias rm=‘rm -i’ alias cp=‘cp -i’ alias mv=‘mv -i’ alias dbe=‘wp db export’ alias edit=‘vi’
  47. 47. How to create basic shell scripts
  48. 48. A simple shell script #!/bin/bash # show various script types and shebangs # This is a comment you can use to explain what a line does # Bash does not know where it is, so be sure to use full paths! /usr/local/bin/wp db export /var/backups/$(date %F)-mydbdump.sql path=/var/www/vhosts/my- domain.co.uk/httpdocs/wp
  49. 49. An extended shell script #!/bin/bash # Backup database to remote location declare -r timestamp=$(date +%F_%H-%M-%S) if [ "$1" == "" ]; then echo "Usage: $0 domain.com"; exit 1 else DOMAIN=$1 echo "/usr/local/bin/wp db export /tmp/$DOMAIN-$timestamp.sql --path=${HOME}/$DOMAIN/httpdocs" echo "/usr/sbin/rsync -avz /tmp/$DOMAIN-$timestamp.sql remote@server.com:/backups/$DOMAIN" fi exit
  50. 50. A PHP shell script #!/bin/php # Backup database to remote location $domain = ''; $home = ''; $timestamp = date(); eval("/usr/bin/wp db export /tmp/$domain-$timestamp.sql --path=$home/$domain/httpdocs");
  51. 51. How to purchase and set up Alfred snippets
  52. 52. the website and stuff here
  53. 53. the website and stuff here
  54. 54. Snippets in email
  55. 55. wppl] = wp plugin list
  56. 56. wptl] = wp theme list
  57. 57. wpcf] = wp cache flush
  58. 58. dbe] = wp db export
  59. 59. Snippets Menu
  60. 60. Free version available with limited options £23 Single Version License £39 Lifetime License
  61. 61. Kayleigh Thorpe “If you buy this app, your life will be better”
  62. 62. What next?
  63. 63. Advanced Workflows
  64. 64. Advanced Workflows
  65. 65. Advanced Workflows
  66. 66. Advanced Workflows
  67. 67. Advanced Workflows
  68. 68. Advanced Workflows
  69. 69. Advanced Workflows
  70. 70. Advanced Workflows
  71. 71. Advanced Workflows
  72. 72. Advanced Workflows
  73. 73. Advanced Workflows
  74. 74. Advanced Workflows
  75. 75. Advanced Workflows
  76. 76. Advanced Workflows
  77. 77. Advanced Workflows
  78. 78. Advanced Workflows
  79. 79. Advanced Workflows
  80. 80. Advanced Workflows
  81. 81. Advanced Workflows
  82. 82. Advanced Workflows
  83. 83. Alternative snippets for Windows
  84. 84. Work smart not hard by Installing brew package manager Installing ZSH shell & oh-my-zsh framework Use and customise aliases Creating scripts Using Alfred snippets and advanced workflows
  85. 85. KEITH HYDE @keithage | https://mr-badger.co.uk
 https://www.34sp.com/talks/keith Thank you very much!

×