|
1 | | -# AmigaAssign |
2 | | -A bash script to provide Amiga style assign command. |
3 | | - |
4 | | -# What is this thing |
5 | | -This script adds an Amiga like ASSIGN command to Linux (using a bash script). |
6 | | -It allows paths to be referenced by a short, convenient name instead of the |
| 1 | +# AmigaAssign |
| 2 | +A bash script to provide Amiga style assign command to Linux. |
| 3 | + |
| 4 | +# What is this thing |
| 5 | +This script adds an Amiga like ASSIGN command to Linux (using a bash script). |
| 6 | +It allows paths to be referenced by a short, convenient name instead of the |
7 | 7 | full path string. It is like an alias for paths instead of commands. |
8 | 8 |
|
9 | | -A quick example. |
10 | | - |
11 | | -```bash |
| 9 | +A quick example. |
| 10 | + |
| 11 | +```bash |
12 | 12 | /home/user$ assign docroot /var/www/html |
13 | 13 | /home/user$ ls $docroot |
14 | 14 | index.html |
15 | 15 | /home/user$ cp website.html $docroot |
16 | | -/home/user$ chmod a+r $docroot/website.html |
17 | | -``` |
18 | | - |
19 | | -# History |
20 | | -A long time ago there was this computer call the Amiga. On the Amiga you |
21 | | -accessed different drives using a name followed by a colon (:). This is |
22 | | -similar to how Windows uses a letter followed by a colon (for example "C:"). |
23 | | -On the Amiga drives where not limited to a single letter but used a name. |
| 16 | +/home/user$ chmod a+r $docroot/website.html |
| 17 | +``` |
| 18 | + |
| 19 | +# History |
| 20 | +A long time ago there was this computer call the Amiga. On the Amiga you |
| 21 | +accessed different drives using a name followed by a colon (:). This is |
| 22 | +similar to how Windows uses a letter followed by a colon (for example "C:"). |
| 23 | +On the Amiga drives where not limited to a single letter but used a name. |
24 | 24 | For example DF0: was the first disk drive. |
25 | 25 |
|
26 | | -The interesting thing was you could also make up new device names and set |
27 | | -them a path on another drive. So for example you could setup WORK: to be |
28 | | -on HD0:MyWork/Current. You could then access it using commands like |
29 | | -"dir WORK:" or "copy file WORK:new_name". This was done with the assign |
| 26 | +The interesting thing was you could also make up new device names and set |
| 27 | +them a path on another drive. So for example you could setup WORK: to be |
| 28 | +on HD0:MyWork/Current. You could then access it using commands like |
| 29 | +"dir WORK:" or "copy file WORK:new_name". This was done with the assign |
30 | 30 | command. |
31 | 31 |
|
32 | | -This is something like it for the bash shell. It adds an assign command |
33 | | -that you "assign" a path name to a bash variable that can then be used |
34 | | -as a shortcut for that path. |
35 | | - |
36 | | -# How to install |
37 | | -Take the "bash_assigncmd" script and copy it to your home directory |
38 | | -under the name ".bash_assigncmd" (cp bash_assigncmd ~/.bash_assigncmd). |
39 | | -Next source this script from one of your bash startup scripts. |
40 | | -I suggest adding it to your .bashrc file (add the line |
41 | | -"source ~/.bash_assigncmd"). |
42 | | - |
43 | | -Run this command to add the line. |
44 | | -```bash |
45 | | -echo "source ~/.bash_assigncmd" >>~/.bashrc |
46 | | -``` |
47 | | - |
48 | | -# Usage |
49 | | -After you have installed the assign command and source it |
50 | | -(but typing ~/.bash_assigncmd or opening a new term window) you |
51 | | -can start using it. |
52 | | - |
53 | | -``` |
| 32 | +This is something like it for the bash shell. It adds an assign command |
| 33 | +that you "assign" a path name to a bash variable that can then be used |
| 34 | +as a shortcut for that path. |
| 35 | + |
| 36 | +# How to install |
| 37 | +Take the "bash_assigncmd" script and copy it to your home directory |
| 38 | +under the name ".bash_assigncmd" (cp bash_assigncmd ~/.bash_assigncmd). |
| 39 | +Next source this script from one of your bash startup scripts. |
| 40 | +I suggest adding it to your .bashrc file (add the line |
| 41 | +"source ~/.bash_assigncmd"). |
| 42 | + |
| 43 | +Run this command to add the line. |
| 44 | +```bash |
| 45 | +echo "source ~/.bash_assigncmd" >>~/.bashrc |
| 46 | +``` |
| 47 | + |
| 48 | +# Usage |
| 49 | +After you have installed the assign command and source it |
| 50 | +(but typing ~/.bash_assigncmd or opening a new term window) you |
| 51 | +can start using it. |
| 52 | + |
| 53 | +``` |
54 | 54 | Usage: |
55 | 55 | assign [OPTIONS] var [path] |
56 | 56 |
|
57 | 57 | Options: |
58 | | - -d -- Delete assignment |
59 | | -``` |
60 | | - |
61 | | -# Adding a new assign |
62 | | -To add a new assignment the first argument is the new assignment name |
63 | | -you want to add. This is a bash variable and has the same rules that all |
64 | | -bash variables have. The second argument is the path you want to assign |
| 58 | + -d -- Delete assignment |
| 59 | +``` |
| 60 | + |
| 61 | +# Adding a new assign |
| 62 | +To add a new assignment the first argument is the new assignment name |
| 63 | +you want to add. This is a bash variable and has the same rules that all |
| 64 | +bash variables have. The second argument is the path you want to assign |
65 | 65 | to this variable. |
66 | 66 |
|
67 | | -So for example "assign test /home/user/test" is the same |
68 | | -as "export test=/home/user/test". The difference between exporting |
69 | | -the var and using the assign command is that the assign command |
70 | | -remembers the var between sessions (and is also available to all |
71 | | -future sessions). |
72 | | - |
73 | | -## Add examples |
74 | | -Here are some examples of adding vars using assign. |
75 | | - |
76 | | -Example | Use | Expands to |
| 67 | +So for example "assign test /home/user/test" is the same |
| 68 | +as "export test=/home/user/test". The difference between exporting |
| 69 | +the var and using the assign command is that the assign command |
| 70 | +remembers the var between sessions (and is also available to all |
| 71 | +future sessions). |
| 72 | + |
| 73 | +## Add examples |
| 74 | +Here are some examples of adding vars using assign. |
| 75 | + |
| 76 | +Example | Use | Expands to |
77 | 77 | --------------------------------- | ------------------------------------- | ----------------------------------------------- |
78 | 78 | `assign c /` | `ls $c` | `ls /` |
79 | 79 | `assign doc /home/user/Documents` | `cp instructions.pdf $doc` | `cp instructions.pdf /home/user/Documents` |
80 | 80 | `assign down ~/Downloads` | `cat $down/AscIITable.txt` | `cat ~/Downloads/AscIITable.txt` |
81 | 81 | `assign docroot /var/www/html` | `chmod 777 $docroot/site1/index.html` | `chmod 777 /var/www/html/site1/index.html` |
82 | | - |
| 82 | + |
83 | 83 | ## Deleting an assignment |
84 | 84 | You delete an assignment using the -d option followed by the assignment to delete. It will be freed from this point on. |
85 | 85 |
|
|
0 commit comments