Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

64 lines (47 sloc) 2.499 kb
I wrote a wrapper script around nmcli because I found it horrible to use to actually connect to anything with.
It allows you to quickly search for and connect to a NetworkManager profile from the CLI without worrying about UUIDs or other assorted carp.
It's a huge time saver for me, and you don't have to be in X to use it.
You'll need Bash 4.0 or higher.
I must thank the ABS guide that I always find to be a tremendously useful reference while writing in bash: http://tldp.org/LDP/abs/html/abs-guide.html
Copyright 2011 Trevor Joynson
License: GPLv3
Installation:
1. Copy nmconnect and symlinks somewhere in your PATH.
$ cd "$HOME/.bin"
$ cp -av /path/to/this/folder/{nmconnect,vpn,lan,wlan} ./
What the commands do:
nmconnect - works on the full connection list
vpn - automatically adds type=vpn to the search, so "vpn AwesomeCo" is the same as running "nmconnect type=vpn AwesomeCo"
lan/wlan - same ideology as vpn
Examples:
## List all connections
$ nmconnect
[*]
0. "Auto eth0" (type="802-3-ethernet", uuid="guid-guid-guid-guid-guid")
1. "Auto ILoveSSIDBeacons" (type="802-11-wireless", uuid="guid-guid-guid-guid-guid")
3. "AwesomeCo" (type="vpn", uuid="guid-guid-guid-guid-guid")
## Search all connections for "auto" (search params are case insensitive)
$ nmconnect auto
[search=auto]
0. "Auto eth0" (type="802-3-ethernet", uuid="guid-guid-guid-guid-guid")
1. "Auto ILoveSSIDBeacons" (type="802-11-wireless", uuid="guid-guid-guid-guid-guid")
## The vpn/lan/wlan commands are merely shortcuts, as is shown by the search params (the first line it prints; in the [brackets])
## "vpn AwesomeCo" and "nmconnect type=vpn awesomeco" are synonymous.
$ vpn
[type=vpn] ## <-- SEARCH PARAMS
3. "AwesomeCo" (type="vpn", uuid="guid-guid-guid-guid-guid")
$ nmconnect type=vpn
[type=vpn]
3. "AwesomeCo" (type="vpn", uuid="guid-guid-guid-guid-guid")
## If you narrow it down to a single result, it asks you if you wish to connect to it.
## The default, as shown by the capital Y, is to connect, so just hit enter and it will connect you.
## If you don't wish to connect, either ctrl+c or type n<enter> and it won't.
$ vpn awesome
[type=vpn search=awesome]
3. "AwesomeCo" (type="vpn", uuid="guid-guid-guid-guid-guid")
--> Start connection to: "AwesomeCo"? [Y/n]
### Another example by narrowing down to the connection number
$ vpn 3
[type=vpn search=3]
3. "AWESOMEco" (type="vpn", uuid="guid-guid-guid-guid-guid")
--> Start connection to: "AwesomeCo"? [Y/n]
Jump to Line
Something went wrong with that request. Please try again.