Add 'zk' script
							parent
							
								
									fade05a394
								
							
						
					
					
						commit
						958de4e03c
					
				| 
						 | 
					@ -51,7 +51,6 @@ alias path='echo -e ${PATH//:/\\n}' # Pretty print path variables
 | 
				
			||||||
# Programs
 | 
					# Programs
 | 
				
			||||||
alias o="xdg-open"
 | 
					alias o="xdg-open"
 | 
				
			||||||
alias v="nvim"
 | 
					alias v="nvim"
 | 
				
			||||||
alias zk='cd ~/.zk && nvim "$(cat ~/.zk/current-zettel.txt)"'
 | 
					 | 
				
			||||||
alias g='git'
 | 
					alias g='git'
 | 
				
			||||||
alias t=' task'
 | 
					alias t=' task'
 | 
				
			||||||
alias tsh='tasksh'
 | 
					alias tsh='tasksh'
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,33 @@
 | 
				
			||||||
 | 
					#!/usr/bin/env bash
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if [ "$TERM_PROGRAM" = tmux ]; then
 | 
				
			||||||
 | 
					  cd ~/.zk && $EDITOR "$(cat ~/.zk/current-zettel.txt)"
 | 
				
			||||||
 | 
					else
 | 
				
			||||||
 | 
					  echo 'Not in tmux'
 | 
				
			||||||
 | 
					  echo 'Choose an option:'
 | 
				
			||||||
 | 
					  echo '1. Open in tmux'
 | 
				
			||||||
 | 
					  echo '2. Open in current terminal'
 | 
				
			||||||
 | 
					  read -r -p 'Enter your choice: ' choice
 | 
				
			||||||
 | 
					  case $choice in
 | 
				
			||||||
 | 
					    1)
 | 
				
			||||||
 | 
					      # Check if a tmux session is running with a window named zk
 | 
				
			||||||
 | 
					      if tmux list-windows -F '#{window_name}' | grep -q zk; then
 | 
				
			||||||
 | 
					        # Attach to the session containing the 'zk' window
 | 
				
			||||||
 | 
					        session="$(tmux list-windows -F '#{window_name} #{session_name}' | grep zk | head -n 1 | awk '{ print $2 }')"
 | 
				
			||||||
 | 
					        tmux attach -t "$session"
 | 
				
			||||||
 | 
					      else
 | 
				
			||||||
 | 
					        # Create session with a window named 'zk' and start nvim
 | 
				
			||||||
 | 
					        tmux new-session -s zk -n zk -d
 | 
				
			||||||
 | 
					        tmux send-keys -t zk:zk "cd ~/.zk && $EDITOR \"\$(cat ~/.zk/current-zettel.txt)\"" Enter
 | 
				
			||||||
 | 
					        tmux attach -t zk
 | 
				
			||||||
 | 
					      fi
 | 
				
			||||||
 | 
					      ;;
 | 
				
			||||||
 | 
					    2)
 | 
				
			||||||
 | 
					      cd ~/.zk && $EDITOR "$(cat ~/.zk/current-zettel.txt)"
 | 
				
			||||||
 | 
					      ;;
 | 
				
			||||||
 | 
					    *)
 | 
				
			||||||
 | 
					      echo 'Not opening Zettelkasten'
 | 
				
			||||||
 | 
					      exit 1
 | 
				
			||||||
 | 
					      ;;
 | 
				
			||||||
 | 
					  esac
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
		Loading…
	
		Reference in New Issue