Merge pull request #1413 from nwinkler/proxy-sed-fix
Make sed replacements work for both BSD and GNU sedpull/1417/head
commit
3116754a52
|
|
@ -5,6 +5,16 @@ BASH_IT_LOAD_PRIORITY_DEFAULT_PLUGIN=${BASH_IT_LOAD_PRIORITY_DEFAULT_PLUGIN:-250
|
||||||
BASH_IT_LOAD_PRIORITY_DEFAULT_COMPLETION=${BASH_IT_LOAD_PRIORITY_DEFAULT_COMPLETION:-350}
|
BASH_IT_LOAD_PRIORITY_DEFAULT_COMPLETION=${BASH_IT_LOAD_PRIORITY_DEFAULT_COMPLETION:-350}
|
||||||
BASH_IT_LOAD_PRIORITY_SEPARATOR="---"
|
BASH_IT_LOAD_PRIORITY_SEPARATOR="---"
|
||||||
|
|
||||||
|
# Handle the different ways of running `sed` without generating a backup file based on OS
|
||||||
|
# - GNU sed (Linux) uses `-i`
|
||||||
|
# - BSD sed (macOS) uses `-i ''`
|
||||||
|
# To use this in Bash-it for inline replacements with `sed`, use the following syntax:
|
||||||
|
# sed "${BASH_IT_SED_I_PARAMETERS[@]}" -e "..." file
|
||||||
|
BASH_IT_SED_I_PARAMETERS=(-i)
|
||||||
|
case "$(uname)" in
|
||||||
|
Darwin*) BASH_IT_SED_I_PARAMETERS=(-i "")
|
||||||
|
esac
|
||||||
|
|
||||||
function _command_exists ()
|
function _command_exists ()
|
||||||
{
|
{
|
||||||
_about 'checks for existence of a command'
|
_about 'checks for existence of a command'
|
||||||
|
|
|
||||||
|
|
@ -370,7 +370,7 @@ ssh-disable-proxy ()
|
||||||
group 'proxy'
|
group 'proxy'
|
||||||
|
|
||||||
if [ -f ~/.ssh/config ] ; then
|
if [ -f ~/.ssh/config ] ; then
|
||||||
sed -e's/^.*ProxyCommand/# ProxyCommand/' -i "" ~/.ssh/config
|
sed -e's/^.*ProxyCommand/# ProxyCommand/' "${BASH_IT_SED_I_PARAMETERS[@]}" ~/.ssh/config
|
||||||
echo "Disabled SSH config proxy settings"
|
echo "Disabled SSH config proxy settings"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
@ -382,7 +382,7 @@ ssh-enable-proxy ()
|
||||||
group 'proxy'
|
group 'proxy'
|
||||||
|
|
||||||
if [ -f ~/.ssh/config ] ; then
|
if [ -f ~/.ssh/config ] ; then
|
||||||
sed -e's/# ProxyCommand/ ProxyCommand/' -i "" ~/.ssh/config
|
sed -e's/# ProxyCommand/ ProxyCommand/' "${BASH_IT_SED_I_PARAMETERS[@]}" ~/.ssh/config
|
||||||
echo "Enabled SSH config proxy settings"
|
echo "Enabled SSH config proxy settings"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue