
Fluxboxを使用して、次のプロパティを使用して端末(つまり、何でも)を開くことができるwinkey+というショートカットを設定できますか?rxterm
- タスクディレクトリ=〜の端末がすでに存在し、現在実行中のコマンドがない場合(たとえば、プロンプトで)、この端末が表示されます。
- または、新しい端末を作成しない場合
答え1
これが私がする方法です:
- プロンプトが表示されたら、シェルのタイトルを「bash」に設定し、コマンドを実行するときにコマンド名を「bash」に設定するか、区別する項目を設定します。
- 開いているウィンドウのリストを呼び出すスクリプトを作成し
wmctrl
たら、次の操作を行います。wmctrl
「bash」というタイトルのウィンドウが見つかったら、それを上昇させます。- それ以外の場合
xterm
xbindkeys
ホットキーを押したときにスクリプトを呼び出すために使用されます。
コマンドを実行するときにシェルにウィンドウのタイトルを設定するようにしてください。
bashでこれを行う方法の単純化されたバージョンは次のとおりです。コードを注意深く確認しませんでしたが、私のコンピュータでは動作します。
# set the title when we run a command
setcommandhook()
{
if $has_debug_trap
then
trap 'command=$BASH_COMMAND; eval settitle "\"${title}\""; trap - DEBUG' DEBUG
fi
}
# set the xterm title
settitle()
{
printf "\033]0;$*\007"
}
promptstring='$(hostname):$(pwd)$ '
title='$(hostname) "${command:-$0}"'
# prompt and window title
if test -n "${title}"
then
PROMPT_COMMAND='command=; eval settitle "\"${title}\""'
if $has_debug_trap
then
PROMPT_COMMAND="$PROMPT_COMMAND; setcommandhook"
fi
fi
if test -n "${promptstring}"
then
PS1='$(eval echo -n "\"${promptstring}\"")'
fi
フックがあるので作業がzsh
簡単です。preexec
あなたは見ることができますマイシェルの設定getcommand
より良い方法でコマンドを処理する機能などの詳細を確認してください。fg
bashプロンプトでxtermを起動し、そうでない場合は新しいプロンプトを起動します。
タイトル付きのウィンドウをwmctrl -l
見つけて、ウィンドウを一覧表示するスクリプトを作成します。bash
見つかった場合は実行wmctrl -i -a <id returned by wmctrl -l>
して発生し、それ以外の場合は呼び出しますxterm
。
これを行うスクリプトは次のとおりです。
#!/bin/bash
#
# bashprompt
#
# if there is an xterm open at a bash prompt, raise/focus that window
# if there isn't start a new xterm
#
# requires that your xterm window title has "bash" at the end
# when there is no command running and doesn't have "bash" at the end
# when a command is running
#
# see <http://unix.stackexchange.com/questions/6842> for more details
#
# Mikel Ward <[email protected]>
# change this to whatever is unique about your window title
# (i.e. a string that appears in the title when the shell is at a prompt
# but does not appear when running a command)
prompttitle="bash$"
terminalprog="xterm"
if ! type wmctrl >/dev/null 2>&1; then
echo "wmctrl can't be found, please install it" 1>&2
exit 1
fi
if ! output="$(wmctrl -l)"; then
echo "Error running wmctrl -l" 1>&2
exit 1
fi
while IFS=$'\n' read -r line; do
if [[ $line =~ $prompttitle ]]; then
id=${line%% *}
break
fi
done <<EOF
$output
EOF
if test -n "$id"; then
wmctrl -i -a "$id"
else
"$terminalprog"&
fi
Win + Rを押すとスクリプトを実行する
スクリプトが呼び出されたとし、次の内容でファイルを作成し/usr/local/bin/bashprompt
ます。~/.xbindkeysrc
"/usr/local/bin/bashprompt"
Mod4 + r
それからxbindkeys
。これを.Xclients
ファイルや類似の項目に追加すると、自動的に起動します。
答え2
fluxbox
Windowsは特定のパターンに応じて独自に一致させることができます。少なくともfluxbox-1.1.1
これは可能です:
Mod4 r :If {Some Matches (title=.*bash) (class=XTerm)} {NextWindow (xterm)} {Exec xterm}
(翻訳:on press windows-key + r: check, if there is a xterm with its title ending in 'bash'. if there is, go to that window; if not, open a new one
.最先端バージョン(git)を使用すると、他のワークスペースのウィンドウに移動することもできます。
あなたがしなければならない唯一のことは、タスクに応じてタイトル(またはbashを含むウィンドウの他のプロパティ)を変更することです。プロンプトを見ると、設定する必要がある属性がありますが、コマンドが実行されたらその属性を削除する必要があります。fluxbox
アプリケーションの内部を見る方法はなく、Windowsについてのみ知っています。