Listing posts

Displaying posts 11 - 15 of 328 in total
Rails bin/dev via GNU screen
mouse 90 · person cloud · link
Last update
2024-03-01
2024
03-01
«run Procfile.dev within GNU screen»

Prepend to bin/dev:

1
2
3
4
5
6
7
8
if command -v screen &> /dev/null; then
  rc_file="tmp/screenrc"
  grep -E -v "^(screen|select|source) " $HOME/.screenrc 2> /dev/null > $rc_file
  nl bin/Procfile.dev | \
    sed -r 's/^\s*([0-9]+)\s*([^:]+): (.+)/split\nfocus\nscreen -t \2 \1 \3/' | \
    tail -n +3 >> $rc_file
  exec screen -c $rc_file
fi

Source: kyrylo.org and overmind


~~~ * ~~~


~~~ * ~~~

GNU Screen | terminal multiplexer attachment
mouse 2729 · person cloud · link
Last update
2024-02-23
2024
02-23
«terminal multiplexer»

Screen commands shortcuts:

Shortcut Descr
^a c create new terminal (use in new regions too)
^a # switch to # terminal (0-9)
^a " terminals list
^a A set the current terminal name/title
^a d detach session
^a S or ^a | split region horizontally or vertically
^a X close current region
^a Q close all regions but the current one
^a tab switch inputo to next region
^a ^a toggle between current and previous region
^a k terminate the current window/tab
^a \ terminate entire session
^a :number x changer current terminal number to x

Scrolling + copy&paste:

Press ^a esc then use PgUp/Dn or Up/Dn arrows to scroll, when finished hit return two times.

If you move the cursor after hitting return once, you will be selecting text to copy, and hitting return the second time will copy it. Then you can paste it with ^a ].

Command line how-to:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
screen       # start a new session (default screen is 0)
screen -d -m # start a new detached session (useful in scrips)
screen -r    # reattach to a running session

screen -d|-D [pid.tty.host] # detaches the elsewhere running screen session

# reattaching options (in case of a "stale attached state"):
screen -d -r   # reattach a session and if necessary detach it first
screen -d -R   # reattach a session and if necessary detach or create it
screen -d -RR  # reattach to the first session and if necessary detach or create it

# or reattach trying even harder:
screen -D -r   # reattach a session, if necessary detach and logout remotely first
screen -D -R   # same as "-D -r" but also notify the user
screen -D -RR  # attach here and now. whatever that means, just do it

Share a session with another user

Same account

1
2
3
4
5
6
7
# user1 starts the session then attach to it
screen -d -m -S shared # start a new detached session called `shared`
screen -x shared # attach in multi display mode

# user2 only attach to it
screen -ls # show current sessions
screen -x shared # attach in multi display mode

Different accounts

1
2
3
4
5
6
7
8
# user1 starts the session then attach to it
screen -d -m -S shared # start a new detached session called `shared`
screen -r shared # attach to the named session
# press "Ctrl-a" and type ":multiuser on"
# press "Ctrl-a" and type ":acladd user2"

# user2 only attach to it
screen -x user1/shared

Note: the multiuser mode needs screen as suid root but this is a security issue... if you want to enable it then type as root:

