@@ -99,6 +99,33 @@ test-bash binary/string tmpdir/string:
9999 expect ( content .contains "beta" )
100100 tmux .cancel
101101
102+ // Tilde expansion: the "lookup" command opens the file given as the
103+ // first rest arg and offers fixed candidates for the second arg.
104+ // When the file path uses ~, the shell must expand the tilde so
105+ // the program can open the file.
106+ // Find an existing file in $HOME to avoid creating test artifacts.
107+ tmux .send-line "for f in .profile .bashrc .zshrc .zshenv .bash_profile .config; do test -e ~/\$ f && echo tilde-found:\$ f && break; done"
108+ tmux .wait-for "tilde-found:"
109+ tilde-file := ""
110+ lines := ( tmux .capture ) .split "\n "
111+ lines .do : | line / string |
112+ if line .contains "tilde-found:" and tilde-file == "" :
113+ tilde-file = ( ( line .trim ) .split ":" ) .last
114+
115+ expect ( tilde-file != "" )
116+
117+ // Re-source with absolute path.
118+ tmux .send-line "source <($ binary completion bash) && echo re-sourced2"
119+ tmux .wait-for "re-sourced2"
120+
121+ // Complete the entry arg using a tilde path for the file.
122+ tmux .send-keys [ "$ binary lookup ~/$( tilde-file ) " , "Tab" , "Tab" ]
123+ tmux .wait-for "tilde-ok-alpha"
124+ content = tmux .capture
125+ expect ( content .contains "tilde-ok-bravo" )
126+ expect ( content .contains "tilde-ok-charlie" )
127+ tmux .cancel
128+
102129 print " All bash tests passed."
103130 finally:
104131 tmux .close
0 commit comments