mirror of
https://github.com/jimeh/tmuxifier.git
synced 2026-02-19 09:56:39 +00:00
Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7106a81066 | |||
| 68ee1b8660 | |||
| 11103822c2 | |||
| f460d78f48 | |||
| 2da8fc9d7b | |||
| e493745b6e | |||
| d5d87d3ab2 | |||
| d367b5ecd6 | |||
|
|
3f171997df |
21
README.md
21
README.md
@@ -52,16 +52,31 @@ Which will yield a Tmux window looking like this:
|
||||
|
||||
## Installation
|
||||
|
||||
Clone the repo to your machine:
|
||||
|
||||
```bash
|
||||
git clone https://github.com/jimeh/tmuxifier.git ~/.tmuxifier
|
||||
```
|
||||
|
||||
And add the following to your `~/.profile`, `~/.bash_profile` or equivalent:
|
||||
### bash & zsh
|
||||
|
||||
And add the following to your `~/.profile`, `~/.bash_profile`, `~/.zshrc` or
|
||||
equivalent:
|
||||
|
||||
```bash
|
||||
[[ -s "$HOME/.tmuxifier/init.sh" ]] && source "$HOME/.tmuxifier/init.sh"
|
||||
```
|
||||
|
||||
### tcsh
|
||||
|
||||
Add the following to your `~/.cshrc`, `~/.tcshrc` or equivalent:
|
||||
|
||||
```tcsh
|
||||
if ( -s "$HOME/.tmuxifier/init.sh" ) then
|
||||
source "$HOME/.tmuxifier/init.sh"
|
||||
endif
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
*__Note:__ This section needs expanding upon.*
|
||||
@@ -117,8 +132,8 @@ in it.
|
||||
### Custom Installaton Path
|
||||
|
||||
To install Tmuxifier to a custom path, clone the repository to your desired
|
||||
path and set `$TMUXIFIER` to that path, additionally loading `init.sh` from
|
||||
that same path.
|
||||
path and set `$TMUXIFIER` to that path, additionally loading `init.sh` or
|
||||
`init.tcsh` from that same path.
|
||||
|
||||
```bash
|
||||
export TMUXIFIER="$HOME/.dotfiles/tmuxifier"
|
||||
|
||||
2
completion/tmuxifier.tcsh
Normal file
2
completion/tmuxifier.tcsh
Normal file
@@ -0,0 +1,2 @@
|
||||
complete tmuxifier 'p@1@`tmuxifier commands`@' \
|
||||
'p@2@`tmuxifier completions $:-1`@'
|
||||
13
init.tcsh
Normal file
13
init.tcsh
Normal file
@@ -0,0 +1,13 @@
|
||||
# Set tmuxifier root path.
|
||||
if ( ! $?TMUXIFIER ) then
|
||||
setenv TMUXIFIER "${HOME}/.tmuxifier"
|
||||
endif
|
||||
|
||||
# Add `bin` directroy to `$PATH`.
|
||||
set path = ( $TMUXIFIER/bin $path )
|
||||
|
||||
# If `tmuxifier` is available, and `$TMUXIFIER_NO_COMPLETE` is not set, then
|
||||
# load tmuxifier shell completion.
|
||||
if ( ! $?TMUXIFIER_NO_COMPLETE ) then
|
||||
which tmuxifier > /dev/null && source "$TMUXIFIER/completion/tmuxifier.tcsh"
|
||||
endif
|
||||
@@ -182,9 +182,10 @@ initialize_session() {
|
||||
fi
|
||||
|
||||
# In order to ensure only specified windows are created, we move the
|
||||
# default window to position 99, and later remove it with the
|
||||
# `finalize_session` function.
|
||||
tmux move-window -s "$session:0" -t "$session:99"
|
||||
# default window to position 999, and later remove it with the
|
||||
# `finalize_and_go_to_session` function.
|
||||
local first_window_index=$(__get_first_window_index)
|
||||
tmux move-window -s "$session:$first_window_index" -t "$session:999"
|
||||
|
||||
# Ensure correct pane splitting.
|
||||
__go_to_session
|
||||
@@ -207,7 +208,7 @@ initialize_session() {
|
||||
# to it here.
|
||||
#
|
||||
finalize_and_go_to_session() {
|
||||
! tmux kill-window -t "$session:99" 2>/dev/null
|
||||
! tmux kill-window -t "$session:999" 2>/dev/null
|
||||
if [[ "$(tmuxifier-current-session)" != "$session" ]]; then
|
||||
__go_to_session
|
||||
fi
|
||||
@@ -229,6 +230,16 @@ __expand_path() {
|
||||
echo $(eval echo "$@")
|
||||
}
|
||||
|
||||
__get_first_window_index() {
|
||||
local index
|
||||
index=$(tmux list-windows -t "$session:" -F "#{window_index}" 2>/dev/null)
|
||||
if [ -n "$index" ]; then
|
||||
echo "$index" | head -1
|
||||
else
|
||||
echo "0"
|
||||
fi
|
||||
}
|
||||
|
||||
__go_to_session() {
|
||||
if [ -z "$TMUX" ]; then
|
||||
tmux -u attach-session -t "$session:"
|
||||
|
||||
@@ -2,4 +2,4 @@
|
||||
set -e
|
||||
[ -n "$TMUXIFIER_DEBUG" ] && set -x
|
||||
|
||||
echo "0.3.1"
|
||||
echo "0.4.0"
|
||||
|
||||
Reference in New Issue
Block a user