Archive

Archive for the ‘MAC’ Category

VI/VIM tips

August 8, 2016 Leave a comment

Following are some random tips which I found to be useful. All of them has been collected from different sites and I am just putting them together for my reference.

Most of the examples mentioned here uses the below methodology

if there is a column prefix “:”  then that indicate its the vi command mode. To do this, open the file, press “ESC” key and type “:”

If you want these changes to be permanent, then you can put these commands in a special file called “.vimrc” which is present in your home directory(/users/<username> in Linux & Mac). Create this file, if it doesnt exist.

Indentation Tips

  1.  Enabling/Disabling auto indent
    :set ai ==> To enable
    :set noai ==> to disable
  2. Disabling auto indentation while pasting a code
    :set paste        ==>To disable autoindenting while pasting
    :set nopaste   ==>To enable it back
  3. How to indent a line which you are newly pasting to the existing code block’s indentation
    use ]p instead of just p. This aligns the pasted block with the surrounding text.
  4. Code block indentation tips
    These commands will fix the indents:

    • =i{ reindents “inner block” (inside the braces).
    • =a{ reindents “a block” (including the braces).
    • =2a{ reindents 2 blocks (this block and containing block).

    Instead of “{“, you can use “}” or “B”, for example, =aB indents a block.

    These commands will decrease or increase indents:

    • >i{ increase indent for inner block.
    • . repeat last change (increase indent of block again).
    • <i{ decrease indent for inner block.

    With the cursor on { or }:

    • =% indents the block (including matching brace).
    • >% or <% indents or unindents the block.

Commenting/uncommenting multiple lines in a file
Open the file in VI and in command mode, press “ctrl+v”, now it will go in to visual mode, now move the cursor using the movement keys (arrow keys up/down), move the up/down arrow till you reach the last line you want to comment. Now press “Shift+i” and now enter the character used for commenting “#”

In Nutshell
Commenting: CTRL+v ==> SHIFT+i ==> # ==> Will insert # on the selected column
Uncommenting: CTRL+v ==> x ==> Will delete the #’s in the selected column

Advertisements
Categories: Linux, MAC, Technical

Enabling mouse scrolling in GNU screen when connecting from MAC


GNU Scren is a great tool for system administrators, as it allows to do anything on a remote server and then continue from exactly where you left later by reconnecting to the session.

But one of the most annoying issues with screen is that if you connect to a screen session and if you want to see the scrollback history, then you need to press the screen keyboard shortcut CTRL+A+]. This is annoying as most people are used to scroll up via mouse.

This is a repost from this site and it helps in overcoming the above issue in MAC’s default terminal Application. All the credits goes to the Original poster and I am just reposting that  for my own reference incase if the original site goes down/removes the content.

Typical use case of GNU Screen for me

MAC Book Pro: My Office Laptop which is connected to my corporate lan only when I am in office/VPN
Linux Server: My office server which is 24X7 up and has GNU screen running.
Network Devices: I need to have a always on telnet session to my Nexus 7000 devices, so that I can monitor whats going on with the device.

So what I normally do is from my Macbook pro, I ssh to the “Linux Server” and then start a GNU screen session by “screen -S devices”. Now from that  screen session I create multiple Tabs and connect to my network devices. So whenever I turnoff my laptop, these sessions will still be alive as the Linux server is always up. So when I reach home, I can just connect to my VPN and then again connect back to the screen session by typing “screen -x devices”.

This is exactly like you run a vnc on the Linux server and then open xterms to the network devices from the vnc session. The advantage of screen over vnc is that screen is really fast and is very good in low speed internet connections.

GNU screen takes all its setting from a .screenrc file which is in your home directory of the Linux server. To enable this tip add the below lines to your .screenrc file

defscrollback 5000
termcapinfo xterm* ti@:te@

Once done, save the file and connect to the screen session from Terminal app and now you can use your mouse scroll up gesture to see the scrollback history.

Note: This trick works only if you are using the default “Terminal” App in the Mac. If you use another app like “iTerm2”, then this tip doesnt work. There is an open bug with iterm2 for this and you need to wait for that to get resolved. Click on this link to see the bug.

 

Categories: MAC

Enabling middle button paste in real vnc for MAC


If you are used to vnc to a linux machine using the real vnc viewer for MAC, then for sure you have faced this big question, How do I paste the clipboard content to the xterm window over vnc. I have googled a lot and was not able to find a good solution. Finally I got a great solution from my company’s internal mac-wiki and thought of sharing the same so that others can benefit out of it

Best free VNC viewers for MAC

Before we start of with the tip, lets see some of the free vnc viewers for MAC

1. Real VNC  (Free)

2. Chicken VNC (Free)

3. Jolly fast VNC (trial version can be renewed multiple times)

I have tried all the above 3 and I personally like real vnc the most for being the fastest of all the above 3. besides thats its free which makes it the best. Only problem with real vnc is that pasting the clipboard content over vnc may not work for some applications if you are vncing to linux. One such example is xterm. Xterm doesnt give the option of Paste in the right click context menu. Generally mouse middle button is the shortcut to paste in xterm which doesnt work through MAC.

On the other hand chicken VNC allows to modify the keyboard mappings to work around the above issue which is discussed above. But chiken vnc is very slow compared to real vnc. You will feel the difference when your internet connection speed is very less. In Chicken vnc, you can emulate middle button paste via Option+click on trackpad by changing the below setting

“Go to Connection Menu and select the Connection Profiles: –>Emulation” and change to below

Cotvnc-profile-dialog

Emulating middle button mouse click in Real VNC

As mentioned above, I prefer Real VNC over others and I needed a solution for middle button mouse click. There came the app called middleclick to your rescue.

Run a small app called middleclick (http://clement.beffa.org/labs/projects/middleclick/). This allows you to emulate the middle button mouse click on a Mac book Pro with a three-finger touch. Then in realVnc options, enable the three-button emulation mode. Once you have this set up, you will be able to cmd-c in your mac and three-finger tap in vnc to paste.

Also do the follwoing as well Go to System Preferences -> Trackpad and uncheck “Look up”

Categories: MAC

Configuring ZTE AC2738 3G modem on MAC OS X 10.9.3

May 31, 2014 34 comments

I have recently got  a Mac book Pro and was trying to connect to internet through my Reliance Netconnect Dongle. Since I am new to Mac and since the Reliance software doesnt work on the New Mavericks OS, i had a difficult time trying to configure it up. This post helps in configuring the same.

Note: After I wrote this post, there have been numerous MAC OS updates which came in that can cause the below hack to not work. So please note down the bottom of this page, if you are running the latest MAC OS.

Reliance Netconnect 3g dongle which I am using was a ZTE AC2738 model and this post is mainly for that though it may be applicable for other 3g dongles provided you have the driver for the same.

Issue: Reliance Netconnect provides MAC drivers and dialer software, but the dialer software doesn’t work on OS X Mavericks version, Which is what this post is trying to solve

Solution: Mac supports inbuilt dialer software and this post is basically making use of that to get connected. But this works only if the driver for the 3G modem is successfully installed

Step by Step guide

  1. Connect Reliance connect to the USB port of the MAC
  2. Automatically a virtual CD drive will appear and open the zip file corresponding to mac installer and follow the instructions.
    Note: You can download the MAC driver package directly from my dropbox link as well. Dropbox link
  3. Double click the installer and follow the installation process until complete.
  4. Once installed you will have a “Reliance Netconnect+” icon in your desktop. This is the dialer and its of no use. So you can move it to trash.
  5. Now open “Network Preferences page” from system Preferences->Network
  6. There on the left pane you will be able to see some new entries corresponding to “ZTE”
  7. Select the ZTE Wireless Terminal in that list and put the below info
    Telephone Number: #777
    Account Name: net
    Password: net
  8. Keep the Other values as it is and click on apply and select connect. Once connected you should be able to browse.

ZTE 2738 on MAC

 

 

 

 

 

 

 

Maverick users for whom the above hack didnt work or the dongle stopped working after getting updates.

Courtesy: The below hack is originally provided by ruchirs in the apple community and I am posting it here. Original thread can be found at Apple community thread for Mavericks

Solution: 

  1. Go to network preferences
  2. Lookup ZTE wireless terminal
  3. enter on right side: telephone no as #777
  4. account name and password as your dongles mobile number.
  5. and click connect!!.

Elcapitan users for whom the Dongle stopped working after upgrade.

Courtesy: The below hack is originally provided by rochishnudutta in the apple community and I am posting it here. Original thread can be found at Apple Community thread for Elcapitan . Also special thanks to Anuj Gupta who mentioned the same in the comments.

Solution:

  1. Boot into Mac by pressing CMD + R (Recovery Mode)
  2. Go to Terminal under Utilities.
  3. Type in csrutil disable. A comment will be displayed that your csrutil has been disabled.
  4. Reboot
  5.  Install the driver as usual and it will require a reboot again.
  6. Then go to network preference. Fill in all details (account and password) by selecting the driver name (in my case, ZTE Wireless Terminal) on the left panel. Save it and connect.
Categories: Gadgets, MAC