-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·34 lines (26 loc) · 1.16 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·34 lines (26 loc) · 1.16 KB
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
#!/usr/bin/env bash
set -e
shell_cfg_file="$HOME/.bashrc"
latest_release_file=https://github.com/andriykrefer/cdsurfer/releases/latest/download/cd-surfer_linux_amd64
fname="cd-surfer"
echo "Downloading latest release..."
rm -rf /tmp/$fname
wget -q -O /tmp/$fname $latest_release_file -O /tmp/$fname
echo "Installing in /bin/${fname}"
sudo chmod 755 /tmp/$fname
sudo mv /tmp/$fname /bin/
# Make a backup .bashrc
cp ${shell_cfg_file} "$shell_cfg_file.bk"
# Remove old config
sed '/# cd-surfer/d' "$shell_cfg_file.bk" > ${shell_cfg_file}
# Add config
printf 'function cds { # cd-surfer\n' >> ${shell_cfg_file}
printf ' eval "$(/bin/cd-surfer "$@")" # cd-surfer\n' >> ${shell_cfg_file}
printf '} # cd-surfer\n' >> ${shell_cfg_file}
# Reload the current shell
source $shell_cfg_file
echo "*************************************************************"
echo "* cd-surfer installed succcesfully! *"
echo "* Restart open terminals to take effect *"
echo "* Enter the command 'cds' in the terminal to call cd-surfer *"
echo "*************************************************************"