Advertisement
xosski

Developer tools setup script

Jan 22nd, 2025
12
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.11 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # Function for error handling
  4. trap 'echo "An error occurred. Exiting..." >&2; exit 1' ERR
  5.  
  6. # Ensure the script is being run as root (or with sudo privileges)
  7. if [ "$(whoami)" != "root" ]; then
  8. echo "Error: This script must be run as root or with sudo." >&2
  9. exit 1
  10. fi
  11.  
  12. # Update package lists and install essential packages
  13. echo "Updating package lists and installing packages..."
  14. sudo apt update -y
  15. sudo apt install -y git vim tmux
  16.  
  17. # Set up Vim with sensible configuration
  18. echo "Setting up vim..."
  19. mkdir -p ~/.vim/pack/tpope/start
  20. cd ~/.vim/pack/tpope/start
  21. git clone https://tpope.io/vim/sensible.git
  22. echo "set number" >> ~/.vimrc
  23. echo "set clipboard=unnamedplus" >> ~/.vimrc
  24.  
  25. # Set up tmux with TPM (Tmux Plugin Manager)
  26. echo "Setting up tmux..."
  27. git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
  28. cat <<EOL >> ~/.tmux.conf
  29. # List of plugins
  30. set -g @plugin 'tmux-plugins/tpm'
  31. set -g @plugin 'tmux-plugins/tmux-sensible'
  32.  
  33. # Other examples:
  34. # set -g @plugin 'github_username/plugin_name'
  35. # set -g @plugin 'github_username/plugin_name#branch'
  36. # set -g @plugin 'git@github.com:user/plugin'
  37. # set -g @plugin 'git@bitbucket.com:user/plugin'
  38.  
  39. # Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
  40. run '~/.tmux/plugins/tpm/tpm'
  41. EOL
  42.  
  43. # Set up nano with custom configuration
  44. echo "Setting up nano..."
  45. cat <<EOL >> ~/.nanorc
  46. set softwrap # enables softwrap
  47. set tabsize 4
  48. set tabstopspaces
  49. set constantshow
  50. set linenumbers
  51. set casesensitive
  52. set positionlog # saves cursor positions between saves, might change
  53. set zap
  54. set autoindent
  55. set indicator
  56. set minibar
  57. EOL
  58.  
  59. # Make bash less annoying with custom settings
  60. echo "Customizing bash..."
  61. cat <<EOL >> ~/.bashrc
  62. # Perform file completion in a case insensitive fashion
  63. bind 'set completion-ignore-case on'
  64.  
  65. # Treat hyphens and underscores as equivalent
  66. bind 'set completion-map-case on'
  67.  
  68. # Display matches for ambiguous patterns at first tab press
  69. bind 'set show-all-if-ambiguous on'
  70.  
  71. # Immediately add a trailing slash when autocompleting symlinks to directories
  72. bind 'set mark-symlinked-directories on'
  73.  
  74. # SANE HISTORY DEFAULTS
  75. shopt -s histappend # Append to the history file, don't overwrite it
  76. shopt -s cmdhist # Save multi-line commands as one command
  77. PROMPT_COMMAND='history -a' # Record each line as it gets issued
  78. HISTSIZE=500000 # Huge history. Doesn't appear to slow things down, so why not?
  79. HISTFILESIZE=100000
  80. HISTCONTROL='erasedups:ignoreboth' # Avoid duplicate entries
  81. export HISTIGNORE='&:[ ]*:exit:ls:bg:fg:history:clear' # Don't record some commands
  82.  
  83. # Enable incremental history search with up/down arrows
  84. bind ''\e[A': history-search-backward'
  85. bind ''\e[B': history-search-forward'
  86. bind ''\e[C': forward-char'
  87. bind ''\e[D': backward-char'
  88.  
  89. # Correct spelling errors during tab-completion
  90. shopt -s dirspell 2> /dev/null
  91. # Correct spelling errors in arguments supplied to cd
  92. shopt -s cdspell 2> /dev/null
  93. EOL
  94.  
  95. # Reload bashrc to apply changes
  96. source ~/.bashrc
  97.  
  98. echo "Setup complete. Please restart your terminal or run 'source ~/.bashrc' to apply the changes."
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement