File tree Expand file tree Collapse file tree 4 files changed +8
-33
lines changed Expand file tree Collapse file tree 4 files changed +8
-33
lines changed Original file line number Diff line number Diff line change @@ -24,13 +24,6 @@ PERF=$(get_tmux_option "@easymotion-perf" "false")
2424CASE_SENSITIVE=$( get_tmux_option " @easymotion-case-sensitive" " false" )
2525SMARTSIGN=$( get_tmux_option " @easymotion-smartsign" " false" )
2626
27- # Create temporary input file with reset character
28- create_input_file () {
29- local tmp_file=$( mktemp -t tmux-easymotion_keystroke-XXXXXXX)
30- printf ' \x03' > " $tmp_file "
31- echo " $tmp_file "
32- }
33-
3427# Build environment variables string for neww -d
3528build_env_vars () {
3629 local motion_type=$1
Original file line number Diff line number Diff line change @@ -342,14 +342,14 @@ def get_terminal_size():
342342 return width , height - 1 # Subtract 1 from height
343343
344344
345- def getch (input_file = None , num_chars = 1 ):
345+ def getch (input_str = None , num_chars = 1 ):
346346 """Get character(s) from terminal or file
347347
348348 Args:
349- input_file : Optional filename to read from . If None, read from stdin.
349+ input_str : Optional string . If None, read from stdin.
350350 num_chars: Number of characters to read (default: 1)
351351 """
352- if input_file is None :
352+ if input_str is None :
353353 # Read from stdin
354354 fd = sys .stdin .fileno ()
355355 old_settings = termios .tcgetattr (fd )
@@ -359,16 +359,7 @@ def getch(input_file=None, num_chars=1):
359359 finally :
360360 termios .tcsetattr (fd , termios .TCSADRAIN , old_settings )
361361 else :
362- # Read from file
363- try :
364- with open (input_file , 'r' ) as f :
365- ch = f .read (num_chars )
366- except FileNotFoundError :
367- logging .info ("File not found" )
368- exit (1 )
369- except Exception as e :
370- logging .error (f"Error reading from file: { str (e )} " )
371- exit (1 )
362+ ch = input_str [:num_chars ]
372363 if ch == '\x03 ' :
373364 logging .info ("Operation cancelled by user" )
374365 exit (1 )
Original file line number Diff line number Diff line change @@ -6,10 +6,6 @@ CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
66# Load common configuration and functions
77source " $CURRENT_DIR /common.sh"
88
9- # Create temporary input file
10- tmp_file=$( create_input_file)
11-
129# Prompt for single character
1310ENV_VARS=$( build_env_vars " s" )
14- tmux command-prompt -1 -p ' easymotion:' " run-shell \" printf %s\\\\ n \\\" %1\\\" > $tmp_file \" ; \
15- neww -d '$ENV_VARS $CURRENT_DIR /easymotion.py $tmp_file '"
11+ tmux command-prompt -1F -p ' easymotion:' " neww -d '$ENV_VARS $CURRENT_DIR /easymotion.py %1"
Original file line number Diff line number Diff line change @@ -6,18 +6,13 @@ CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
66# Load common configuration and functions
77source " $CURRENT_DIR /common.sh"
88
9- # Create temporary input file
10- tmp_file=$( create_input_file)
11-
129# Build environment variables
1310ENV_VARS=$( build_env_vars " s2" )
1411
1512# First prompt: get first character
1613tmux command-prompt -1 -p ' easymotion char 1:' \
17- " run-shell \" printf '%1' > $tmp_file \" ; \
18- set-option -g @_easymotion_tmp_char1 '%1'"
14+ " set-option -g @_easymotion_tmp_char1 '%1'"
1915
2016# Second prompt: get second character and launch easymotion
21- tmux command-prompt -1 -p ' easymotion char 2: #{@_easymotion_tmp_char1}' \
22- " run-shell \" printf '%1' >> $tmp_file && echo >> $tmp_file \" ; \
23- neww -d '$ENV_VARS $CURRENT_DIR /easymotion.py $tmp_file '"
17+ tmux command-prompt -1F -p ' easymotion char 2: #{@_easymotion_tmp_char1}' \
18+ " neww -d '$ENV_VARS $CURRENT_DIR /easymotion.py #{@_easymotion_tmp_char1}%1'"
You can’t perform that action at this time.
0 commit comments