Skip to content

Instantly share code, notes, and snippets.

@liangfu
Last active July 18, 2023 17:24
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save liangfu/feea9c45d5c508afad276685be577240 to your computer and use it in GitHub Desktop.
Save liangfu/feea9c45d5c508afad276685be577240 to your computer and use it in GitHub Desktop.
Initialize dev workspace with a single bash script
apt update
apt install -y emacs-nox aptitude screen xcscope-el gdb nano || echo 0 && echo "Success"
python3 -m pip install git-remote-codecommit opennmt-tf==1.25.1
cat << EOF > ~/.gdbinit
set print thread-events off
define hook-run
catch throw
end
define hook-quit
set confirm off
end
define vp
print *($arg0._M_impl._M_start)@$arg0.size()
end
EOF
echo "Created ~/.gdbinit"
cat << EOF > ~/.cuda-gdbinit
set print thread-events off
define hook-run
catch throw
set cuda break_on_launch application
end
define hook-quit
set confirm off
end
EOF
echo "Created ~/.cuda-gdbinit"
cat << 'EOF' > ~/.emacs
;;User information
(setq user-full-name "Liangfu Chen")
(setq user-mail-address "liangfc@amazon.com")
(setq user-organization "Amazon Web Services")
;;windmove helper
;;https://stackoverflow.com/questions/4351044/binding-m-up-m-down-in-emacs-23-1-1
(define-key input-decode-map "\e\e[A" [(meta up)])
(define-key input-decode-map "\e\e[B" [(meta down)])
(define-key input-decode-map "\e\e[C" [(meta right)])
(define-key input-decode-map "\e\e[D" [(meta left)])
;;Using windmove
(global-set-key (kbd "M-<left>") 'windmove-left)
(global-set-key (kbd "M-<right>") 'windmove-right)
(global-set-key (kbd "M-<up>") 'windmove-up)
(global-set-key (kbd "M-<down>") 'windmove-down)
;;Open .h files in c++ mode
(add-to-list 'auto-mode-alist '("\\.\\(h\\|hpp\\)\\'" . c++-mode))
(add-to-list 'auto-mode-alist '("\\.\\(cc\\|cpp\\|cu\\)\\'" . c++-mode))
;;No tabs
(setq-default indent-tabs-mode nil)
(setq tab-width 2) ; or any other preferred value
(setq js-indent-level 2)
(setq-default c-basic-offset 4)
(defvaralias 'c-basic-offset 'tab-width)
(defvaralias 'cperl-indent-level 'tab-width)
(add-to-list 'default-frame-alist '(height . 50))
(add-to-list 'default-frame-alist '(width . 150))
(setq inhibit-startup-screen t)
(setq inhibit-default-init t)
(setq inhibit-splash-screen t) ; hide welcome screen
;;Using [F5] to refresh file list
(defun refresh-file ()
(interactive)
(revert-buffer t t t))
(global-set-key [f5] 'refresh-file)
(global-set-key [f9] 'compile)
;;Treat 'y' or <CR> as yes, 'n' as no.
(fset 'yes-or-no-p 'y-or-n-p)
(define-key query-replace-map [return] 'act)
;;Diable back up files option
(setq make-backup-files nil)
;;Display trailing whitespace
(setq show-trailing-whitespace t)
;;Display time options
(setq display-time t
display-time-24hr-format t)
(display-time)
;;Define custom other file list
(defvar my-cpp-other-file-alist
'(("\\.hpp\\'" (".cc" ".cpp"))
("\\.h\\'" (".cpp" ".cc" ".cu" ".c"))
("\\.cpp\\'" (".h" ".hpp"))
("\\.cxx\\'" (".h" ".hpp"))
("\\.cc\\'" (".h" ".hpp"))
("\\.cu\\'" (".h" ".hpp"))
("\\.c\\'" (".h"))
))
(setq-default ff-other-file-alist 'my-cpp-other-file-alist)
;;Directories to find header and source files
(setq ff-search-directories '("." "../src" "../include"))
(global-set-key "\C-co" 'ff-find-other-file)
;;Require cscope
(require 'xcscope)
;;Using gud-gdb as default debugger
(defalias 'gdb 'gud-gdb)
EOF
echo "Created ~/.emacs"
cat << EOF > ~/.bash_aliases
# User specific aliases and functions
alias scr='screen'
alias scrr='scr -D -R'
alias gl='git log --graph --pretty=format:"%Cred%h%Creset . %an: %s %Cgreen(%cr)%Creset" --abbrev-commit --date=relative'
alias ca='conda activate'
EOF
echo "Created ~/.bash_aliases"
cat << EOF > ~/.screenrc
## Control-^ (usually Control-Shift-6) is traditional and the only key not used by emacs
escape ^^^^
#
## do not trash BackSpace, usually DEL
bindkey -k kb
bindkey -d -k kb
#
## do not trash Delete, usually ESC [ 3 ~
bindkey -k kD
bindkey -d -k kD
#
#
term screen-256color
EOF
echo "Created ~/.screenrc"
cat << EOF > ~/.gitconfig
# This is Git's per-user configuration file.
[user]
name = Liangfu Chen
email = liangfc@amazon.com
[core]
editor = nano
pager = less
[color]
ui = auto
[push]
default = simple
[init]
defaultBranch = main
EOF
echo "Created ~/.gitconfig"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment