-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathali
More file actions
executable file
·46 lines (41 loc) · 1001 Bytes
/
ali
File metadata and controls
executable file
·46 lines (41 loc) · 1001 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
42
43
44
45
46
#!/bin/bash
# ali - populate your .bash_alias quickly
NOR='\033[0m'
RED='\033[00;31m'
GREEN='\033[00;32m'
YELLOW='\033[00;33m'
# make sure we are in the user's home folder
cd /home/$USER
# check for an existing alias file, usually .bash_alias
if [ -f /home/$USER/.bash_aliases ]
then
alifile="/home/$USER/.bash_aliases"
else
alifile="/home/$USER/.aliases"
fi
ali_new()
{
echo "-------------------------------------------"
echo -e "Adding aliases to ${GREEN}$alifile ${NOR}"
echo "-------------------------------------------"
echo -e "Enter alias name - ${YELLOW}ctrl-c to cancel${NOR} :"
read a
if grep "$a=" $alifile
then
echo -e "${RED}This alias exists, retry...${NOR}"
ali_new
else
echo "Enter command for $a:"
read b
newali="alias $a="\"$b\"
echo $newali >> $alifile
fi
read -n1 -p 'More? (Y/n) '
if [ $REPLY = 'n' ]; then
$SHELL
exit 0
fi
ali_new
}
# start routine
ali_new