Skip to content

Instantly share code, notes, and snippets.

@ma-al
Last active March 29, 2023 04:15
Show Gist options
  • Save ma-al/eec01504be44010c7d657f837170543b to your computer and use it in GitHub Desktop.
Save ma-al/eec01504be44010c7d657f837170543b to your computer and use it in GitHub Desktop.
Miscellaneous creature comforts πŸ›€πŸ½ when working in JupyterLab

Shell Comforts In JupyterLab Terminal

Get aliases and colors into the JupyterLab terminal:

Create a .profile file in $USER containing:

bash
source $USER/.bashrc

(Thanks to https://stackoverflow.com/a/70699378)

Then, add your customisations in ~/.bashrc:

PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME} - ${PWD}\007"'
  
[ -z "$PS1" ] && return
PS1="\[\e[0;36m\]\[\e[1;33m\]>>>>\[\e[0m\] "

export PAGER=less
export EDITOR=vim
export HISTCONTROL=ignorespace:ignoredups
export HISTIGNORE="l:c:x:hg:history"
export HISTSIZE=30000
export HISTFILESIZE=30000

alias c=clear
alias l='ls -Flh --color=auto --time-style=long-iso'
alias ll='ls -FCAlh --color=auto --time-style=long-iso'
alias lp='ls -ld --color=auto --time-style=long-iso */'
alias lk="readlink -f "
alias xx=exit

alias hg='history | grep -v hg | grep -i '
alias fp='ps aux | grep -v grep | grep -i '
alias ps3='pstree -cupsa'
alias grep='grep --color=always '
alias grin='grep -rIn'
alias ips="ip -o addr show scope global | awk '{gsub(/\/.*/, \" \",\$4); print \$4}'"
alias dus="du -h | sort -hr | head -40"

alias cd="pushd 1> /dev/null "
alias pd="popd 1> /dev/null "
alias cdd="cd ~/"

alias gclo="git clone"
alias gsta="git status"
alias gadd="git add"
alias gbra="git branch -v"
alias grem="git remote -v"
alias gcov="git count-objects -v"
alias glog="git log --oneline"
alias gchk="git checkout"
alias gcsa="git commit -sa"
alias gcom="git commit -s"
alias gpll="git pull"
alias gpsh="git push"

SSH

Open JupyterLab's Terminal (via the Launcher) and do:

# create the key
cd ~/.ssh/
ssh-keygen

# add to current agent
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/<key-file>

# test access
ssh -T git@github.com

Then, add following to ~/.ssh/config:

Host github.com
   IdentityFile ~/.ssh/<key-file>

(Thanks to https://stackoverflow.com/a/21938804)

JupyterLab's UI Git client should now work!

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