2019-07-16 14:51:48 -07:00
|
|
|
#!/bin/bash
|
|
|
|
|
if [ "$1" == "-h" ] ; then
|
|
|
|
|
echo "
|
|
|
|
|
ws - quickly setup workspace environment by invoking some terminals
|
|
|
|
|
- intended to be invoked within a window manager environ like i3
|
|
|
|
|
- can use a default workDir variable preference if ~/.bashrc.local exists
|
|
|
|
|
|
|
|
|
|
Usage:
|
|
|
|
|
#with an existing terminal:
|
|
|
|
|
ws
|
|
|
|
|
ws ~/projects
|
|
|
|
|
|
2020-10-05 23:08:33 -07:00
|
|
|
#with i3wm|sway for example:
|
2019-07-16 14:51:48 -07:00
|
|
|
1. select workspace e.g. <\$mod+2>
|
|
|
|
|
2. open dbus quick menu <\$mod+d> and type ws
|
|
|
|
|
"
|
|
|
|
|
echo "$(tput setaf 6)$workDir $(tput setaf 7)was previous working directory"
|
|
|
|
|
exit 0
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
|
|
myLocalConfig="$HOME/.bashrc.local"
|
2020-10-05 23:08:33 -07:00
|
|
|
# myTerm=${TERM:-urxvt}
|
|
|
|
|
myTerm=${TERM:-alacritty}
|
2019-07-16 14:51:48 -07:00
|
|
|
|
|
|
|
|
if [[ -e $myLocalConfig ]]; then
|
|
|
|
|
source $myLocalConfig
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [[ $1 ]]; then
|
|
|
|
|
workingDirectory=$1
|
|
|
|
|
else
|
|
|
|
|
workingDirectory=${workDir:-~/projects} #e.g. if workDir is defined in .bashrc.local
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# echo $workDir
|
|
|
|
|
# echo $workingDirectory
|
|
|
|
|
|
2020-10-05 23:08:33 -07:00
|
|
|
if [[ $myTerm == urxvt ]]; then
|
2025-05-13 16:45:55 -04:00
|
|
|
urxvt -cd $workingDirectory -title "$(basename $workingDirectory) woola" -e bash -ic "$HOME/bin/woola" &
|
|
|
|
|
urxvt -cd $workingDirectory -title "$(basename $workingDirectory) ranger" -e bash -ic "ranger" &
|
|
|
|
|
urxvt -cd $workingDirectory &
|
2020-10-05 23:08:33 -07:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [[ $myTerm == alacritty ]]; then
|
2025-05-13 16:45:55 -04:00
|
|
|
alacritty --working-directory $workingDirectory --title "$(basename $workingDirectory) fzf" -e bash -c "f && exec bash" &
|
|
|
|
|
alacritty --working-directory $workingDirectory --title "$(basename $workingDirectory) nnn" -e bash -c "nnn && exec bash" &
|
|
|
|
|
alacritty --working-directory $workingDirectory --title "$(basename $workingDirectory) alacritty" &
|
|
|
|
|
alacritty --working-directory $workingDirectory --title "$(basename $workingDirectory) top" -e bash -c "top && exec bash" &
|
|
|
|
|
|
|
|
|
|
sleep 0.3
|
|
|
|
|
|
|
|
|
|
python $HOME/projects/dev/arch/ws-splithv4-33.py fzf nnn alacritty top '3'
|
|
|
|
|
|
2020-10-05 23:08:33 -07:00
|
|
|
else
|
2025-05-13 16:45:55 -04:00
|
|
|
echo "edit script for compatibility with terminal"
|
2020-10-05 23:08:33 -07:00
|
|
|
fi
|
2019-07-16 14:51:48 -07:00
|
|
|
|
|
|
|
|
if [[ -e $myLocalConfig ]]; then
|
|
|
|
|
sed -i -E "s|(export workDir=).+|\1$workingDirectory|" "$myLocalConfig"
|
|
|
|
|
export workDir=$workingDirectory
|
|
|
|
|
fi
|
|
|
|
|
|