How to have script detect if terminal emulator is running in a desktop session or not?
![Creative The name of the picture](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgO9GURib1T8z7lCwjOGLQaGtrueEthgQ8LO42ZX8cOfTqDK4jvDDpKkLFwf2J49kYCMNW7d4ABih_XCb_2UXdq5fPJDkoyg7-8g_YfRUot-XnaXkNYycsNp7lA5_TW9td0FFpLQ2APzKcZ/s1600/1.jpg)
![Creative The name of the picture](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYQ0N5W1qAOxLP7t7iOM6O6AzbZnkXUy16s7P_CWfOb5UbTQY_aDsc727chyphenhyphen5W4IppVNernMMQeaUFTB_rFzAd95_CDt-tnwN-nBx6JyUp2duGjPaL5-VgNO41AVsA_vu30EJcipdDG409/s400/Clash+Royale+CLAN+TAG%2523URR8PPP.png)
up vote
10
down vote
favorite
I have scripts I run that write out a text file, then open it in an editor. If I open a terminal emulator window in my desktop session and run the script, I'd like the editor to be a graphical one such as gedit
. But, if I'm logged in through ConnectBot on my phone or similar (no desktop session), I'd like the editor to be nano
.
Currently I have to maintain 2 different scripts, identical except for the last step (or let the graphical one run, error off, then manually open the file in nano
). Having two mostly identical scripts is inefficient from a maintenance standpoint.
Can a script detect which of these situations I'm in, and open the correct editor?
(I have found ways for a script to detect whether it's running in a terminal emulator window or by being double-clicked, but not yet found a way to detect if the window is running in a desktop...I don't think I know the correct terminology to google for)
scripts desktop-environments virtual-console
add a comment |Â
up vote
10
down vote
favorite
I have scripts I run that write out a text file, then open it in an editor. If I open a terminal emulator window in my desktop session and run the script, I'd like the editor to be a graphical one such as gedit
. But, if I'm logged in through ConnectBot on my phone or similar (no desktop session), I'd like the editor to be nano
.
Currently I have to maintain 2 different scripts, identical except for the last step (or let the graphical one run, error off, then manually open the file in nano
). Having two mostly identical scripts is inefficient from a maintenance standpoint.
Can a script detect which of these situations I'm in, and open the correct editor?
(I have found ways for a script to detect whether it's running in a terminal emulator window or by being double-clicked, but not yet found a way to detect if the window is running in a desktop...I don't think I know the correct terminology to google for)
scripts desktop-environments virtual-console
6
If your script is for use by other people you should use the program specified by$EDITOR
by default instead ofnano
, and fallback onnano
if it is not set.
â Bakuriu
May 21 at 17:42
Thanks, great advice, and it's great to hear what is good practice. Just me though.
â Organic Marble
May 21 at 17:42
add a comment |Â
up vote
10
down vote
favorite
up vote
10
down vote
favorite
I have scripts I run that write out a text file, then open it in an editor. If I open a terminal emulator window in my desktop session and run the script, I'd like the editor to be a graphical one such as gedit
. But, if I'm logged in through ConnectBot on my phone or similar (no desktop session), I'd like the editor to be nano
.
Currently I have to maintain 2 different scripts, identical except for the last step (or let the graphical one run, error off, then manually open the file in nano
). Having two mostly identical scripts is inefficient from a maintenance standpoint.
Can a script detect which of these situations I'm in, and open the correct editor?
(I have found ways for a script to detect whether it's running in a terminal emulator window or by being double-clicked, but not yet found a way to detect if the window is running in a desktop...I don't think I know the correct terminology to google for)
scripts desktop-environments virtual-console
I have scripts I run that write out a text file, then open it in an editor. If I open a terminal emulator window in my desktop session and run the script, I'd like the editor to be a graphical one such as gedit
. But, if I'm logged in through ConnectBot on my phone or similar (no desktop session), I'd like the editor to be nano
.
Currently I have to maintain 2 different scripts, identical except for the last step (or let the graphical one run, error off, then manually open the file in nano
). Having two mostly identical scripts is inefficient from a maintenance standpoint.
Can a script detect which of these situations I'm in, and open the correct editor?
(I have found ways for a script to detect whether it's running in a terminal emulator window or by being double-clicked, but not yet found a way to detect if the window is running in a desktop...I don't think I know the correct terminology to google for)
scripts desktop-environments virtual-console
asked May 21 at 12:10
![](https://i.stack.imgur.com/DbsU5.jpg?s=32&g=1)
![](https://i.stack.imgur.com/DbsU5.jpg?s=32&g=1)
Organic Marble
9,65763053
9,65763053
6
If your script is for use by other people you should use the program specified by$EDITOR
by default instead ofnano
, and fallback onnano
if it is not set.
â Bakuriu
May 21 at 17:42
Thanks, great advice, and it's great to hear what is good practice. Just me though.
â Organic Marble
May 21 at 17:42
add a comment |Â
6
If your script is for use by other people you should use the program specified by$EDITOR
by default instead ofnano
, and fallback onnano
if it is not set.
â Bakuriu
May 21 at 17:42
Thanks, great advice, and it's great to hear what is good practice. Just me though.
â Organic Marble
May 21 at 17:42
6
6
If your script is for use by other people you should use the program specified by
$EDITOR
by default instead of nano
, and fallback on nano
if it is not set.â Bakuriu
May 21 at 17:42
If your script is for use by other people you should use the program specified by
$EDITOR
by default instead of nano
, and fallback on nano
if it is not set.â Bakuriu
May 21 at 17:42
Thanks, great advice, and it's great to hear what is good practice. Just me though.
â Organic Marble
May 21 at 17:42
Thanks, great advice, and it's great to hear what is good practice. Just me though.
â Organic Marble
May 21 at 17:42
add a comment |Â
3 Answers
3
active
oldest
votes
up vote
13
down vote
accepted
You can use the environment variable $DISPLAY
as trigger within a if
condition. Usually when this variable has a value you are able to run graphical applications.
Here is a bash example:
if [[ -z $DISPLAY ]]
then
nano
else
gedit
fi
The operator -z
will return true when the envvar $DISPLAY
is empty and your script will run nano
, in all other cases it will run gedit
.
According to the this comment of @vurp0:
On most modern Wayland desktops (like the default desktop in Fedora
and Ubuntu),$DISPLAY
is still set due to backwards compatibility
(through XWayland), but for a more robust script it would be good to
test for both$DISPLAY
and$WAYLAND_DISPLAY
to be sure.
I would suggest to modify the test expression in the following way:
[[ -z $DISPLAY$WAYLAND_DISPLAY ]]
Thus, the values of the two variables will be concatenated into a common string, which will be processed by the operator -z
.
References:
- Advanced Bash-Scripting Guide: 7. Tests
- Advanced Bash-Scripting Guide: 7.1. Test Constructs
- Advanced Bash-Scripting Guide: 7.3. Other Comparison Operators
1
Or for explicit logic:[[ -z $DISPLAY && -z $WAYLAND_DISPLAY ]]
â Dennis Williamson
May 21 at 21:00
add a comment |Â
up vote
7
down vote
Typically virtual terminals use /dev/pts
pseudo-terminals. So, based on the output of tty
command, we can build a simple case
statement to handle opening particular editor:
case "$(tty)" in ; "/dev/pts"*) nano ;; "/dev/tty"*) gedit ;; ;esac
Or formatted more nicely:
case "$(tty)" in
"/dev/pts"*) gedit ;;
"/dev/tty"*) nano ;;
*) echo "Not suitable tty" > /dev/stderr ;;
esac
Compared to using environment variables, this is slightly more reliable and considering it uses case
statement with tty
command slightly more portable. What probably would be best is to combine both, with extra testing, such as "/dev/tty"*) [ -n "$DISPLAY" ] && gedit ;;
Isn't this the wrong way around? On my Ctrl+Alt+F1 console,tty
gives/dev/tty1
, whereasgnome-terminal
(first tab) gives/dev/pts/0
.
â Paddy Landau
May 29 at 11:25
@PaddyLandau Yes,gedit
should be in/dev/pts*
case. I switched them around while error testing in tty and ended up copying it here without switching back. Thanks, edited already.
â Sergiy Kolodyazhnyy
May 29 at 14:40
add a comment |Â
up vote
3
down vote
This is what I've been using:
# $TERM variable may be missing when called via desktop shortcut
CurrentTERM=$(env | grep TERM)
if [[ $CurrentTERM == "" ]] ; then
notify-send --urgency=critical "$0 cannot be run from GUI without TERM environment variable."
exit 1
fi
The reason for this code was this question: Desktop shortcut to Bash script crashes and burns
You can modify it to look like this:
# $TERM variable may be missing when called via desktop shortcut
CurrentTERM=$(env | grep TERM)
if [[ $CurrentTERM == "" ]] ; then
nano ...
else
gedit ...
fi
add a comment |Â
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
13
down vote
accepted
You can use the environment variable $DISPLAY
as trigger within a if
condition. Usually when this variable has a value you are able to run graphical applications.
Here is a bash example:
if [[ -z $DISPLAY ]]
then
nano
else
gedit
fi
The operator -z
will return true when the envvar $DISPLAY
is empty and your script will run nano
, in all other cases it will run gedit
.
According to the this comment of @vurp0:
On most modern Wayland desktops (like the default desktop in Fedora
and Ubuntu),$DISPLAY
is still set due to backwards compatibility
(through XWayland), but for a more robust script it would be good to
test for both$DISPLAY
and$WAYLAND_DISPLAY
to be sure.
I would suggest to modify the test expression in the following way:
[[ -z $DISPLAY$WAYLAND_DISPLAY ]]
Thus, the values of the two variables will be concatenated into a common string, which will be processed by the operator -z
.
References:
- Advanced Bash-Scripting Guide: 7. Tests
- Advanced Bash-Scripting Guide: 7.1. Test Constructs
- Advanced Bash-Scripting Guide: 7.3. Other Comparison Operators
1
Or for explicit logic:[[ -z $DISPLAY && -z $WAYLAND_DISPLAY ]]
â Dennis Williamson
May 21 at 21:00
add a comment |Â
up vote
13
down vote
accepted
You can use the environment variable $DISPLAY
as trigger within a if
condition. Usually when this variable has a value you are able to run graphical applications.
Here is a bash example:
if [[ -z $DISPLAY ]]
then
nano
else
gedit
fi
The operator -z
will return true when the envvar $DISPLAY
is empty and your script will run nano
, in all other cases it will run gedit
.
According to the this comment of @vurp0:
On most modern Wayland desktops (like the default desktop in Fedora
and Ubuntu),$DISPLAY
is still set due to backwards compatibility
(through XWayland), but for a more robust script it would be good to
test for both$DISPLAY
and$WAYLAND_DISPLAY
to be sure.
I would suggest to modify the test expression in the following way:
[[ -z $DISPLAY$WAYLAND_DISPLAY ]]
Thus, the values of the two variables will be concatenated into a common string, which will be processed by the operator -z
.
References:
- Advanced Bash-Scripting Guide: 7. Tests
- Advanced Bash-Scripting Guide: 7.1. Test Constructs
- Advanced Bash-Scripting Guide: 7.3. Other Comparison Operators
1
Or for explicit logic:[[ -z $DISPLAY && -z $WAYLAND_DISPLAY ]]
â Dennis Williamson
May 21 at 21:00
add a comment |Â
up vote
13
down vote
accepted
up vote
13
down vote
accepted
You can use the environment variable $DISPLAY
as trigger within a if
condition. Usually when this variable has a value you are able to run graphical applications.
Here is a bash example:
if [[ -z $DISPLAY ]]
then
nano
else
gedit
fi
The operator -z
will return true when the envvar $DISPLAY
is empty and your script will run nano
, in all other cases it will run gedit
.
According to the this comment of @vurp0:
On most modern Wayland desktops (like the default desktop in Fedora
and Ubuntu),$DISPLAY
is still set due to backwards compatibility
(through XWayland), but for a more robust script it would be good to
test for both$DISPLAY
and$WAYLAND_DISPLAY
to be sure.
I would suggest to modify the test expression in the following way:
[[ -z $DISPLAY$WAYLAND_DISPLAY ]]
Thus, the values of the two variables will be concatenated into a common string, which will be processed by the operator -z
.
References:
- Advanced Bash-Scripting Guide: 7. Tests
- Advanced Bash-Scripting Guide: 7.1. Test Constructs
- Advanced Bash-Scripting Guide: 7.3. Other Comparison Operators
You can use the environment variable $DISPLAY
as trigger within a if
condition. Usually when this variable has a value you are able to run graphical applications.
Here is a bash example:
if [[ -z $DISPLAY ]]
then
nano
else
gedit
fi
The operator -z
will return true when the envvar $DISPLAY
is empty and your script will run nano
, in all other cases it will run gedit
.
According to the this comment of @vurp0:
On most modern Wayland desktops (like the default desktop in Fedora
and Ubuntu),$DISPLAY
is still set due to backwards compatibility
(through XWayland), but for a more robust script it would be good to
test for both$DISPLAY
and$WAYLAND_DISPLAY
to be sure.
I would suggest to modify the test expression in the following way:
[[ -z $DISPLAY$WAYLAND_DISPLAY ]]
Thus, the values of the two variables will be concatenated into a common string, which will be processed by the operator -z
.
References:
- Advanced Bash-Scripting Guide: 7. Tests
- Advanced Bash-Scripting Guide: 7.1. Test Constructs
- Advanced Bash-Scripting Guide: 7.3. Other Comparison Operators
edited May 21 at 18:57
answered May 21 at 12:28
![](https://i.stack.imgur.com/Lrlbx.jpg?s=32&g=1)
![](https://i.stack.imgur.com/Lrlbx.jpg?s=32&g=1)
pa4080
11.8k52255
11.8k52255
1
Or for explicit logic:[[ -z $DISPLAY && -z $WAYLAND_DISPLAY ]]
â Dennis Williamson
May 21 at 21:00
add a comment |Â
1
Or for explicit logic:[[ -z $DISPLAY && -z $WAYLAND_DISPLAY ]]
â Dennis Williamson
May 21 at 21:00
1
1
Or for explicit logic:
[[ -z $DISPLAY && -z $WAYLAND_DISPLAY ]]
â Dennis Williamson
May 21 at 21:00
Or for explicit logic:
[[ -z $DISPLAY && -z $WAYLAND_DISPLAY ]]
â Dennis Williamson
May 21 at 21:00
add a comment |Â
up vote
7
down vote
Typically virtual terminals use /dev/pts
pseudo-terminals. So, based on the output of tty
command, we can build a simple case
statement to handle opening particular editor:
case "$(tty)" in ; "/dev/pts"*) nano ;; "/dev/tty"*) gedit ;; ;esac
Or formatted more nicely:
case "$(tty)" in
"/dev/pts"*) gedit ;;
"/dev/tty"*) nano ;;
*) echo "Not suitable tty" > /dev/stderr ;;
esac
Compared to using environment variables, this is slightly more reliable and considering it uses case
statement with tty
command slightly more portable. What probably would be best is to combine both, with extra testing, such as "/dev/tty"*) [ -n "$DISPLAY" ] && gedit ;;
Isn't this the wrong way around? On my Ctrl+Alt+F1 console,tty
gives/dev/tty1
, whereasgnome-terminal
(first tab) gives/dev/pts/0
.
â Paddy Landau
May 29 at 11:25
@PaddyLandau Yes,gedit
should be in/dev/pts*
case. I switched them around while error testing in tty and ended up copying it here without switching back. Thanks, edited already.
â Sergiy Kolodyazhnyy
May 29 at 14:40
add a comment |Â
up vote
7
down vote
Typically virtual terminals use /dev/pts
pseudo-terminals. So, based on the output of tty
command, we can build a simple case
statement to handle opening particular editor:
case "$(tty)" in ; "/dev/pts"*) nano ;; "/dev/tty"*) gedit ;; ;esac
Or formatted more nicely:
case "$(tty)" in
"/dev/pts"*) gedit ;;
"/dev/tty"*) nano ;;
*) echo "Not suitable tty" > /dev/stderr ;;
esac
Compared to using environment variables, this is slightly more reliable and considering it uses case
statement with tty
command slightly more portable. What probably would be best is to combine both, with extra testing, such as "/dev/tty"*) [ -n "$DISPLAY" ] && gedit ;;
Isn't this the wrong way around? On my Ctrl+Alt+F1 console,tty
gives/dev/tty1
, whereasgnome-terminal
(first tab) gives/dev/pts/0
.
â Paddy Landau
May 29 at 11:25
@PaddyLandau Yes,gedit
should be in/dev/pts*
case. I switched them around while error testing in tty and ended up copying it here without switching back. Thanks, edited already.
â Sergiy Kolodyazhnyy
May 29 at 14:40
add a comment |Â
up vote
7
down vote
up vote
7
down vote
Typically virtual terminals use /dev/pts
pseudo-terminals. So, based on the output of tty
command, we can build a simple case
statement to handle opening particular editor:
case "$(tty)" in ; "/dev/pts"*) nano ;; "/dev/tty"*) gedit ;; ;esac
Or formatted more nicely:
case "$(tty)" in
"/dev/pts"*) gedit ;;
"/dev/tty"*) nano ;;
*) echo "Not suitable tty" > /dev/stderr ;;
esac
Compared to using environment variables, this is slightly more reliable and considering it uses case
statement with tty
command slightly more portable. What probably would be best is to combine both, with extra testing, such as "/dev/tty"*) [ -n "$DISPLAY" ] && gedit ;;
Typically virtual terminals use /dev/pts
pseudo-terminals. So, based on the output of tty
command, we can build a simple case
statement to handle opening particular editor:
case "$(tty)" in ; "/dev/pts"*) nano ;; "/dev/tty"*) gedit ;; ;esac
Or formatted more nicely:
case "$(tty)" in
"/dev/pts"*) gedit ;;
"/dev/tty"*) nano ;;
*) echo "Not suitable tty" > /dev/stderr ;;
esac
Compared to using environment variables, this is slightly more reliable and considering it uses case
statement with tty
command slightly more portable. What probably would be best is to combine both, with extra testing, such as "/dev/tty"*) [ -n "$DISPLAY" ] && gedit ;;
edited May 29 at 14:38
answered May 22 at 10:08
![](https://i.stack.imgur.com/U1Jy6.jpg?s=32&g=1)
![](https://i.stack.imgur.com/U1Jy6.jpg?s=32&g=1)
Sergiy Kolodyazhnyy
64k9127274
64k9127274
Isn't this the wrong way around? On my Ctrl+Alt+F1 console,tty
gives/dev/tty1
, whereasgnome-terminal
(first tab) gives/dev/pts/0
.
â Paddy Landau
May 29 at 11:25
@PaddyLandau Yes,gedit
should be in/dev/pts*
case. I switched them around while error testing in tty and ended up copying it here without switching back. Thanks, edited already.
â Sergiy Kolodyazhnyy
May 29 at 14:40
add a comment |Â
Isn't this the wrong way around? On my Ctrl+Alt+F1 console,tty
gives/dev/tty1
, whereasgnome-terminal
(first tab) gives/dev/pts/0
.
â Paddy Landau
May 29 at 11:25
@PaddyLandau Yes,gedit
should be in/dev/pts*
case. I switched them around while error testing in tty and ended up copying it here without switching back. Thanks, edited already.
â Sergiy Kolodyazhnyy
May 29 at 14:40
Isn't this the wrong way around? On my Ctrl+Alt+F1 console,
tty
gives /dev/tty1
, whereas gnome-terminal
(first tab) gives /dev/pts/0
.â Paddy Landau
May 29 at 11:25
Isn't this the wrong way around? On my Ctrl+Alt+F1 console,
tty
gives /dev/tty1
, whereas gnome-terminal
(first tab) gives /dev/pts/0
.â Paddy Landau
May 29 at 11:25
@PaddyLandau Yes,
gedit
should be in /dev/pts*
case. I switched them around while error testing in tty and ended up copying it here without switching back. Thanks, edited already.â Sergiy Kolodyazhnyy
May 29 at 14:40
@PaddyLandau Yes,
gedit
should be in /dev/pts*
case. I switched them around while error testing in tty and ended up copying it here without switching back. Thanks, edited already.â Sergiy Kolodyazhnyy
May 29 at 14:40
add a comment |Â
up vote
3
down vote
This is what I've been using:
# $TERM variable may be missing when called via desktop shortcut
CurrentTERM=$(env | grep TERM)
if [[ $CurrentTERM == "" ]] ; then
notify-send --urgency=critical "$0 cannot be run from GUI without TERM environment variable."
exit 1
fi
The reason for this code was this question: Desktop shortcut to Bash script crashes and burns
You can modify it to look like this:
# $TERM variable may be missing when called via desktop shortcut
CurrentTERM=$(env | grep TERM)
if [[ $CurrentTERM == "" ]] ; then
nano ...
else
gedit ...
fi
add a comment |Â
up vote
3
down vote
This is what I've been using:
# $TERM variable may be missing when called via desktop shortcut
CurrentTERM=$(env | grep TERM)
if [[ $CurrentTERM == "" ]] ; then
notify-send --urgency=critical "$0 cannot be run from GUI without TERM environment variable."
exit 1
fi
The reason for this code was this question: Desktop shortcut to Bash script crashes and burns
You can modify it to look like this:
# $TERM variable may be missing when called via desktop shortcut
CurrentTERM=$(env | grep TERM)
if [[ $CurrentTERM == "" ]] ; then
nano ...
else
gedit ...
fi
add a comment |Â
up vote
3
down vote
up vote
3
down vote
This is what I've been using:
# $TERM variable may be missing when called via desktop shortcut
CurrentTERM=$(env | grep TERM)
if [[ $CurrentTERM == "" ]] ; then
notify-send --urgency=critical "$0 cannot be run from GUI without TERM environment variable."
exit 1
fi
The reason for this code was this question: Desktop shortcut to Bash script crashes and burns
You can modify it to look like this:
# $TERM variable may be missing when called via desktop shortcut
CurrentTERM=$(env | grep TERM)
if [[ $CurrentTERM == "" ]] ; then
nano ...
else
gedit ...
fi
This is what I've been using:
# $TERM variable may be missing when called via desktop shortcut
CurrentTERM=$(env | grep TERM)
if [[ $CurrentTERM == "" ]] ; then
notify-send --urgency=critical "$0 cannot be run from GUI without TERM environment variable."
exit 1
fi
The reason for this code was this question: Desktop shortcut to Bash script crashes and burns
You can modify it to look like this:
# $TERM variable may be missing when called via desktop shortcut
CurrentTERM=$(env | grep TERM)
if [[ $CurrentTERM == "" ]] ; then
nano ...
else
gedit ...
fi
edited May 22 at 12:25
answered May 22 at 12:05
![](https://i.stack.imgur.com/2SXNl.jpg?s=32&g=1)
![](https://i.stack.imgur.com/2SXNl.jpg?s=32&g=1)
WinEunuuchs2Unix
34.5k756131
34.5k756131
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1038684%2fhow-to-have-script-detect-if-terminal-emulator-is-running-in-a-desktop-session-o%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
6
If your script is for use by other people you should use the program specified by
$EDITOR
by default instead ofnano
, and fallback onnano
if it is not set.â Bakuriu
May 21 at 17:42
Thanks, great advice, and it's great to hear what is good practice. Just me though.
â Organic Marble
May 21 at 17:42