mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-04-17 04:29:14 +02:00
Adding a thing to move my hostfile around
This is a MEETUP thing, not for general consumption. This is temporary until I can make a node thing or something to replace it.
This commit is contained in:
parent
f04344dbfe
commit
7b14df9d10
1 changed files with 50 additions and 0 deletions
50
plugins/atlas/atlas.plugin.zsh
Normal file
50
plugins/atlas/atlas.plugin.zsh
Normal file
|
|
@ -0,0 +1,50 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
function atlas_usage {
|
||||||
|
cat <<-USAGE
|
||||||
|
|
||||||
|
usage: atlas command [map name]
|
||||||
|
|
||||||
|
new Create new hosts map file
|
||||||
|
init Create ~/.hosts to store host maps in
|
||||||
|
map link /etc/hosts to map supplying map name
|
||||||
|
|
||||||
|
|
||||||
|
USAGE
|
||||||
|
}
|
||||||
|
|
||||||
|
function atlas_new {
|
||||||
|
if [ -z "$1" ]; then
|
||||||
|
echo "need a name of new map";
|
||||||
|
else
|
||||||
|
touch ~/.hosts/$1;
|
||||||
|
echo "Created $1 at ~/.hosts/$1";
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function atlas_init {
|
||||||
|
if [ ! -d "/Users/nstilwell/.hosts" ]; then
|
||||||
|
mkdir /Users/nstilwell/.hosts;
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Atlas initialized";
|
||||||
|
}
|
||||||
|
|
||||||
|
function atlas_map {
|
||||||
|
if [ -d "/Users/nstilwell/.hosts" ] && [ -e "/Users/nstilwell/.hosts/$1" ]; then
|
||||||
|
sudo ln -f /Users/nstilwell/.hosts/$1 /etc/hosts;
|
||||||
|
echo "mapped ~/.hosts/$1 to /etc/hosts";
|
||||||
|
else
|
||||||
|
echo "$1 doesn't exist at ~/.hosts/$1";
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function atlas {
|
||||||
|
if [ -z "$1" ]; then
|
||||||
|
atlas_usage;
|
||||||
|
else
|
||||||
|
[ "$1" = "new" ] && atlas_new "$2";
|
||||||
|
[ "$1" = "init" ] && atlas_init;
|
||||||
|
[ "$1" = "map" ] && atlas_map "$2";
|
||||||
|
fi
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue