Discussion:
How to switch window without loading the shell init?
(too old to reply)
Kaushal
2015-05-06 14:47:20 UTC
Permalink
Hi,

I use the tmux split-window function only temporarily at times to do some
quick selections from a list using percol.

Examples:

# switch to another session by name
bind S split-window "tmux ls | percol --initial-index `tmux ls | awk
'/attached.$/ {print NR-1}'` | cut -d':' -f 1 | xargs tmux switch-client -t"
# switch to ANY window in ANY session by name

# switch to ANY window in ANY session by name
bind s split-window "tmux ls | cut -d: -f1 | xargs -I SESSION tmux lsw -F
'SESSION:#{window_name}' -t SESSION | percol --initial-index `tmux ls | cut
-d: -f1 | xargs -I SESSION tmux lsw -F
'___#{session_attached}#{window_active}___' -t SESSION | awk '/___11___/
{print NR-1}'` | xargs tmux switch-client -t"

These work except that when creating a new window, it also load my shell
init script.

For a new terminal, window, my shell init always loads a bunch of
environment manipulation that I need to run certain company programs when I
am actually working in a terminal. I don't need those in the above
temporary split-window cases.

I can also skip the time consuming environment setup if I can set an env
var SHELL_CONFIG_LOADED before calling split-window.

So the questions I have are:

- How can I make split-window not load my default shell init (*rc) script?
- Alternatively, how can I set an env var SHELL_CONFIG_LOADED before my
shell init gets loaded on doing split-window?

Thanks.
Chas. Owens
2015-05-06 14:55:19 UTC
Permalink
It sounds like your heavy weight initializing is being done in .bashrc as
opposed to .bash_profile or .profile. The .bashrc config file is intended
to barely bootstrap your environment and .bash_profile (or .profile) is
intended to make an interactive shell usable. One option would be to use a
different shell like sh to run your commands: sh -c "ls | percol
--initial-index `tmux ls | awk '/attached.$/ {print NR-1}'` | cut -d':' -f
1 | xargs tmux switch-client -t" another would be to specify a different
.bashrc: bash --rcfile ".bashrc_light" -c "tmux ls | blah".
Post by Kaushal
Hi,
I use the tmux split-window function only temporarily at times to do some
quick selections from a list using percol.
# switch to another session by name
bind S split-window "tmux ls | percol --initial-index `tmux ls | awk
'/attached.$/ {print NR-1}'` | cut -d':' -f 1 | xargs tmux switch-client -t"
# switch to ANY window in ANY session by name
# switch to ANY window in ANY session by name
bind s split-window "tmux ls | cut -d: -f1 | xargs -I SESSION tmux lsw
-F 'SESSION:#{window_name}' -t SESSION | percol --initial-index `tmux ls |
cut -d: -f1 | xargs -I SESSION tmux lsw -F
'___#{session_attached}#{window_active}___' -t SESSION | awk '/___11___/
{print NR-1}'` | xargs tmux switch-client -t"
These work except that when creating a new window, it also load my shell
init script.
For a new terminal, window, my shell init always loads a bunch of
environment manipulation that I need to run certain company programs when I
am actually working in a terminal. I don't need those in the above
temporary split-window cases.
I can also skip the time consuming environment setup if I can set an env
var SHELL_CONFIG_LOADED before calling split-window.
- How can I make split-window not load my default shell init (*rc) script?
- Alternatively, how can I set an env var SHELL_CONFIG_LOADED before my
shell init gets loaded on doing split-window?
Thanks.
------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
tmux-users mailing list
https://lists.sourceforge.net/lists/listinfo/tmux-users
Kaushal
2015-05-06 15:30:39 UTC
Permalink
I tried that but as I mentioned in the parallel thread, tcsh was still load
first as my default-shell was tcsh. Changing default-shell to /bin/sh and
default-command to tcsh fixed everything.

