-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlinkalias.sh
More file actions
executable file
·41 lines (37 loc) · 1002 Bytes
/
Copy pathlinkalias.sh
File metadata and controls
executable file
·41 lines (37 loc) · 1002 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/bash
current_file=`basename "$0"`
#install the script if it has not already been installed
if [ -e /usr/bin/$current_file ]
then
#if an identifier was not passed
if [ -z $2 ]
then
echo "linkalias aliasName to 'command here'"
echo "linkalias aliasName = 'command here'"
exit
fi
else
sudo cp $current_file /usr/bin/linkalias
echo "linkalias now installed"
fi
#perform operation if the correct argument was passed
if [ "$2" == "to" ] || [ "$2" == "=" ]
then
#ensure that the last needed argument was passed too
if [ -z $3 ]
then
echo "A correct identifier needs to be passed"
echo "linkalias aliasName to 'command here'"
echo "linkalias aliasName = 'command here'"
exit
else
output="alias $1='$3' # => added by linkalias"
echo ""$output >> ~/.bashrc
echo "$1 now added as a permanent alias!!"
exec $BASH
fi
else
echo "A correct identifier needs to be passed"
echo "linkalias aliasName to 'command here'"
echo "linkalias aliasName = 'command here'"
fi