diff --git a/bin/i3-shell b/bin/i3-shell new file mode 100755 index 00000000..e63980c5 --- /dev/null +++ b/bin/i3-shell @@ -0,0 +1,29 @@ +#!/bin/bash +# i3 thread: https://faq.i3wm.org/question/150/how-to-launch-a-terminal-from-here/?answer=152#post-id-152 + +# I stole this from here: https://gist.github.com/viking/5851049 + +CMD=$TERMINAL +CWD='' + +# Get window ID +ID=$(xdpyinfo | grep focus | cut -f4 -d " ") + +# Get PID of process whose window this is +PID=$(xprop -id $ID | grep -m 1 PID | cut -d " " -f 3) + +# Get last child process (shell, vim, etc) +if [ -n "$PID" ]; then + TREE=$(pstree -lpA $PID | tail -n 1) + PID=$(echo $TREE | awk -F'---' '{print $NF}' | sed -re 's/[^0-9]//g') + + # If we find the working directory, run the command in that directory + if [ -e "/proc/$PID/cwd" ]; then + CWD=$(readlink /proc/$PID/cwd) + fi +fi +if [ -n "$CWD" ]; then + cd $CWD && $CMD +else + $CMD +fi diff --git a/i3/configWork b/i3/configWork index 82e8c43b..6ac06686 100644 --- a/i3/configWork +++ b/i3/configWork @@ -45,7 +45,8 @@ floating_modifier $mod # bindsym $mod+Return exec xfce4-terminal # bindsym $mod+Return exec konsole # bindsym $mod+Return exec termite -bindsym $mod+Return exec /usr/local/bin/st +# bindsym $mod+Return exec /usr/local/bin/st +bindsym $mod+Return exec ~/.dotfiles/bin/i3-shell # kill focused window bindsym $mod+q kill diff --git a/shells/functions b/shells/functions index 23a8ea72..8458e005 100644 --- a/shells/functions +++ b/shells/functions @@ -38,9 +38,9 @@ function mycd() { cd "$@" 2> /dev/null if [ $? = 0 ]; then # If we get here cd was successful - if [ ! $TMUX ]; then - pwd > ~/.current-folder - fi + #if [ ! $TMUX ]; then + # pwd > ~/.current-folder + #fi ls else # If we get here, cd was not successful diff --git a/shells/zsh/zshrc b/shells/zsh/zshrc index beb694f4..b18054ef 100644 --- a/shells/zsh/zshrc +++ b/shells/zsh/zshrc @@ -91,6 +91,6 @@ TRAPWINCH(){ zle && {zle reset-prompt; zle -R} } -if [ -f ~/.current-folder ] && [ ! $TMUX ]; then - \cd "$(cat ~/.current-folder)" -fi +#if [ -f ~/.current-folder ] && [ ! $TMUX ]; then +# \cd "$(cat ~/.current-folder)" +#fi