I now just need to make sure that I pass in a bash/sh compatiable command
instead of a tcsh/csh command.
Post by Chas. Owens
It sounds like your heavy weight initializing is being done in .bashrc as
opposed to .bash_profile or .profile. The .bashrc config file is intended
to barely bootstrap your environment and .bash_profile (or .profile) is
intended to make an interactive shell usable. One option would be to use a
different shell like sh to run your commands: sh -c "ls | percol
--initial-index `tmux ls | awk '/attached.$/ {print NR-1}'` | cut -d':' -f
1 | xargs tmux switch-client -t" another would be to specify a different
.bashrc: bash --rcfile ".bashrc_light" -c "tmux ls | blah".
Post by Kaushal
Hi,
I use the tmux split-window function only temporarily at times to do some
quick selections from a list using percol.
# switch to another session by name
bind S split-window "tmux ls | percol --initial-index `tmux ls | awk
'/attached.$/ {print NR-1}'` | cut -d':' -f 1 | xargs tmux switch-client -t"
# switch to ANY window in ANY session by name
# switch to ANY window in ANY session by name
bind s split-window "tmux ls | cut -d: -f1 | xargs -I SESSION tmux lsw
-F 'SESSION:#{window_name}' -t SESSION | percol --initial-index `tmux ls |
cut -d: -f1 | xargs -I SESSION tmux lsw -F
'___#{session_attached}#{window_active}___' -t SESSION | awk '/___11___/
{print NR-1}'` | xargs tmux switch-client -t"
These work except that when creating a new window, it also load my shell
init script.
For a new terminal, window, my shell init always loads a bunch of
environment manipulation that I need to run certain company programs when I
am actually working in a terminal. I don't need those in the above
temporary split-window cases.
I can also skip the time consuming environment setup if I can set an env
var SHELL_CONFIG_LOADED before calling split-window.
- How can I make split-window not load my default shell init (*rc) script?
- Alternatively, how can I set an env var SHELL_CONFIG_LOADED before my
shell init gets loaded on doing split-window?
Thanks.
------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
tmux-users mailing list
https://lists.sourceforge.net/lists/listinfo/tmux-users
Nicholas Marriott
2015-05-06 15:03:38 UTC
Permalink
Most shells have a way to specify different init files for interactive
and noninteractive shells (such as setting ENV in .profile for ksh).

Or if you're using a sh-like shell you could do something like this in
the profile:

case "$-" in
*i*)
export SHELL_CONFIG_LOADED=1
;;
esac
Post by Kaushal
Hi,
I use the tmux split-window function only temporarily at times to do some
quick selections from a list using percol.
# switch to another session by name
bind * S split-window "tmux ls | percol --initial-index `tmux ls | awk
'/attached.$/ {print NR-1}'` | cut -d':' -f 1 | xargs tmux switch-client -t"
# switch to ANY window in ANY session by name
# switch to ANY window in ANY session by name
bind * s split-window "tmux ls | cut -d: -f1 | xargs -I SESSION tmux lsw
-F 'SESSION:#{window_name}' -t SESSION | percol --initial-index `tmux ls |
cut -d: -f1 | xargs -I SESSION tmux lsw -F
'___#{session_attached}#{window_active}___' -t SESSION | awk '/___11___/
{print NR-1}'` | xargs tmux switch-client -t"
These work except that when creating a new window, it also load my shell
init script.
For a new terminal, window, my shell init always loads a bunch of
environment manipulation that I need to run certain company programs when
I am actually working in a terminal. I don't need those in the above
temporary split-window cases.
I can also skip the time consuming environment setup if I can set an env
var*SHELL_CONFIG_LOADED before calling split-window.
- How can I make split-window not load my default shell init (*rc) script?
- Alternatively, how can I set an env var*SHELL_CONFIG_LOADED before my
shell init gets loaded on doing split-window?
Thanks.
------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
tmux-users mailing list
https://lists.sourceforge.net/lists/listinfo/tmux-users
Kaushal
2015-05-06 15:11:43 UTC
Permalink
Thanks for the quick replies. But unfortunately, I have to use the tcsh
shell and I can put in my custom init stuff only in a ~/.alias which is
sourced by a company maintained ~/.cshrc.

In that ~/.cshrc, I already have:

# skip remaining setup if not an interactive shell
if ($?USER == 0 || $?prompt == 0) exit

# blah blah blah

if ( -e ~/.alias) then
source ~/.alias
endif

But it looks like that .alias is still getting loaded on doing split-window.

Also from man tcsh, I don't think that tcsh has anything like a "profile"
setup that bash has.

On Wed, May 6, 2015 at 11:03 AM Nicholas Marriott <
Post by Nicholas Marriott
Most shells have a way to specify different init files for interactive
and noninteractive shells (such as setting ENV in .profile for ksh).
Or if you're using a sh-like shell you could do something like this in
case "$-" in
*i*)
export SHELL_CONFIG_LOADED=1
;;
esac
Post by Kaushal
Hi,
I use the tmux split-window function only temporarily at times to do
some
Post by Kaushal
quick selections from a list using percol.
# switch to another session by name
bind * S split-window "tmux ls | percol --initial-index `tmux ls | awk
'/attached.$/ {print NR-1}'` | cut -d':' -f 1 | xargs tmux
switch-client
Post by Kaushal
-t"
# switch to ANY window in ANY session by name
# switch to ANY window in ANY session by name
bind * s split-window "tmux ls | cut -d: -f1 | xargs -I SESSION tmux
lsw
Post by Kaushal
-F 'SESSION:#{window_name}' -t SESSION | percol --initial-index `tmux
ls |
Post by Kaushal
cut -d: -f1 | xargs -I SESSION tmux lsw -F
'___#{session_attached}#{window_active}___' -t SESSION | awk
'/___11___/
Post by Kaushal
{print NR-1}'` | xargs tmux switch-client -t"
These work except that when creating a new window, it also load my
shell
Post by Kaushal
init script.
For a new terminal, window, my shell init always loads a bunch of
environment manipulation that I need to run certain company programs
when
Post by Kaushal
I am actually working in a terminal. I don't need those in the above
temporary split-window cases.
I can also skip the time consuming environment setup if I can set an
env
Post by Kaushal
var*SHELL_CONFIG_LOADED before calling split-window.
- How can I make split-window not load my default shell init (*rc)
script?
Post by Kaushal
- Alternatively, how can I set an env var*SHELL_CONFIG_LOADED before
my
Post by Kaushal
shell init gets loaded on doing split-window?
Thanks.
------------------------------------------------------------------------------
Post by Kaushal
One dashboard for servers and applications across Physical-Virtual-Cloud
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
tmux-users mailing list
https://lists.sourceforge.net/lists/listinfo/tmux-users
Nicholas Marriott
2015-05-06 15:16:56 UTC
Permalink
Change your default-shell to /bin/sh so that new windows started with a
command will get /bin/sh and set default-command to tcsh so you get
tcsh?
Post by Kaushal
Thanks for the quick replies. But unfortunately, I have to use the tcsh
shell and I can put in my custom init stuff only in a ~/.alias which is
sourced by a company maintained ~/.cshrc.
# skip remaining setup if not an interactive shell
if ($?USER == 0 || $?prompt == 0) exit
# blah blah blah
if ( -e ~/.alias) then
* * * * source ~/.alias
endif
But it looks like that .alias is still getting loaded on doing split-window.
Also from man tcsh, I don't think that tcsh has anything like a "profile"
setup that bash has.
On Wed, May 6, 2015 at 11:03 AM Nicholas Marriott
Most shells have a way to specify different init files for interactive
and noninteractive shells (such as setting ENV in .profile for ksh).
Or if you're using a sh-like shell you could do something like this in
case "$-" in
*i*)
* * * * export SHELL_CONFIG_LOADED=1
* * * * ;;
esac
* * Hi,
* * I use the tmux split-window function only temporarily at times to
do some
* * quick selections from a list using percol.
* * # switch to another session by name
* * bind * S split-window "tmux ls | percol --initial-index `tmux ls |
awk
* * '/attached.$/ {print NR-1}'` | cut -d':' -f 1 | xargs tmux
switch-client
* * -t"
* * # switch to ANY window in ANY session by name
* * # switch to ANY window in ANY session by name
* * bind * s split-window "tmux ls | cut -d: -f1 | xargs -I SESSION
tmux lsw
* * -F 'SESSION:#{window_name}' -t SESSION | percol --initial-index
`tmux ls |
* * cut -d: -f1 | xargs -I SESSION tmux lsw -F
* * '___#{session_attached}#{window_active}___' -t SESSION | awk
'/___11___/
* * {print NR-1}'` | xargs tmux switch-client -t"
* * These work except that when creating a new window, it also load my
shell
* * init script.
* * For a new terminal, window, my shell init always loads a bunch of
* * environment manipulation that I need to run certain company
programs when
* * I am actually working in a terminal. I don't need those in the
above
* * temporary split-window cases.
* * I can also skip the time consuming environment setup if I can set
an env
* * var*SHELL_CONFIG_LOADED before calling split-window.
* * - How can I make split-window not load my default shell init (*rc)
script?
* * - Alternatively, how can I set an env var*SHELL_CONFIG_LOADED
before my
* * shell init gets loaded on doing split-window?
* * Thanks.
------------------------------------------------------------------------------
One dashboard for servers and applications across
Physical-Virtual-Cloud
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable
Insights
Deep dive visibility with transaction tracing using APM Insight.
[2]http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
tmux-users mailing list
[4]https://lists.sourceforge.net/lists/listinfo/tmux-users
References
Visible links
2. http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
4. https://lists.sourceforge.net/lists/listinfo/tmux-users
Kaushal
2015-05-06 15:28:53 UTC
Permalink
That worked wonders! Thanks.

It happens that the existing commands I have like

bind S split-window "tmux ls | percol --initial-index `tmux ls | awk
'/attached.$/ {print NR-1}'` | cut -d':' -f 1 | xargs tmux switch-client -t"

are sh compatible too.

On Wed, May 6, 2015 at 11:16 AM Nicholas Marriott <
Post by Nicholas Marriott
Change your default-shell to /bin/sh so that new windows started with a
command will get /bin/sh and set default-command to tcsh so you get
tcsh?
Post by Kaushal
Thanks for the quick replies. But unfortunately, I have to use the
tcsh
Post by Kaushal
shell and I can put in my custom init stuff only in a ~/.alias which
is
Post by Kaushal
sourced by a company maintained ~/.cshrc.
# skip remaining setup if not an interactive shell
if ($?USER == 0 || $?prompt == 0) exit
# blah blah blah
if ( -e ~/.alias) then
* * * * source ~/.alias
endif
But it looks like that .alias is still getting loaded on doing split-window.
Also from man tcsh, I don't think that tcsh has anything like a
"profile"
Post by Kaushal
setup that bash has.
On Wed, May 6, 2015 at 11:03 AM Nicholas Marriott
Most shells have a way to specify different init files for
interactive
Post by Kaushal
and noninteractive shells (such as setting ENV in .profile for ksh).
Or if you're using a sh-like shell you could do something like this
in
Post by Kaushal
case "$-" in
*i*)
* * * * export SHELL_CONFIG_LOADED=1
* * * * ;;
esac
* * Hi,
* * I use the tmux split-window function only temporarily at times
to
Post by Kaushal
do some
* * quick selections from a list using percol.
* * # switch to another session by name
* * bind * S split-window "tmux ls | percol --initial-index `tmux
ls |
Post by Kaushal
awk
* * '/attached.$/ {print NR-1}'` | cut -d':' -f 1 | xargs tmux
switch-client
* * -t"
* * # switch to ANY window in ANY session by name
* * # switch to ANY window in ANY session by name
* * bind * s split-window "tmux ls | cut -d: -f1 | xargs -I SESSION
tmux lsw
* * -F 'SESSION:#{window_name}' -t SESSION | percol --initial-index
`tmux ls |
* * cut -d: -f1 | xargs -I SESSION tmux lsw -F
* * '___#{session_attached}#{window_active}___' -t SESSION | awk
'/___11___/
* * {print NR-1}'` | xargs tmux switch-client -t"
* * These work except that when creating a new window, it also
load my
Post by Kaushal
shell
* * init script.
* * For a new terminal, window, my shell init always loads a bunch
of
Post by Kaushal
* * environment manipulation that I need to run certain company
programs when
* * I am actually working in a terminal. I don't need those in the
above
* * temporary split-window cases.
* * I can also skip the time consuming environment setup if I can
set
Post by Kaushal
an env
* * var*SHELL_CONFIG_LOADED before calling split-window.
* * - How can I make split-window not load my default shell init
(*rc)
Post by Kaushal
script?
* * - Alternatively, how can I set an env var*SHELL_CONFIG_LOADED
before my
* * shell init gets loaded on doing split-window?
* * Thanks.
------------------------------------------------------------------------------
Post by Kaushal
One dashboard for servers and applications across
Physical-Virtual-Cloud
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable
Insights
Deep dive visibility with transaction tracing using APM Insight.
[2]http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
tmux-users mailing list
[4]https://lists.sourceforge.net/lists/listinfo/tmux-users
References
Visible links
2. http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
4. https://lists.sourceforge.net/lists/listinfo/tmux-users
Loading...