~ / archivo / stackoverflow / 50346138
Terminator initial script
StackOverflow
· oh-my-zsh, terminator
· ayudé
-
I'm current user of terminator & oh-my-zsh. In teminator I tried to set my custom layout with several tabs and initial commands for every tab. I followed instruction as described here https://amir.rachum.com/blog/2015/11/28/terminator-multiple-custom-commands/ Main part there is this script in .zshrc
echo $INIT_CMD if [ ! -z "$INIT_CMD" ]; then OLD_IFS=$IFS setopt shwordsplit IFS=';' for cmd in $INIT_CMD; do print -s "$cmd" # add to history eval $cmd done unset INIT_CMD IFS=$OLD_IFS fiEverything works fine except commands from initial script are not stored in my zsh history. If I execute commands directly in zsh it works properly as well. My guess is that history file loaded after my command is executed.
- Tarun Lalwani 2018-05-27 04:57 @AmirRachum Why not just use a workaround or so?
echo "$cmd" >> ~/.zsh_history - Gleb 2018-05-28 08:05 @TarunLalwani I've tried your way and it works but it shares
$cmdamong tabs - Tarun Lalwani 2018-05-28 08:28 Try adding a
fc -R ~/.zsh_historyin your init script and see if it helps - Tarun Lalwani 2018-05-28 15:03 Also when I test this code on mac with
zsh 5.5.1 (x86_64-apple-darwin17.5.0)it works great. Please check what version ofzshyou are using and see if that is the source of the problem - Gleb 2018-05-30 08:35 @TarunLalwani I added
fc -R ~/.zsh_historycommand before that script, but it didn't help me. My zsh version was5.2on Ubuntu 17.10 and it doesn't let me upgrade it till I upgraded my Ubuntu to 18.04. Now I havezsh 5.4.2 (x86_64-ubuntu-linux-gnu)which is last stable. And the problem with shared history still exists. I noticed that my usual history stored in such way:: 1527666945:0;mc. Maybe that's my problem
- Tarun Lalwani 2018-05-27 04:57 @AmirRachum Why not just use a workaround or so?
-
Simple solution for bash
append ;bash to you custom command
Example: change
redis-servertoredis-server; bash- Yehor 2023-01-03 11:36 Your answer helped me, thank you very much! But could you please explain why
; bashdid the trick ?
- Yehor 2023-01-03 11:36 Your answer helped me, thank you very much! But could you please explain why
-
The solution for this (bash)
echo $INIT_CMD if [ ! -z "$INIT_CMD" ]; then OLD_IFS=$IFS IFS=';' for cmd in $INIT_CMD; do history -s "$cmd" # add to history eval $cmd done unset INIT_CMD IFS=$OLD_IFS # ----------------required to refresh the shell session history -a # append history lines from this session # to the history file history -r # read the history file and append the # contents to the history list fiThe solution for this (zsh)
echo $INIT_CMD if [ ! -z "$INIT_CMD" ]; then OLD_IFS=$IFS setopt shwordsplit IFS=';' for cmd in $INIT_CMD; do print -S "$cmd" # add to history eval $cmd done unset INIT_CMD IFS=$OLD_IFS fi