1
2
3
chmod u+s `which screen`
chmod 755 /var/run/screen
rm -fr /var/run/screen/*

but you really should make a third shared account which both users can log into.

Customize session (see attachment):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# ~/.screenrc - screen user config file

# the following two lines give a two-line status, with the current window highlighted
hardstatus alwayslastline '%{= kG}@%{G}%H%? %1`%?%{g}|%= %{= kw}%-w%{+b yk} %n*%t%?(%u)%? %{-}%+w %=%{g}|%{y}%l%{g}|%{B}%Y-%m-%d %{W}%c%{g}'

# huge scrollback buffer
defscrollback 1000

# no welcome message
startup_message off

# 256 colors
term screen-256color
attrcolor b ".I"
#termcapinfo xterm 'Co#256:AB=\E[48;5;%dm:AF=\E[38;5;%dm'
#termcapinfo xterm* ti@:te@
#defbce on

# mouse tracking allows to switch region focus by clicking
mousetrack off

shelltitle --
#shell /usr/bin/fish

# select window 1..10 with sequence "^a 1..0"
bind c screen 1 # window numbering starts at 1 not 0
bind 0 select 10

# turn of flow control (^S-^Q / XON-XOFF characters)
defflow off

# default windows
screen 1 bash
screen 2 bash
select 1

# https://www.gnu.org/software/screen/manual/html_node/Key-Binding.html#Key-Binding
maptimeout 1000
# NOTE: run `showkey -a` to see keycodes to use here
# select window 11..20 with sequence "^A .N", where N=1..0
bind .  # unbind "^A ." (write termcap)
bindkey "^A.1" select 11
bindkey "^A.2" select 12
bindkey "^A.3" select 13
bindkey "^A.4" select 14
bindkey "^A.5" select 15
bindkey "^A.6" select 16
bindkey "^A.7" select 17
bindkey "^A.8" select 18
bindkey "^A.9" select 19
bindkey "^A.0" select 20

# switch windows with F1 (prev) and F2 (next)
# x11
bindkey "^[OP" prev
bindkey "^[OQ" next
# old VT console
bindkey "^[[[A" prev
bindkey "^[[[B" next

## get rid of silly xoff stuff
#bind s split
## Ctrl+F2 puts Screen into resize mode. Resize regions using hjkl keys.
#bindkey "^[O1;5Q" eval "command -c rsz" # enter resize mode
## use hjkl keys to resize regions
#bind -c rsz h eval "resize -h -5" "command -c rsz"
#bind -c rsz j eval "resize -h +5" "command -c rsz"
#bind -c rsz k eval "resize -v -5" "command -c rsz"
#bind -c rsz l eval "resize -v +5" "command -c rsz"

# navigating regions with Ctrl-arrows
#bindkey "^[[1;5D" focus left
#bindkey "^[[1;5C" focus right
#bindkey "^[[1;5A" focus up
#bindkey "^[[1;5B" focus down

Tips & tricks

  • Use this handy script to start your terminals the way you want:
1
2
3
4
5
6
7
8
#!/bin/bash
if [ -z "$1" ]; then
  echo "USAGE: bashto pwd [cmd arg1 arg2 ...]"
  exit
fi
cd "$1"                    # go to the specified folder
shift; [ -n "$1" ] && "$@" # execute an optional command
exec /bin/bash             # run shell

.screenrc example: screen -t www bashto /mnt/ramd elinks.

1
2
[ -n "$DISPLAY" ] && echo -n "$DISPLAY" > $HOME/.last_display
[ -z "$DISPLAY" ] && export DISPLAY=$(cat $HOME/.last_display)

Alternatives:


Source: GNU.org screen manual, ArchLinux tips, A killer GNU Screen Config gist, MC mouse support, Dev.to, Shared session


~~~ * ~~~

Chromium personalizations
mouse 1152 · person cloud · link
Last update
2024-02-23
2024
02-23
«chromium/google chrome/vivaldi/webkit engine based browsers
apps/addons/plugins fix»

Add-ons

developer mode

Go to chrome://extensions/ / vivaldi://extensions/ and toggle developer mode switch.

Vivaldi

Command line options

1
2
3
4
5
6
7
8
9
# https://www.ghacks.net/2017/02/13/how-to-speed-up-the-vivaldi-web-browser/
# optimized command for raspberry pi
/usr/bin/vivaldi \
  --process-per-site \
  --enable-low-res-tiling \
  --enable-low-end-device-mode \
  --disk-cache-size=104857600 \
  --disk-cache-dir=$TMPD \
  "$@"

Fix passwords not syncing

If you observe the following error in vivaldi://sync

1
2
Error: CleanupPasswordStore@components/password_manager/core/browser/sync/password_sync_bridge.cc:1067,
datatype error was encountered: Failed to get encryption key during database cleanup.
  1. close Vivaldi
  2. rm -f ~/.config/vivaldi/Default/Login\ Data*
  3. launch Vivaldi and the sync error in vivaldi://sync should have vanished

Video DRM/Widevine on Vivaldi

See: old script, vivaldi forum, test video, another test page

1
2
apt install libwidevinecdm0
echo '{"Path":"/opt/WidevineCdm"}' > ~/.config/vivaldi/WidevineCdm/latest-component-updated-widevine-cdm

~~~ * ~~~

nano editor settings
mouse 2243 · person cloud · link
Last update
2024-02-09
2024
02-09
« — »
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# /etc/nanorc or ~/.nanorc
set tabsize 2
set tabstospaces
set smarthome
set regexp
set nonewlines

#set autoindent
#set linenumbers

set constantshow

#set mouse

set nowrap

# use alt-</, or alt->/. to switch buffer
# user ^R ^T to open a new file buffer with file manager
set multibuffer