Last active
November 21, 2023 22:49
-
-
Save ClassicOldSong/c9d43e199a8929ad8d783e8a3bc3793b to your computer and use it in GitHub Desktop.
Use tmux as your login shell
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Usage: | |
# Download this file | |
# Put it in /bin or wherever you want, eg: `/bin/tmuxlogin` | |
# Give it excutable permission, eg: `sudo chmod +x /bin/tmuxlogin` | |
# Modify your `/etc/shells` and add `/bin/tmuxlogin` to it | |
# Modify your `~/.tmux.conf` and add `set-option -g default-shell /bin/bash(or whatever shell you want)` to it | |
# `chsh -s /bin/tmuxlogin` | |
# Done! | |
# Define colors | |
YELLOW="\033[0;93m" | |
GREEN="\033[0;32m" | |
CYAN="\033[0;36m" | |
RED="\033[0;31m" | |
NC="\033[0m" | |
# Do not attach when using a local terminal emulator or tty | |
if [ "$SSH_CLIENT" == "" ]; then | |
/usr/bin/tmux new | |
exit $? | |
fi | |
# Switch to bash when there's arguments exist | |
# such as `scp' or `sftp' or `ssh -t' | |
if [ "$1" != "" ]; then | |
exec -l /bin/bash "$@" | |
fi | |
# Add a pause for displaying motd | |
echo -e "\n$GREEN[ Press any key to continue ]\n$YELLOW" | |
read -n 1 -s -r | |
/usr/bin/tmux attach || /usr/bin/tmux new | |
EXITSTATUS=$? | |
echo -e $NC | |
exit $EXITSTATUS |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment