Skip to content

Instantly share code, notes, and snippets.

@mamemomonga
Last active April 8, 2024 04:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mamemomonga/68f42f245484c321fba3f247029dd6f4 to your computer and use it in GitHub Desktop.
Save mamemomonga/68f42f245484c321fba3f247029dd6f4 to your computer and use it in GitHub Desktop.
現在のtmuxで新しいウィンドウを開き、cdコマンドでパスを移動するスクリプト
#!/bin/bash
set -eu
# 現在のtmuxで新しいウィンドウを開き、cdコマンドでパスを移動するスクリプト
if [ -z "${TMUX:-}" ]; then
echo "tmuxを起動してください"
exit 1
fi
export TMUX
tmux_new_cd() {
local name=$1
local path=$2
tmux \
new-window -n "$name" \;\
send-keys "cd '$path'" C-m
}
# デスクトップに移動
tmux_new_cd Desktop /Users/username/Desktop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment