If you have been following along you now have macOS tuned up and some basic applications installed. If you need to read other parts of this series:
- Apple MacBook Air M1 for Network Engineers Part 5
- Apple MacBook Air M1 for Network Engineers Part 4
- Apple MacBook Air M1 for Network Engineers Part 2
- Apple MacBook Air M1 for Network Engineers Part 1
In part 3 we will continue installing applications.
- Sublime Text 3 - A highly customizable text editor
- Open Sublime text from the terminal
The Network Tech Cisco plugin
- Using Regular Expression to search/replace
- Regex Quantifiers
- Speedtest-cli - Run OOKLA speedtest from the terminal
- iTerm2 - A fantastic terminal application
- Onyx - Operating system utilities for macOS
- Ticker - A stock market app for the terminal
Sublime text
One of the most popular editors for python developers. There is a free version that is fully functional but will ask you to buy once in a while and a paid version for $74.95. The license for the paid version lets you install it on all of your personal computers and it runs on Mac, Linux, and Windows so I purchased a license.
There are many tutorials on setting up Sublimetext for developers.
realpython.com has some of my favorite tutorials:
Setting Up Sublime Text 3 for Full Stack Python Development
realpython.com also sells a package on python/sublimetext that includes detailed videos and pdfs on Sublimetext and Python for $59. I purchased it and was not disappointed. In fact, I signed up for the realpython.com membership for $100 per year.
Why is it so hard to find good and clear instructions on how to make Sublime more Python friendly?
There are many reasons to give Sublime text a try if you are a network engineer, one of my favorites is that you can put a list of all the open files on the left side. This is much better than notepad ++ on Windows if you are working with several files at one time. You can even click and drag the files to change their order in the "Open Files" window.
Installation
- Download the package from www.sublimetext.com
- Open the dmg file.
- Drag to the applications folder
- Set Sublimetext as the default editor for text documents.
- In finder, locate a .txt file, right-click, get info, set "Open with" to Sublimetext.app.
Set the option to open files in the same window but a new tab.
Go to “Sublime Text” → “Preferences” → “Settings.”
Add the following property to your Sublime user configuration file:
{
"open_files_in_new_window": false
}
The windows will look like this:
If there are already settings in the file, just add the
"open_files_in_new_window": false
between the starting and closing brackets on its own line. All of the lines except the last one have to have a comma at the end.
Save and close the two settings windows that opened. Now when you double click on a file it will open in the same window, in a new tab.
Reference
Sublime text open files same window
Zooming
Reference
Using Snippets
This allows you to create snippets of text and insert them with a "trigger word" or from the tools menu. This site shows how to get started. There is an error in how to create a new snippet. Instead of tools, new snippet, it's tools, developer, new snippet.
quickly insert text and code with sublime text snippets
Here is a sample snippet I made to start a config file for a cisco IOS-XE switch.
<snippet> <content><![CDATA[ no service pad service tcp-keepalives-in service tcp-keepalives-out service timestamps debug datetime msec localtime service timestamps log datetime msec localtime service password-encryption service linenumber service sequence-numbers service counters max age 5 no service dhcp clock timezone PST -8 0 clock summer-time PDT recurring no ip source-route no ip gratuitous-arps no ip domain lookup login on-failure log login on-success log ipv6 nd raguard policy HOST_POLICY spanning-tree mode rapid-pvst spanning-tree portfast default archive log config logging enable logging size 1000 interface GigabitEthernet1/0/1 switchport access vlan xxx switchport mode access switchport nonegotiate load-interval 30 no cdp enable ipv6 nd raguard attach-policy HOST_POLICY storm-control broadcast level 1.00 storm-control multicast level 1.00 ip verify source exit ip default-gateway x.x.x.x ip forward-protocol nd no ip http server ip http authentication local ip http secure-server ip http secure-ciphersuite aes-256-cbc-sha ecdhe-rsa-aes-gcm-sha2 ecdhe-ecdsa-aes-gcm-sha2 ip http tls-version TLSv1.2 ip ssh rsa keypair-name SSH-KEYS ip ssh version 2 ip ssh server algorithm mac hmac-sha2-256 hmac-sha2-512 ip ssh server algorithm encryption aes256-ctr aes192-ctr aes128-ctr ip scp server enablebanner exec ^CC ********************************************************* Switch Name: xxxxxxxx Description: yyyyyyyyyyyyyyyy ********************************************************* ^C $1 ]]></content> <!-- Optional: Set a tabTrigger to define how to trigger the snippet --> <tabTrigger>basic-cisco</tabTrigger> <!-- Optional: Set a scope to limit where the snippet will trigger --> <scope>text</scope> <description> Cisco start up </description> </snippet>
I could also click tools, snippet, and pick it from the list.
The part of the snippet "<description> Cisco start up </description>" sets the description you see on the right of the men.
Open Sublime Text from the terminal
A lot of time I want to just type "subl <filename>" from the terminal to edit a file. I also want to use Sublime text for my git commit messages. Sublime provides instructions to set this up on macOS.
Setup
The first task is to make a symlink to subl. Assuming you've placed Sublime Text in the Applications folder, and that you have a ~/bin directory in your path, you can run:ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" ~/bin/subl
The EDITOR environment variable
To use Sublime Text as the editor for many commands that prompt for input, set your EDITOR environment variable:
export EDITOR='subl -w'
Specifying -w will cause the subl command to not exit until the file is closed.
On my M1 I had to add the bin folder and this to the .zshrc file:
export PATH=$HOME/bin:$PATH
to make this work but now I can just type subl to start sublime text from the terminal.
Reference
Finding Differences
One really useful feature in Sublime text is the difference engine. An example will make it clear.
In this file I changed the following:
interface 1/1-1/48
interface 1/1-1/48,2/1-2/48,3/1-3/48
In Sublime text, I right clicked over the line and selected "Show Diff Hunk"
Now Sublime text shows an orange bar on the left and the old string. Right clicking over the line again will show "Hide Diff Hunk", Revert Diff Hunk and show unsaved changes.
The "Show Unsaved Changes" will open a "Git" style windows and show you all the unsaved changes in the file.
--- /Users/mhubbard/GoogleDrive/01_Vector/network Refresh/Site-49/2930.txt Fri Sep 17 09:58:10 2021 +++ /Users/mhubbard/GoogleDrive/01_Vector/network Refresh/Site-49/2930.txt Sun Sep 19 16:21:35 2021 @@ -13,7 +13,7 @@ time daylight-time-rule continental-us-and-canada time timezone -480 spanning-tree -interface 1/1-1/48 +interface 1/1-1/48,2/1-2/48,3/1-3/48 rate-limit bcast in percent 1
The Network Tech Cisco plugin
This is a great open-source plug-in for Cisco network engineers. I have found that it does a reasonable job highlighting Aruba text and the network calculations work.
It highlights the keywords in the code, works with IOS, IOS-XR, Nexus, ASA, and ACE code. It also has:
- code completion
- Mask Conversions
- Quick Info - Display subnet information
- Format MAC Addresses by Colon, Dash or Dot
- Password Decode - Decode type 7 passwords
- Jumping - Quickly jump around large configuration using Symbols
- Search for networks
Set the syntax type
Open a file to edit or start a new file.
Supported configurations:
- Cisco ASA
- Cisco ACE
- Cisco IOS
- Cisco IOS XR
- Cisco NXOS
Set the syntax from the command pallet
Tools - Command Pallet OR cmd+shift+p
Set Syntax: Cisco IOS <enter>
File extensions
If a configuration file has a specific file extension and is opened in Sublime Text, the syntax will be automatically be set:
- Cisco ASA - *.cisco-asa - *.asa
- Cisco ACE - *.cisco-ace
- Cisco IOS - *.cisco-ios - *.ios
- Cisco IOS XR - *.cisco-ios-xr - *.ios-xr
- Cisco NXOS - *.cisco-nxos - *.cisco-nexus - *.nxos
Here is a screenshot of a highlighted configuration
Completions
Configuration snippets and autocompletion are suggested based on the syntax and configuration mode.
For example, I started typing errd and it suggested the following:
Mask Conversions
type a / and the conversion window will pop up. Once you find the mask you want press [enter]
In this example, pressing [enter] will insert 255.255.255.0
You can press ctrl+space to toggle between the netmask, wildcard mask and /
Jumping
One of the greatest features, if you are working on a large configuration file, is the ability to jump to commands that enter a configuration mode. For example, to jump to "interface vlan 20" press "cmd+r" and a dialog box will appear:
You can search for more than just interfaces. Here I entered ip to find an access-list.
You can also jump to "line con" or "line vty"
Type 7 password decoding
Cisco type 7 passwords aren't hashed, they are "encoded' so they are reversible. Network Tech has a handy feature to decode them.
In a file that has a type 7 password:
- Press Shift (⇧) + Command (⌘) + p to open the command palette
- Enter "Network Tech: Decode Passwords"
You will see the passwords from the file, select the one you want to decode
In this example:
username cisco privilege 15 password 7 13061E01080355
It will ask if you want to save the password to the clipboard or display it. Here is what it looks like if you choose to display:
Listing network details
If you highlight an IP address and subnet mask, network tech list all the details for the subnet:
Reference
Compare Side-By-Side plugin
- Easily select two tabs or selections to compare
- Comparison results open in a new window
- Empty lines added so common code lines up
- Count number of lines changed
- Highlighting of changed lines
- Intra-line diff highlighting
- Synchronized scrolling
- Search for and install using Package Control (⌘+↑+P, “Install Package”)
- (Preferences -> Browse Packages)
Reference
Compare Side-By-Side
Using Regular Expressions
Replacing vlan20 with vlan 20
The () create a "capture group" that allows you to use the text it found in the replace window. The capture groups start at 1 and increment by 1.
In this example, the first capture group matches on v or V.
The second matches on digits "\d" and the {1,3} matches 1, 2 or 3 digits.
In the replace dialog, click the icon on the far left that looks like a '.*". This puts the search box in regex mode.
Replacing text from the beginning of a line
Given a file with strings like this:
01_BRAD-MDF-AdminTL-STK1-2-config-output.txt:Gi2/0/10 up up < Surv Serv 10.196.250.2 1c98.ec15.a338 >
I just wanted the text starting with < and ending with >
Regex quantifiers
Quantifier Meaning A? Match regular expression A zero or one times A* Match regular expression A zero or more times A+ Match regular expression A one or more times A{m} Match regular expression A exactly m times A{m,n} Match regular expression A between m and n times (included)
Reference
Speedtest-cli
https://github.com/sivel/speedtest-cli
Installation
Pip install speedtest-cli
speedtest-cli Retrieving speedtest.net configuration... Testing from Spectrum (71.84.93.96)... Retrieving speedtest.net server list... Selecting best server based on ping... Hosted by Cox - Orange County (Orange County, CA) [51.76 km]: 27.113 ms Testing download speed................................................................................ Download: 102.39 Mbit/s Testing upload speed...................................................................................................... Upload: 21.24 Mbit/s
Iterm2
InstallationDownload here: Iterm2
- Open the zip file.
- select "Automatically update".
- move app to applications.
- In Applications, select iTerm, right click, get info, Check "Open in Rosetta".
iterm2 documentation
Onyx
Operating system utilities for macOSOnyx Download
OnyX is a multifunction utility that you can use to verify the structure of the system files, to run miscellaneous maintenance and cleaning tasks, to configure parameters in the Finder, Dock, Safari, and some Apple applications, to delete caches, to remove certain problematic folders and files, to rebuild various databases and indexes, and more.
Download the package, move to the application folder
Ticker
Ticker - Stock ticker for the command line Ticker Github page Features Live stock price quotes Track value of your stock positions Support for multiple cost basis lots Support for pre and post market price quotes
Ticker is a fun little terminal app that lets you monitor stocks.
Installation brew install achannarasappa/tap/ticker
Ticker uses ~/.ticker.yaml for configuration. Below is the default yaml file. Put stock symbols
in the watchlist area to watch them.
If you own stocks, put them in the Lots area. It's pretty self explanatory. Put the stock symbol
after symbol:, the quantity you own after quantity and the purchase cost after unit_cost.
Then open a terminal and type ticker [enter]
# ~/.ticker.yaml show-summary: true show-tags: true show-fundamentals: true show-separator: true show-holdings: true interval: 5 currency: USD watchlist: - NET - TEAM - ESTC - BTC-USD lots: - symbol: "ABNB" quantity: 35.0 unit_cost: 146.00 - symbol: "ARKW" quantity: 20.0 unit_cost: 152.25 - symbol: "ARKW" quantity: 20.0 unit_cost: 145.35
It's a beautiful thing to be appreciated... Keep it up, thanks for sharing.
ReplyDeleteAfter looking through a few blog articles on your website,
we sincerely appreciate the way you blogged.
Text Sublime
Hubbard On Networking: Apple Macbook Air M1 For Network Engineers Part 3 >>>>> Download Now
ReplyDelete>>>>> Download Full
Hubbard On Networking: Apple Macbook Air M1 For Network Engineers Part 3 >>>>> Download LINK
>>>>> Download Now
Hubbard On Networking: Apple Macbook Air M1 For Network Engineers Part 3 >>>>> Download Full
>>>>> Download LINK eR