Skip to content

Instantly share code, notes, and snippets.

@fredjoseph
Last active September 6, 2020 11:16
Show Gist options
  • Select an option

  • Save fredjoseph/e5b058dfc4c84ff1621dd3e224a61e45 to your computer and use it in GitHub Desktop.

Select an option

Save fredjoseph/e5b058dfc4c84ff1621dd3e224a61e45 to your computer and use it in GitHub Desktop.
WSL

WSL

Terminal

  • wsltty: alternative to the default terminal allowing a simpler and more exhaustive configuration.

Quake mode

Requirements

  • AutoHotKey

Install

cd ~/.ahk
git clone https://github.com/lonepie/mintty-quake-console.git
.\mintty-quake-console\mintty-quake-console.ahk

If not already done, associate .ahk files to the autohotkey program (autohotkey.exe).

Configuration

Right click the mintty-quake-console icon in system tray and select Options

  • Hotkey Trigger : CTRL + *
  • Mintty Arguments : put your distribution name to the WSL argument (--WSL="Ubuntu")
  • Start With Windows : 1

Right click the mintty-quake-console icon in system tray and select Edit Config

  • initial_trans : 235
  • animation_step : 70
  • animation_timeout : 2
  • animation_mode_slide : 1
  • animation_mode_fade : 0

Right click the mintty-quake-console icon in system tray and select Reload

To run a different shell without changing WSL's default shell, append shell path to mintty_args:

mintty_args=--WSL= --configdir="%APPDATA%\wsltty" -~ /usr/bin/fish -li

Shortcuts

Ctrl+Alt+Numpad(+) increase console height

Ctrl+Alt+Numpad(-) decrease console height

Ctrl+Alt+] increase console width

Ctrl+Alt+[ decrease console width

Ctrl+Alt+Numpad(/) toggle window borders and titlebar

Ctrl+Alt+Numpad(*) saves height, width & window borders state

Ctrl+Alt+Numpad(.) toggle script

Note

For launching automatically a .ahk file at startup, copy it into the auto startup folder (Win+R : shell:startup)

Configuration

Theme

Various themes can be found here

Copy/paste the following lines in %AppData%/wsltty/themes/monokai-custom.minttyrc

BackgroundColour=39,40,34
ForegroundColour=248,248,242
CursorColour=248,248,242
Black=39,40,34
BoldBlack=55,59,65
Red=165,66,66
BoldRed=204,102,102
Green=136,223,15
BoldGreen=181,189,104
Yellow=138,138,19
BoldYellow=240,198,116
Blue=43,145,193
BoldBlue=129,162,190
Magenta=174,129,255
BoldMagenta=245,244,241
Cyan=94,141,135
BoldCyan=138,190,183
White=248,248,242
BoldWhite=249,248,245

Options

Server X

  • VcXsrv: X Server for windows

Configuration

  • display settings: Multiple windows
  • Start no client
  • Extra settings: keep the default ones

System (Ubuntu)

  • Update distribution
sudo apt update
sudo apt upgrade -y
  • Install
# change root password
sudo passwd

# Powerline
sudo apt install powerline -y

# dbus (required if you used Ubuntu WSL and a X Server)
sudo apt-get install dbus-x11
sudo dbus-uuidgen --ensure

# Install Node.js, NPM and dependencies
curl "https://api.github.com/repos/nvm-sh/nvm/releases/latest" | grep -Po '"tag_name": "\K.*?(?=")' | xargs -I {} curl -o- "https://raw.githubusercontent.com/nvm-sh/nvm/{}/install.sh" | bash
export NVM_DIR=$HOME/.nvm
. $NVM_DIR/nvm.sh
nvm install v10.16.1

# update NPM
npm install -g npm

# install Yarn
npm install -g yarn
yarn config set prefix $HOME/.yarn-global

# install maven
sudo apt install -y maven

# install zsh
sudo apt install -y zsh

# install oh-my-zsh
git clone git://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh
chsh -s /bin/zsh $whoami

# nvm
git clone https://github.com/lukechilds/zsh-nvm ~/.oh-my-zsh/custom/plugins/zsh-nvm
git clone https://github.com/lukechilds/zsh-better-npm-completion ~/.oh-my-zsh/custom/plugins/zsh-better-npm-completion

# install fuzzy finder
sudo apt install -y fzy

# install httpie
sudo apt install -y httpie

# install tig
sudo apt install tig

# install jq
sudo apt install -y jq

# install gron (make JSON greppable)
sudo apt install gron

# install q
curl --silent "https://api.github.com/repos/harelba/q/releases/latest" | grep -Po '"tag_name": "\K.*?(?=")' | xargs -I {} curl -sOL "https://github.com/harelba/packages-for-q/raw/master/deb/q-text-as-data_{}-2_amd64.deb"
sudo dpkg -i q-text-*_amd64.deb
rm q-text-*

# install psmisc (small utilities including killall)
sudo apt install -y psmisc

mkdir ~/.zsh-custom.d
mkdir ~/.zsh-custom.d/completions

# install prettyping
curl -O https://raw.githubusercontent.com/denilsonsa/prettyping/master/prettyping
chmod u+x prettyping

# install htop
sudo apt install htop

# install z/fzf
git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf
curl "https://raw.githubusercontent.com/rupa/z/master/{z.sh}" -o ~/.zsh-custom.d/completions/"#1"
curl "https://raw.githubusercontent.com/changyuheng/fz/master/{fz.sh}" -o ~/.zsh-custom.d/completions/z"#1"
.fzf/install --all --no-bash

# fzf-marks
git clone https://github.com/urbainvaes/fzf-marks.git ~/.fzf-marks
echo "source ~/.fzf-marks/fzf-marks/fzf-marks.plugin.zsh" >> ~/.zshrc

# install autojump
sudo apt install -y autojump

# install zsh-syntax-highlighting
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ~/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting

# install k
git clone https://github.com/supercrabtree/k ~/.oh-my-zsh/custom/plugins/k

# install bd
mkdir -p ~/.oh-my-zsh/custom/plugins/bd
curl https://raw.githubusercontent.com/Tarrasch/zsh-bd/master/bd.zsh > ~/.oh-my-zsh/custom/plugins/bd/bd.zsh

#install highlight
sudo apt install -y highlight

# install nnn
curl --silent "https://api.github.com/repos/jarun/nnn/releases/latest" | grep -Po '"tag_name": "v\K.*?(?=")' | xargs -I {} curl -sOL "https://github.com/jarun/nnn/releases/download/v{}/nnn_{}-1_debian9.amd64.deb"
sudo dpkg -i nnn_*_debian9.amd64.deb
rm nnn_*

# install has
su -c "curl -sL https://git.io/_has > /usr/local/bin/has" root
sudo chmod +x /usr/local/bin/has

# install cheat.sh
sudo apt install -y xsel rlwrap
su -c "curl https://cht.sh/:cht.sh > /usr/local/bin/cht.sh" root
sudo chmod +x /usr/local/bin/cht.sh

# install ncdu
sudo apt install ncdu

# install entr
sudo apt install entr

# install ctags
sudo apt install universal-ctags

# install direnv
sudo apt install direnv

# install lnav
sudo apt install lnav

# install colordiff
sudo apt install colordiff

# install vnstat
sudo apt install vnstat

# install pet
curl --silent "https://api.github.com/repos/knqyf263/pet/releases/latest" | grep -Po '"tag_name": "v\K.*?(?=")' | xargs -I {} curl -sOL "https://github.com/knqyf263/pet/releases/download/v{}/pet_{}_linux_amd64.deb"
sudo dpkg -i pet_*_amd64.deb
rm pet_*

# Rust applications
# Update Rust (only required if you install the applications with `cargo install <appName>`)
sudo apt remove rustc -y
curl https://sh.rustup.rs -sSf | sh -s -- -y
source $HOME/.cargo/env

# install bat (cargo <appName>: bat) - Already in apt repositories
curl --silent "https://api.github.com/repos/sharkdp/bat/releases/latest" | grep -Po '"tag_name": "v\K.*?(?=")' | xargs -I {} curl -sOL "https://github.com/sharkdp/bat/releases/download/v{}/bat_{}_amd64.deb"
sudo dpkg -i bat*_amd64.deb
rm bat*

# install exa (cargo <appName>: exa) - Already in apt repositories
curl --silent "https://api.github.com/repos/ogham/exa/releases/latest" | grep -Po '"tag_name": "v\K.*?(?=")' | xargs -I {} curl -sOL "https://github.com/ogham/exa/releases/download/v{}/exa-linux-x86_64-{}.zip"
unzip exa-linux-*.zip
sudo mv exa-linux-x86_64 /usr/local/bin/exa
rm -rf exa-linux-*

# install fd (cargo <appName>: fd-find)
curl --silent "https://api.github.com/repos/sharkdp/fd/releases/latest" | grep -Po '"tag_name": "v\K.*?(?=")' | xargs -I {} curl -sOL "https://github.com/sharkdp/fd/releases/download/v{}/fd_{}_amd64.deb"
sudo dpkg -i fd_*_amd64.deb
rm fd_*

# install procs (cargo <appName>: procs)
curl --silent "https://api.github.com/repos/dalance/procs/releases/latest" | grep -Po '"tag_name": "v\K.*?(?=")' | xargs -I {} curl -sOL "https://github.com/dalance/procs/releases/download/v{}/procs-v{}-x86_64-lnx.zip"
unzip procs-*.zip
sudo mv procs /usr/local/bin/
rm -rf procs-*

# install sd (cargo <appName>: sd)
curl --silent "https://api.github.com/repos/chmln/sd/releases/latest" | grep -Po '"tag_name": "v\K.*?(?=")' | xargs -I {} curl -sOL "https://github.com/chmln/sd/releases/download/v{}/sd-v{}-x86_64-unknown-linux-gnu"
mv sd-v* sd
chmod +x sd
sudo mv sd /usr/local/bin/

# install dust (cargo <appName>: du-dust)
curl --silent "https://api.github.com/repos/bootandy/dust/releases/latest" | grep -Po '"tag_name": "v\K.*?(?=")' | xargs -I {} curl -sOL "https://github.com/bootandy/dust/releases/download/v{}/dust-v{}-x86_64-unknown-linux-gnu.tar.gz"
tar -xvf dust-v*.tar.gz
sudo mv dust-v*/dust /usr/local/bin/
rm -rf dust-v*

# install ripgrep (cargo <appName>: ripgrep) - Already in apt repositories
curl --silent "https://api.github.com/repos/BurntSushi/ripgrep/releases/latest" | grep -Po '"tag_name": "\K.*?(?=")' | xargs -I {} curl -sOL "https://github.com/BurntSushi/ripgrep/releases/download/{}/ripgrep_{}_amd64.deb"
sudo dpkg -i ripgrep_*_amd64.deb
rm ripgrep_*

# install tokei (cargo <appName>: tokei)
curl --silent "https://api.github.com/repos/XAMPPRocky/tokei/releases/latest" | grep -Po '"tag_name": "\K.*?(?=")' | xargs -I {} curl -sOL "https://github.com/XAMPPRocky/tokei/releases/download/{}/tokei-x86_64-unknown-linux-gnu.tar.gz"
tar -xvf tokei-*.tar.gz
sudo mv tokei /usr/local/bin
rm tokei-*

# install hyperfine (cargo <appName>: hyperfine)
curl --silent "https://api.github.com/repos/sharkdp/hyperfine/releases/latest" | grep -Po '"tag_name": "v\K.*?(?=")' | xargs -I {} curl -sOL "https://github.com/sharkdp/hyperfine/releases/download/v{}/hyperfine_{}_amd64.deb"
sudo dpkg -i hyperfine_*_amd64.deb
rm  hyperfine_*

# install ytop (cargo <appName>: ytop)
curl --silent "https://api.github.com/repos/cjbassi/ytop/releases/latest" | grep -Po '"tag_name": "\K.*?(?=")' | xargs -I {} curl -sOL "https://github.com/cjbassi/ytop/releases/download/{}/ytop-{}-x86_64-unknown-linux-gnu.tar.gz"
tar -xvf ytop-*.tar.gz
sudo mv ytop /usr/local/bin
rm  ytop-*

# install tealdeer (tldr client) (cargo <appName>: tealdeer)
curl --silent "https://api.github.com/repos/dbrgn/tealdeer/releases/latest" | grep -Po '"tag_name": "v\K.*?(?=")' | xargs -I {} curl -sOL "https://github.com/dbrgn/tealdeer/releases/download/v{}/tldr-linux-x86_64-musl"
mv tldr-linux-x86_64* tldr
chmod +x tldr
sudo mv tldr /usr/local/bin/
curl -sOL https://raw.githubusercontent.com/dbrgn/tealdeer/master/zsh_tealdeer
sudo mv zsh_tealdeer /usr/local/share/zsh/site-functions/_tldr

# install bandwhich (cargo <appName>: bandwhich)
curl --silent "https://api.github.com/repos/imsnif/bandwhich/releases/latest" | grep -Po '"tag_name": "\K.*?(?=")' | xargs -I {} curl -sOL "https://github.com/imsnif/bandwhich/releases/download/{}/bandwhich-v{}-x86_64-unknown-linux-musl.tar.gz"
tar -xvf bandwhich-*.tar.gz
sudo mv bandwhich /usr/local/bin
rm  bandwhich-*

# install grex (cargo <appName>: grex)
curl --silent "https://api.github.com/repos/pemistahl/grex/releases/latest" | grep -Po '"tag_name": "v\K.*?(?=")' | xargs -I {} curl -sOL "https://github.com/pemistahl/grex/releases/download/v{}/grex-v{}-x86_64-unknown-linux-musl.tar.gz"
tar -xvf grex-*.tar.gz
sudo mv grex /usr/local/bin
rm  grex-*

# install rmesg (cargo <appName>: rmesg)
curl --silent "https://api.github.com/repos/polyverse/rmesg/releases/latest" | grep -Po '"tag_name": "v\K.*?(?=")' | xargs -I {} curl -sOL "https://github.com/polyverse/rmesg/releases/download/v{}/rmesg"
chmod +x rmesg
sudo mv rmesg /usr/local/bin/

# install zoxide (cargo <appName>: zoxide)
curl --silent "https://api.github.com/repos/ajeetdsouza/zoxide/releases/latest" | grep -Po '"tag_name": "v\K.*?(?=")' | xargs -I {} curl -sOL "https://github.com/ajeetdsouza/zoxide/releases/download/v{}/zoxide-x86_64-unknown-linux-gnu"
mv zoxide* zoxide
chmod +x zoxide
sudo mv zoxide /usr/local/bin/

# install so (cargo <appName>: so)
curl --silent "https://api.github.com/repos/samtay/so/releases/latest" | grep -Po '"tag_name": "v\K.*?(?=")' | xargs -I {} curl -sOL "https://github.com/samtay/so/releases/download/v{}/so-v{}-x86_64-unknown-linux-gnu.tar.gz"
tar -xvf so-*.tar.gz
sudo mv so /usr/local/bin
rm  so-*

# install gitui (cargo <appName>: gitui)
curl --silent "https://api.github.com/repos/extrawurst/gitui/releases/latest" | grep -Po '"tag_name": "v\K.*?(?=")' | xargs -I {} curl -sOL "https://github.com/extrawurst/gitui/releases/download/v{}/gitui-linux-musl.tar.gz"
tar -xvf gitui-*.tar.gz
sudo mv gitui /usr/local/bin
rm gitui-*

# install nushell (cargo <appName>: nu)
curl --silent "https://api.github.com/repos/nushell/nushell/releases/latest" | grep -Po '"browser_download_url": "\K.*?linux.tar.gz(?=")' | xargs -I {} curl -sOL {}
tar -xvf nu_*.tar.gz
sudo mv nu_*/* /usr/local
sudo mv /usr/local/nushell* /usr/local/nushell
sudo ln -s /usr/local/nushell/nu /usr/local/bin/nu
rm -r nu*

# install bottom (cargo <appName>: bottom)
curl --silent "https://api.github.com/repos/ClementTsang/bottom/releases/latest" | grep -Po '"browser_download_url": "\K.*.deb(?=")' | xargs -I {} curl -sOL {}
sudo dpkg -i bottom_*
rm bottom_*

# install broot (cargo <appName>: broot)
curl -sOL https://dystroy.org/broot/download/x86_64-linux/broot
chmod +x broot
sudo mv broot /usr/local/bin

# install delta
curl --silent "https://api.github.com/repos/dandavison/delta/releases/latest" | grep -Po '"tag_name": "\K.*?(?=")' | xargs -I {} curl -sOL "https://github.com/dandavison/delta/releases/download/{}/git-delta_{}_amd64.deb"
sudo dpkg -i git-delta*_amd64.deb
rm  git-delta*

# install gitoxide (cargo <appName>: gitoxide)
curl --silent "https://api.github.com/repos/Byron/gitoxide/releases/latest" | grep -Po '"browser_download_url": "\K.*-max-.*linux-musl.tar.gz(?=")' | xargs -I {} curl -sOL {}
tar -xvf gix-*.tar.gz
mv gix-*/gix .cargo/bin
mv gix-*/gixp .cargo/bin
rm -r gix-*

# install cointop
curl -o- https://raw.githubusercontent.com/miguelmota/cointop/master/install.sh | bash

# NPM applications
# install can i use
npm install -g caniuse-cmd
# install tldr
npm install -g tldr
# install fx (JSON viewer)
npm install -g fx
# install fkill
npm install -g fkill-cli
# install vtop
npm install -g vtop
# install kmdr
npm install -g kmdr
# install http-server
npm install -g http-server
# install live-server
npm install -g live-server
# install npkill (find and delete node_modules folders)
npm i -g npkill
# install dockly
npm install -g dockly
# install how2
npm install -g how-2
# diff-so-fancy
npm install -g diff-so-fancy
# undollar
npm install -g undollar

# tmux plugin manager
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm

# clean
chmod -R g-w-x,o-w-x ~/.oh-my-zsh

bash

Configuration

See here

Tmux

Configuration

See here

Copy

By holding the Shift key, the mouse inputs are directly sent to the terminal (xterm, terminal, etc) and tmux's mouse mode is bypassed.

  • Shift + select text using mouse, then mouse right click: copy the selection.
  • Shift + double-click (mouse left button): copy the double clicked word.
  • Shift + mouse right click: paste the copied text
  • Ctrl + Shift + mouse right click: open menu

Vi

Configuration

.plug.vim

See here

.vimrc

See here

Git

Configuration

See here

Tips

Reset WSL password

  • Change the default user name for your WSL distro to root. Use the following command:
  ubuntu config --default-user root
  • Launch your Linux distribution, e.g. type ubuntu
  • Reset your password using the passwd command: passwd <username>. Substitute the portion with the actual user name you want to reset the password for
  • Leave your WSL session and set the default user of the WSL distro back to your user account.
  ubuntu config --default-user <username>

For other distros, replace ubuntu by one of the following

  • OpenSUSE Leap 42: openSUSE-42
  • SUSE Linux: SLES-12
  • Debian: debian
  • Kali Linux: kali

ZSH

Newly added completion file not loaded

Try removing any .zcompdump files in your home directory

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment