Skip to content

Commit

Permalink
Fix shell integration in headless mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Heiko Nickerl committed Jun 5, 2018
1 parent 1d22f6a commit bf91a85
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 9 deletions.
9 changes: 7 additions & 2 deletions bin/shell-integration.fish
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@

function sodalite-widget
set target (sodalite)
[ -d $target ] ;or set target (dirname $target)
cd $target
if [ $target ]
[ -d $target ] ;or set target (dirname $target)
cd $target
end
if not [ $DESKTOP ]
clear
end
commandline -f repaint
end

Expand Down
19 changes: 15 additions & 4 deletions bin/shell-integration.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
# sodalite shell integration

function headless_clear {
[ $DESKTOP ] || clear
}

function setup_cleanup {
trap headless_clear EXIT SIGTERM SIGINT
}

function sodalite-emacs-widget {
setup_cleanup
target="$(sodalite)"
[ -d "$target" ] || target="$(dirname $target)"
cd "$target"
if [ $target ]; then
[ -d "$target" ] || target="$(dirname $target)"
cd "$target"
fi
zle reset-prompt
}

Expand All @@ -19,6 +30,6 @@ if [ $shell = 'zsh' ]; then
bindkey -M vicmd 'f' sodalite-vim-widget
bindkey -M emacs '^f' sodalite-emacs-widget
elif [ $shell = 'bash' ]; then
bind -m vi-command '"f":"ddicd $(sodalite); tput cuu1; tput ed\n"'
bind -m emacs '"\C-f":"\C-k\C-ucd $(sodalite); tput cuu1; tput ed\n"'
bind -m vi-command '"f":"ddisetup_cleanup; cd $(sodalite); tput cuu1; tput ed\n"'
bind -m emacs '"\C-f":"\C-k\C-usetup_cleanup; cd $(sodalite); tput cuu1; tput ed\n"'
fi
10 changes: 8 additions & 2 deletions bin/sodalite
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
#!/bin/bash


function reset {
# enable control flow keys
stty ixany 2> /dev/null
}

trap reset SIGINT SIGTERM

# disable control flow keys
stty -ixon 2> /dev/null

Expand All @@ -18,5 +26,3 @@ python3 $LIB_DIR/main.py < /dev/tty > /dev/tty
read <&3 line
[ $line ] && echo "$line"

# enable control flow keys
stty ixany 2> /dev/null
3 changes: 2 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
##### Bugfixes
- Prevent race conditions while drawing to screen
- Make sodalite-open script (xdg-open wrapper) more robust

- Fix opening files when running headless
- Enhance shell integration when running headless

## v0.9: June 02, 2018
##### Features
Expand Down

0 comments on commit bf91a85

Please sign in to comment.