Skip to content

Commit

Permalink
Merge pull request #35 from mrjones2014/mrj/34/check-tmux-session
Browse files Browse the repository at this point in the history
Check if there is a tmux session before trying to use it
  • Loading branch information
mrjones2014 authored Oct 15, 2022
2 parents 7543ad4 + e6bab37 commit b50a0ee
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lua/smart-splits/api.lua
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,11 @@ end
---@param direction string direction to move
---@return boolean whether we moved with tmux or not
local function move_cursor_tmux(direction, at_edge_and_moving_to_edge)
local tmux = require('smart-splits.tmux')
if not tmux.current_session_is_tmux() then
return
end

local dir_key = dir_keys_tmux[direction]
local tmux_moved = move_tmux_inner(dir_key)
if tmux_moved or not at_edge_and_moving_to_edge then
Expand Down
4 changes: 4 additions & 0 deletions lua/smart-splits/tmux.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ local function tmux_exec(cmd)
return vim.fn.system(cmd_str)
end

function M.current_session_is_tmux()
return get_socket_path() ~= nil
end

---Try to get current tmux pane ID
---returns nil if failed or not in a tmux session.
---@return string|nil
Expand Down

0 comments on commit b50a0ee

Please sign in to comment.