osdir.com
mailing list archive

Subject: Home/End keys in mutt - msg#00037

List: gnu.screen.user

Date: Prev Index Thread: Prev Index
Hello there!

Could somebody please advice how is it possible to use mouse in the Vim
invoked unbder screen? Looks like mouse isn't working at all, while in regular
terminal it works fine.

--
Eugene N Dzhurinsky

Attachment: pgp0ZJpKlUZlf.pgp
Description: PGP signature

_______________________________________________
screen-users mailing list
screen-users-mXXj517/zsQ@xxxxxxxxxxxxxxxx
http://lists.gnu.org/mailman/listinfo/screen-users
Was this page helpful?
Yes No
Thread at a glance:

Previous Message by Date: click to view message preview

Re: Opening a new window,and cd to the same directory as the currentwindow,no matter what I'm doing

Eventually, I've found a way to do this. I thought some of you might be interested, so... I'm quoting myself here: > 3) How is the current window number stored in screen? I mean, is there a command, a register or something, > that would tell me the current window number? Then I could store it in a variable before creating the new > window... > > and... since on every window, the variable $WINDOW is defined (at window creation, I know, but I don't > change the window number), in my ~/.bashrc, I could find back the process with $WINDOW = current window, > and then find its CWD Few answers latter I was already dreaming: > > I'd need something like the 'exec' command but which would take the environment from the shell of the > current window, not the parent shell > But actually, combine these two ideas, and you've got something not so crasy! ;) let me explain why: == exec [[fdpat] newcommand [args ...]] Run a unix subprocess (...)in the current window == The WINDOW environment variable is also defined for the subprocess! (As I already said, I never move window araund, so $WINDOW is always the current windown umber, but it might not always be the case for you...) All we have to do now is to find back the current window process pid, and then read its /proc/${pid}/cwd Since this process and the subprocess have the same PPID, this makes things even easier :) Here is the 'interesting' part of my screen-utils.bash: ===== #!/bin/bash # Author: samlt # This script is intended to be run within a screen session # Find the PWD of the window process, from which this script is called function getSameDir () { #{{{ local WINNB pid # find the current window process pid while read pid; do [[ $$ == $pid ]] && continue WINNB=$(tr '\000' '\n' </proc/${pid}/environ | sed -n '/^WINDOW=/s///p') [[ -z "${WINNB}" ]] && continue [[ ${WINDOW} -eq ${WINNB} ]] && break done < <(ps --ppid ${PPID} --noheader -o %p | sed 's/^[[:space:]]*//') # check if we really found something, or if we've just reached the end of the loop [[ ${WINDOW} -eq ${WINNB} ]] || exit 2 echo $(readlink /proc/${pid}/cwd) } #}}} # Open(in the background?) a new window in the same dir as the (local) process on the current window function newWindow () { # {{{ local DIR="$(getSameDir)" # screen -X eval screen "stuff 'cd \"$DIR\"^M^L'" other screen -X eval screen "stuff 'cd \"$DIR\"^M^L'" } # }}} # (sniiiip...) ############### # "main" ######## # if WINDOW is not set, no need to go further, we're not in a screen session [[ -z ${WINDOW} ]] && exit 1 case "${1}" in nw) newWindow ;; # (sniiiip...) esac # vim: set et sts=3 sw=3 foldmethod=marker : ==== Now to open a new window (and cd to the same directory as the current window) while you're working on a remote box, or simply if you don't have your (local) prompt available just issue :exec /path/to/screen-utils.baeh nw :) Now make a shortcut, and enjoy :)

Previous Message by Thread: click to view message preview

Re: Opening a new window,and cd to the same directory as the currentwindow,no matter what I'm doing

Eventually, I've found a way to do this. I thought some of you might be interested, so... I'm quoting myself here: > 3) How is the current window number stored in screen? I mean, is there a command, a register or something, > that would tell me the current window number? Then I could store it in a variable before creating the new > window... > > and... since on every window, the variable $WINDOW is defined (at window creation, I know, but I don't > change the window number), in my ~/.bashrc, I could find back the process with $WINDOW = current window, > and then find its CWD Few answers latter I was already dreaming: > > I'd need something like the 'exec' command but which would take the environment from the shell of the > current window, not the parent shell > But actually, combine these two ideas, and you've got something not so crasy! ;) let me explain why: == exec [[fdpat] newcommand [args ...]] Run a unix subprocess (...)in the current window == The WINDOW environment variable is also defined for the subprocess! (As I already said, I never move window araund, so $WINDOW is always the current windown umber, but it might not always be the case for you...) All we have to do now is to find back the current window process pid, and then read its /proc/${pid}/cwd Since this process and the subprocess have the same PPID, this makes things even easier :) Here is the 'interesting' part of my screen-utils.bash: ===== #!/bin/bash # Author: samlt # This script is intended to be run within a screen session # Find the PWD of the window process, from which this script is called function getSameDir () { #{{{ local WINNB pid # find the current window process pid while read pid; do [[ $$ == $pid ]] && continue WINNB=$(tr '\000' '\n' </proc/${pid}/environ | sed -n '/^WINDOW=/s///p') [[ -z "${WINNB}" ]] && continue [[ ${WINDOW} -eq ${WINNB} ]] && break done < <(ps --ppid ${PPID} --noheader -o %p | sed 's/^[[:space:]]*//') # check if we really found something, or if we've just reached the end of the loop [[ ${WINDOW} -eq ${WINNB} ]] || exit 2 echo $(readlink /proc/${pid}/cwd) } #}}} # Open(in the background?) a new window in the same dir as the (local) process on the current window function newWindow () { # {{{ local DIR="$(getSameDir)" # screen -X eval screen "stuff 'cd \"$DIR\"^M^L'" other screen -X eval screen "stuff 'cd \"$DIR\"^M^L'" } # }}} # (sniiiip...) ############### # "main" ######## # if WINDOW is not set, no need to go further, we're not in a screen session [[ -z ${WINDOW} ]] && exit 1 case "${1}" in nw) newWindow ;; # (sniiiip...) esac # vim: set et sts=3 sw=3 foldmethod=marker : ==== Now to open a new window (and cd to the same directory as the current window) while you're working on a remote box, or simply if you don't have your (local) prompt available just issue :exec /path/to/screen-utils.baeh nw :) Now make a shortcut, and enjoy :)
Sign up for updates to this mailing list. email:
Loading Comments...
Home | News | Patents | Sitemap | FAQ | advertise

Advertising by