mirror of
https://github.com/dustinkirkland/byobu
synced 2025-08-21 22:13:19 -07:00
* screen-launcher-install: test executability of screen-launcher; install to
.profile unconditionally, and only .bash_profile and .bash_login if they exist; LP: #319691 * screen-launcher-uninstall: test writability of file to prune; prune from .profile, .bash_profile, and .bash_login
This commit is contained in:
parent
554819558d
commit
80b0965ce5
2 changed files with 19 additions and 7 deletions
|
@ -22,6 +22,7 @@
|
|||
install_screen_launcher() {
|
||||
dest=$1
|
||||
launcher="/usr/bin/screen-launcher"
|
||||
launcher_line="[ -x $launcher ] && $launcher"
|
||||
# We have to make sure screen is called last
|
||||
pos=$(( $(grep -ns "$launcher" "$dest" | sed 's/:.*$//' | head -1) ))
|
||||
do=0
|
||||
|
@ -29,7 +30,7 @@ install_screen_launcher() {
|
|||
if [ $pos -lt $(( $(wc -l "$dest" | sed "s/ .*$//") -2)) ]; then
|
||||
# We have to reposition the line at the end
|
||||
# First remove it
|
||||
sed -ibak '/screen-launcher/d' "$dest"
|
||||
sed -i '/\/usr\/bin\/screen-launcher$/d' "$dest"
|
||||
do=1
|
||||
fi
|
||||
else
|
||||
|
@ -37,9 +38,17 @@ install_screen_launcher() {
|
|||
fi
|
||||
# Add it at the end
|
||||
if [ $do -eq 1 ]; then
|
||||
echo "$launcher" >> "$dest"
|
||||
echo "$launcher_line" >> "$dest"
|
||||
fi
|
||||
}
|
||||
|
||||
install_screen_launcher "$HOME/.bashrc"
|
||||
install_screen_launcher "$HOME/.bash_profile"
|
||||
# Install in ~/.profile unconditionally
|
||||
install_screen_launcher "$HOME/.profile"
|
||||
|
||||
# Now, install in any shell-specific profiles, if they exist
|
||||
# This list may grow to support other shells
|
||||
for i in ".bash_profile" ".bash_login"; do
|
||||
if [ -w "$HOME/$i" ]; then
|
||||
install_screen_launcher "$HOME/$i"
|
||||
fi
|
||||
done
|
||||
|
|
|
@ -21,8 +21,11 @@
|
|||
|
||||
remove_screen_launcher() {
|
||||
dest=$1
|
||||
sed -ibak '/^\/usr\/bin\/screen-launcher$/d' "$dest"
|
||||
if [ -w "$dest" ]; then
|
||||
sed -i '/\/usr\/bin\/screen-launcher$/d' "$dest"
|
||||
fi
|
||||
}
|
||||
|
||||
remove_screen_launcher "$HOME/.bashrc"
|
||||
remove_screen_launcher "$HOME/.bash_profile"
|
||||
for i in ".profile" ".bashrc" ".bash_profile"; do
|
||||
remove_screen_launcher "$HOME/$i"
|
||||
done
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue